For my own LLVM pass I need the results of the llvm::DependenceAnalysis() pass. I.e. I want the DependenceInfo object for some module/function.
I tried several approaches to get the pass to run the pass, however none worked so far.
Any hints on how to use DependenceAnalysis are welcome!
First approach:
I tried calling the DependenceAnalysis().run() function directly inside the run() function of my own pass.
// MAM is the ModuleAnalysisManager that is an argument to the run() function of my pass
FunctionAnalysisManager &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
DependenceAnalysis depAnalysis;
llvm::DependenceInfo depInfo = depAnalysis.run(F, FAM);
When I run my pass I get an error from opt:
opt: CommandLine Error: Option 'enable-fs-discriminator' registered more than once!
I am not able to find the origin of this error message.
Second approach:
I added the DependenceAnalysis() pass directly to the ModulePassManager, to which I also add my own pass.
MPM.addPass(createModuleToFunctionPassAdaptor((DependenceAnalysis())))
This results in a compile erorr, since DependenceAnalysis.run() does not return a PreservedAnalysis object but a DependenceInfo object.
I found that the problem was not only how I used the
DependenceAnalysisbut also some problems due to my linking of LLVM.Getting the results of
DependenceAnalysisis done by:Thanks to @arnt for pointing to the linking problem. Turns out I linked LLVM twice in
CMake.