[llvm-dev] On-the-fly passes

David Greene via llvm-dev llvm-dev at lists.llvm.org
Tue Mar 26 13:26:33 PDT 2019


I'm seeing some very unexpected behavior in a ModulePass I've created.
To support both the legacy and new pass managers, I've abstracted away
the code to get the passes it depends on:

bool MyPass::runOnModule(Module &M) override {
  auto DominatorGetter = [this] (Function &F) -> DominatorTree & {
    return this->getAnalysis<DominatorTreeWrapperPass>(F).getDomTree();
  };

      auto PostDominatorGetter = [this] (Function &F) -> PostDominatorTree & {
        return this->
        getAnalysis<PostDominatorTreeWrapperPass>(F).getPostDomTree();
      };

      auto LoopInfoGetter = [this] (Function &F) -> LoopInfo & {
        return this->getAnalysis<LoopInfoWrapperPass>(F).getLoopInfo();
      };

      auto SCEVGetter = [this] (Function &F) -> ScalarEvolution & {
        return this->getAnalysis<ScalarEvolutionWrapperPass>(F).getSE();
      };

      auto AssumptionCacheGetter = [this] (Function &F) ->
        AssumptionCache & {
        return
        this->getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
      };

      auto OREGetter = [this] (Function &F) -> OptimizationRemarkEmitter & {
        return this->
        getAnalysis<OptimizationRemarkEmitterWrapperPass>(F).getORE();
      };
}


More information about the llvm-dev mailing list