<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/152673>152673</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[llvm 20.1.4]DominatorTreeAnalysis failed to be used
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kdr521
</td>
</tr>
</table>
<pre>
Recently, while I was working on the llvm project development, I wanted to obtain the dominating tree analysis results on the function, but was told the following error:
`Exception Code: 0xC0000005
#0 0x00007ffb9eca0709 llvm::AnalysisManager<llvm::Function>::getResultImpl(llvm::AnalysisKey*, llvm::Function&) (D:\project\source_code_obfuscation\Obfuscation_v1.0_bak\build\SplitFunction.dll+0x330709)
#1 0x00007ffb9eca0579 llvm::AnalysisManager<llvm::Function>::getResultImpl(llvm::AnalysisKey*, llvm::Function&) (D:\project\source_code_obfuscation\Obfuscation_v1.0_bak\build\SplitFunction.dll+0x330579)
#2 0x00007ffb9eca1386 llvm::DominatorTreeAnalysis::Result& llvm::AnalysisManager<llvm::Function>::getResult<llvm::DominatorTreeAnalysis>(llvm::Function&) (D:\project\source_code_obfuscation\Obfuscation_v1.0_bak\build\SplitFunction.dll+0x331386)
#3 0x00007ffb9e97849e TestPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (D:\project\source_code_obfuscation\Obfuscation_v1.0_bak\build\SplitFunction.dll+0x849e)
#4 0x00007ffb9ef0182a llvm::detail::PassModel<llvm::Function, TestPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (D:\project\source_code_obfuscation\Obfuscation_v1.0_bak\build\SplitFunction.dll+0x59182a)
#5 0x00007ff6a0e48889 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (D:\project\source_code_obfuscation\llvm-20.1.4\build\bin\opt.exe+0x15e8889)
#6 0x00007ff6a233c0d1 llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (D:\project\source_code_obfuscation\llvm-20.1.4\build\bin\opt.exe+0x2adc0d1)
#7 0x00007ff6a1ff05ab llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (D:\project\source_code_obfuscation\llvm-20.1.4\build\bin\opt.exe+0x27905ab)
#8 0x00007ff6a2338ab1 llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (D:\project\source_code_obfuscation\llvm-20.1.4\build\bin\opt.exe+0x2ad8ab1)
#9 0x00007ff6a0e42d29 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (D:\project\source_code_obfuscation\llvm-20.1.4\build\bin\opt.exe+0x15e2d29)
#10 0x00007ff6a15d6ba3 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (D:\project\source_code_obfuscation\llvm-20.1.4\build\bin\opt.exe+0x1d76ba3)
#11 0x00007ff6a39181b6 optMain (D:\project\source_code_obfuscation\llvm-20.1.4\build\bin\opt.exe+0x40b81b6)
#12 0x00007ff6a391e5b1 main (D:\project\source_code_obfuscation\llvm-20.1.4\build\bin\opt.exe+0x40be5b1)
#13 0x00007ff69f8610c9 __tmainCRTStartup D:/W/B/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:237:8
#14 0x00007ff69f861416 .l_start D:/W/B/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:124:3
#15 0x00007ffc16a87374 (C:\windows\System32\KERNEL32.DLL+0x17374)
#16 0x00007ffc1889cc91 (C:\windows\SYSTEM32\ntdll.dll+0x4cc91)
`
This is my code:
.h
`struct TestPass : public llvm::PassInfoMixin<TestPass> {
llvm::PreservedAnalyses run(llvm::Function &F, llvm::FunctionAnalysisManager &FAM);
};
`
.c
`PreservedAnalyses TestPass::run(llvm::Function &F, llvm::FunctionAnalysisManager &FAM) {
auto &DT = FAM.getResult<llvm::DominatorTreeAnalysis>(F);
auto &LI = FAM.getResult<llvm::LoopAnalysis>(F);
return llvm::PreservedAnalyses::all();
}
extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo llvmGetPassPluginInfo()
{
return {
LLVM_PLUGIN_API_VERSION,
"SplitFunction",
"v1.0",
[](PassBuilder &PB)
{
PB.registerAnalysisRegistrationCallback([](FunctionAnalysisManager &FAM)
{
llvm::errs() << "Registering DominatorTreeAnalysis and LoopAnalysis\n";
FAM.registerPass([] { return DominatorTreeAnalysis(); });
FAM.registerPass([] { return LoopAnalysis(); });
});
PB.registerPipelineParsingCallback([](StringRef Name, FunctionPassManager &FPM, ArrayRef<PassBuilder::PipelineElement> InnerPipeline)
{
if (Name != "test") return false;
FPM.addPass(TestPass());
return true;
});
}
};
}`
What was the reason for not registering?
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWVuT2rjW_TXqF1UoW7KN_cCD2w1TXYGEopmkvidKtjagL8KiJLkv__6UfMGGpjNJz8mcM2dcXQ3osvfaS0vSlsyMEbsSYILCWxTe3bDK7pWefOM6JP5NrvjLZAUFlFa-IJLhp72QgO_xEzP4SelvotxhVWK7Byzl4wEftfp_KCzm8AhSHQ9QWtfNdSgtcGwVVrllounC1UGUzDojVgNgVjL5YoTBGkwl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