Usage of `DependenceAnalysis` pass

Hi everyone,
I’m developing my own transformation pass and want to use the results of the DependenceAnalysis pass (i.e. the DependenceInfo object for a given function F). I tried two different approaches.

First approach:
I tried to add the DependenceAnalysis pass to my ModulePassManager like so:


However, this results in an error, since DependenceAnalysis::run() returns a DependenceInfo object and not a PreservedAnalysis.

Second approach:
I tried running the DependenceAnalysis::run() method explicitly within my pass.

FunctionAnalysisManager &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
DependenceAnalysis depAnalysis;
llvm::DependenceInfo depInfo =, FAM);

When I run my pass I get the following error from opt:

opt: CommandLine Error: Option 'enable-fs-discriminator' registered more than once!

I’m not sure how to continue. Any help is appreciated!

Answering my question. Turns out I linked to LLVM twice (once to my library and once to my tests).
However, the way to use DependenceAnalysis is:

FunctionAnalysisManager &FAM = MAM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
DependencyInfo depInfo = FAM.getResult<DependenceAnalysis>(F);