Index: llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp =================================================================== --- llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp +++ llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp @@ -20,8 +20,6 @@ #include "AMDGPU.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/Analysis/InstructionSimplify.h" -#include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/IR/Dominators.h" @@ -47,19 +45,11 @@ 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) - : GetDT(GetDT), GetTLI(GetTLI) {} + AMDGPUPrintfRuntimeBindingImpl() {} bool run(Module &M); private: @@ -68,14 +58,7 @@ bool lowerPrintfForGpu(Module &M); - Value *simplify(Instruction *I, const TargetLibraryInfo *TLI, - const DominatorTree *DT) { - return simplifyInstruction(I, {*TD, TLI, DT}); - } - const DataLayout *TD; - function_ref GetDT; - function_ref GetTLI; SmallVector Printfs; }; } // namespace @@ -176,23 +159,6 @@ SmallString<16> OpConvSpecifiers; Value *Op = CI->getArgOperand(0); - if (auto LI = dyn_cast(Op)) { - Op = LI->getPointerOperand(); - for (auto *Use : Op->users()) { - if (auto SI = dyn_cast(Use)) { - Op = SI->getValueOperand(); - break; - } - } - } - - if (auto I = dyn_cast(Op)) { - Value *Op_simplified = - simplify(I, &GetTLI(*I->getFunction()), &GetDT(*I->getFunction())); - if (Op_simplified) - Op = Op_simplified; - } - StringRef FormatStr; if (!getConstantStringInfo(Op, FormatStr)) { Value *Stripped = Op->stripPointerCasts(); @@ -487,26 +453,11 @@ } bool AMDGPUPrintfRuntimeBinding::runOnModule(Module &M) { - auto GetDT = [this](Function &F) -> DominatorTree & { - return this->getAnalysis(F).getDomTree(); - }; - auto GetTLI = [this](Function &F) -> TargetLibraryInfo & { - return this->getAnalysis().getTLI(F); - }; - - return AMDGPUPrintfRuntimeBindingImpl(GetDT, GetTLI).run(M); + return AMDGPUPrintfRuntimeBindingImpl().run(M); } PreservedAnalyses AMDGPUPrintfRuntimeBindingPass::run(Module &M, ModuleAnalysisManager &AM) { - FunctionAnalysisManager &FAM = - AM.getResult(M).getManager(); - auto GetDT = [&FAM](Function &F) -> DominatorTree & { - return FAM.getResult(F); - }; - auto GetTLI = [&FAM](Function &F) -> TargetLibraryInfo & { - return FAM.getResult(F); - }; - bool Changed = AMDGPUPrintfRuntimeBindingImpl(GetDT, GetTLI).run(M); + bool Changed = AMDGPUPrintfRuntimeBindingImpl().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 @@ -143,9 +141,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 @@ -169,8 +164,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 @@ -414,9 +407,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 @@ -440,8 +430,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 @@ -707,9 +695,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 @@ -733,8 +718,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 @@ -1010,9 +993,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 @@ -1036,8 +1016,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 @@ -1325,9 +1303,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