banach-space / llvm-tutor

A collection of out-of-tree LLVM passes for teaching and learning
MIT License
2.95k stars 393 forks source link

This analysis pass was not registered prior to being queried #113

Closed NoobCat2000 closed 6 months ago

NoobCat2000 commented 6 months ago

i was testing OpcodeCoutner pass in windows, but the assert failed in line:

auto& OpcodeMap = FAM.getResult<OpcodeCounter>(Func);

Delve more deeper, i see it fail in getResult, maybe PassInstrumentationAnalysis is not loaded. Can someone help me

jvstech commented 6 months ago

This is a bug that, for whatever reason, only occurs on Windows.

I get around this by manually adding llvm::PassInstrumentationAnalysis registration; it seems the fix here would be to add something like this to each of the analysis registrations:

  auto &MAM = FAM->getResult<ModuleAnalysisManagerFunctionProxy>(F).getManager();
  MAM.registerPass([&] { return PassInstrumentationAnalysis{}; });

I haven't taken a solid look at this code in a while, so I can only give this as a rough idea of what needs to be done.

In reality, I think there's an underlying issue with LLVM causing this problem in the first place, but it can be worked around.

NoobCat2000 commented 6 months ago

This is a bug that, for whatever reason, only occurs on Windows.

I get around this by manually adding llvm::PassInstrumentationAnalysis registration; it seems the fix here would be to add something like this to each of the analysis registrations:

  auto &MAM = FAM->getResult<ModuleAnalysisManagerFunctionProxy>(F).getManager();
  MAM.registerPass([&] { return PassInstrumentationAnalysis{}; });

I haven't taken a solid look at this code in a while, so I can only give this as a rough idea of what needs to be done.

In reality, I think there's an underlying issue with LLVM causing this problem in the first place, but it can be worked around.

Its work, you are great, thank you very much