Index: llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp @@ -47,18 +47,13 @@ private: bool runOnModule(Module &M) override; - - void getAnalysisUsage(AnalysisUsage &AU) const override { - AU.addRequired(); - AU.addRequired(); - } }; class AMDGPUPrintfRuntimeBindingImpl { public: AMDGPUPrintfRuntimeBindingImpl( - function_ref GetDT, - function_ref GetTLI) + function_ref GetDT, + function_ref GetTLI) : GetDT(GetDT), GetTLI(GetTLI) {} bool run(Module &M); @@ -74,8 +69,8 @@ } const DataLayout *TD; - function_ref GetDT; - function_ref GetTLI; + function_ref GetDT; + function_ref GetTLI; SmallVector Printfs; }; } // namespace @@ -188,7 +183,7 @@ if (auto I = dyn_cast(Op)) { Value *Op_simplified = - simplify(I, &GetTLI(*I->getFunction()), &GetDT(*I->getFunction())); + simplify(I, GetTLI(*I->getFunction()), GetDT(*I->getFunction())); if (Op_simplified) Op = Op_simplified; } @@ -487,11 +482,16 @@ } bool AMDGPUPrintfRuntimeBinding::runOnModule(Module &M) { - auto GetDT = [this](Function &F) -> DominatorTree & { - return this->getAnalysis(F).getDomTree(); + auto GetDT = [this](Function &F) -> DominatorTree * { + if (auto *DTWP = getAnalysisIfAvailable()) + return &DTWP->getDomTree(); + return nullptr; }; - auto GetTLI = [this](Function &F) -> TargetLibraryInfo & { - return this->getAnalysis().getTLI(F); + auto GetTLI = [this](Function &F) -> TargetLibraryInfo * { + if (auto *TLIW = + this->getAnalysisIfAvailable()) + return &TLIW->getTLI(F); + return nullptr; }; return AMDGPUPrintfRuntimeBindingImpl(GetDT, GetTLI).run(M); @@ -501,11 +501,11 @@ AMDGPUPrintfRuntimeBindingPass::run(Module &M, ModuleAnalysisManager &AM) { FunctionAnalysisManager &FAM = AM.getResult(M).getManager(); - auto GetDT = [&FAM](Function &F) -> DominatorTree & { - return FAM.getResult(F); + auto GetDT = [&FAM](Function &F) -> DominatorTree * { + return FAM.getCachedResult(F); }; - auto GetTLI = [&FAM](Function &F) -> TargetLibraryInfo & { - return FAM.getResult(F); + auto GetTLI = [&FAM](Function &F) -> TargetLibraryInfo * { + return FAM.getCachedResult(F); }; bool Changed = AMDGPUPrintfRuntimeBindingImpl(GetDT, GetTLI).run(M); return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all(); Index: llvm/test/CodeGen/AMDGPU/llc-pipeline.ll =================================================================== --- llvm/test/CodeGen/AMDGPU/llc-pipeline.ll +++ llvm/test/CodeGen/AMDGPU/llc-pipeline.ll @@ -29,8 +29,6 @@ ; GCN-O0-NEXT: Expand large div/rem ; GCN-O0-NEXT: Expand large fp convert ; GCN-O0-NEXT: AMDGPU Printf lowering -; GCN-O0-NEXT: FunctionPass Manager -; GCN-O0-NEXT: Dominator Tree Construction ; GCN-O0-NEXT: Lower ctors and dtors for AMDGPU ; GCN-O0-NEXT: Lower OpenCL enqueued blocks ; GCN-O0-NEXT: Lower uses of LDS variables from non-kernel functions @@ -142,9 +140,6 @@ ; GCN-O0-NEXT: Machine Optimization Remark Emitter ; GCN-O0-NEXT: AMDGPU Assembly Printer ; GCN-O0-NEXT: Free MachineFunction -; GCN-O0-NEXT:Pass Arguments: -domtree -; GCN-O0-NEXT: FunctionPass Manager -; GCN-O0-NEXT: Dominator Tree Construction ; GCN-O1:Target Library Information ; GCN-O1-NEXT:Target Pass Configuration @@ -168,8 +163,6 @@ ; GCN-O1-NEXT: Expand large div/rem ; GCN-O1-NEXT: Expand large fp convert ; GCN-O1-NEXT: AMDGPU Printf lowering -; GCN-O1-NEXT: FunctionPass Manager -; GCN-O1-NEXT: Dominator Tree Construction ; GCN-O1-NEXT: Lower ctors and dtors for AMDGPU ; GCN-O1-NEXT: Lower OpenCL enqueued blocks ; GCN-O1-NEXT: Lower uses of LDS variables from non-kernel functions @@ -412,9 +405,6 @@ ; GCN-O1-NEXT: Machine Optimization Remark Emitter ; GCN-O1-NEXT: AMDGPU Assembly Printer ; GCN-O1-NEXT: Free MachineFunction -; GCN-O1-NEXT:Pass Arguments: -domtree -; GCN-O1-NEXT: FunctionPass Manager -; GCN-O1-NEXT: Dominator Tree Construction ; GCN-O1-OPTS:Target Library Information ; GCN-O1-OPTS-NEXT:Target Pass Configuration @@ -438,8 +428,6 @@ ; GCN-O1-OPTS-NEXT: Expand large div/rem ; GCN-O1-OPTS-NEXT: Expand large fp convert ; GCN-O1-OPTS-NEXT: AMDGPU Printf lowering -; GCN-O1-OPTS-NEXT: FunctionPass Manager -; GCN-O1-OPTS-NEXT: Dominator Tree Construction ; GCN-O1-OPTS-NEXT: Lower ctors and dtors for AMDGPU ; GCN-O1-OPTS-NEXT: Lower OpenCL enqueued blocks ; GCN-O1-OPTS-NEXT: Lower uses of LDS variables from non-kernel functions @@ -704,9 +692,6 @@ ; GCN-O1-OPTS-NEXT: Machine Optimization Remark Emitter ; GCN-O1-OPTS-NEXT: AMDGPU Assembly Printer ; GCN-O1-OPTS-NEXT: Free MachineFunction -; GCN-O1-OPTS-NEXT:Pass Arguments: -domtree -; GCN-O1-OPTS-NEXT: FunctionPass Manager -; GCN-O1-OPTS-NEXT: Dominator Tree Construction ; GCN-O2:Target Library Information ; GCN-O2-NEXT:Target Pass Configuration @@ -730,8 +715,6 @@ ; GCN-O2-NEXT: Expand large div/rem ; GCN-O2-NEXT: Expand large fp convert ; GCN-O2-NEXT: AMDGPU Printf lowering -; GCN-O2-NEXT: FunctionPass Manager -; GCN-O2-NEXT: Dominator Tree Construction ; GCN-O2-NEXT: Lower ctors and dtors for AMDGPU ; GCN-O2-NEXT: Lower OpenCL enqueued blocks ; GCN-O2-NEXT: Lower uses of LDS variables from non-kernel functions @@ -1006,9 +989,6 @@ ; GCN-O2-NEXT: Machine Optimization Remark Emitter ; GCN-O2-NEXT: AMDGPU Assembly Printer ; GCN-O2-NEXT: Free MachineFunction -; GCN-O2-NEXT:Pass Arguments: -domtree -; GCN-O2-NEXT: FunctionPass Manager -; GCN-O2-NEXT: Dominator Tree Construction ; GCN-O3:Target Library Information ; GCN-O3-NEXT:Target Pass Configuration @@ -1032,8 +1012,6 @@ ; GCN-O3-NEXT: Expand large div/rem ; GCN-O3-NEXT: Expand large fp convert ; GCN-O3-NEXT: AMDGPU Printf lowering -; GCN-O3-NEXT: FunctionPass Manager -; GCN-O3-NEXT: Dominator Tree Construction ; GCN-O3-NEXT: Lower ctors and dtors for AMDGPU ; GCN-O3-NEXT: Lower OpenCL enqueued blocks ; GCN-O3-NEXT: Lower uses of LDS variables from non-kernel functions @@ -1320,9 +1298,6 @@ ; GCN-O3-NEXT: Machine Optimization Remark Emitter ; GCN-O3-NEXT: AMDGPU Assembly Printer ; GCN-O3-NEXT: Free MachineFunction -; GCN-O3-NEXT:Pass Arguments: -domtree -; GCN-O3-NEXT: FunctionPass Manager -; GCN-O3-NEXT: Dominator Tree Construction define void @empty() { ret void