[llvm] 94e2462 - AMDGPU: Remove attempt at simplifying the format string in printf lowering
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 7 06:26:12 PDT 2023
Author: Matt Arsenault
Date: 2023-07-07T09:26:07-04:00
New Revision: 94e24624c2f5b7ebdfd8be898986f943c9462b7f
URL: https://github.com/llvm/llvm-project/commit/94e24624c2f5b7ebdfd8be898986f943c9462b7f
DIFF: https://github.com/llvm/llvm-project/commit/94e24624c2f5b7ebdfd8be898986f943c9462b7f.diff
LOG: AMDGPU: Remove attempt at simplifying the format string in printf lowering
This avoids computing the dominator tree by removing the
simplifyInstruction use.
This was applying simplification with some kind of questionable
load-store forwarding and looking for the global. This had to have
been an ancient hack copied from previous backends. In the OpenCL
case, this is always emitted as required the direct global reference
anyway.
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
index 3dcb54657410f7..13f83e298cf4e2 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
+++ b/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 @@ class AMDGPUPrintfRuntimeBinding final : public ModulePass {
private:
bool runOnModule(Module &M) override;
-
- void getAnalysisUsage(AnalysisUsage &AU) const override {
- AU.addRequired<TargetLibraryInfoWrapperPass>();
- AU.addRequired<DominatorTreeWrapperPass>();
- }
};
class AMDGPUPrintfRuntimeBindingImpl {
public:
- AMDGPUPrintfRuntimeBindingImpl(
- function_ref<const DominatorTree &(Function &)> GetDT,
- function_ref<const TargetLibraryInfo &(Function &)> GetTLI)
- : GetDT(GetDT), GetTLI(GetTLI) {}
+ AMDGPUPrintfRuntimeBindingImpl() {}
bool run(Module &M);
private:
@@ -68,14 +58,7 @@ class AMDGPUPrintfRuntimeBindingImpl {
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<const DominatorTree &(Function &)> GetDT;
- function_ref<const TargetLibraryInfo &(Function &)> GetTLI;
SmallVector<CallInst *, 32> Printfs;
};
} // namespace
@@ -176,23 +159,6 @@ bool AMDGPUPrintfRuntimeBindingImpl::lowerPrintfForGpu(Module &M) {
SmallString<16> OpConvSpecifiers;
Value *Op = CI->getArgOperand(0);
- if (auto LI = dyn_cast<LoadInst>(Op)) {
- Op = LI->getPointerOperand();
- for (auto *Use : Op->users()) {
- if (auto SI = dyn_cast<StoreInst>(Use)) {
- Op = SI->getValueOperand();
- break;
- }
- }
- }
-
- if (auto I = dyn_cast<Instruction>(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 AMDGPUPrintfRuntimeBindingImpl::run(Module &M) {
}
bool AMDGPUPrintfRuntimeBinding::runOnModule(Module &M) {
- auto GetDT = [this](Function &F) -> DominatorTree & {
- return this->getAnalysis<DominatorTreeWrapperPass>(F).getDomTree();
- };
- auto GetTLI = [this](Function &F) -> TargetLibraryInfo & {
- return this->getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
- };
-
- return AMDGPUPrintfRuntimeBindingImpl(GetDT, GetTLI).run(M);
+ return AMDGPUPrintfRuntimeBindingImpl().run(M);
}
PreservedAnalyses
AMDGPUPrintfRuntimeBindingPass::run(Module &M, ModuleAnalysisManager &AM) {
- FunctionAnalysisManager &FAM =
- AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
- auto GetDT = [&FAM](Function &F) -> DominatorTree & {
- return FAM.getResult<DominatorTreeAnalysis>(F);
- };
- auto GetTLI = [&FAM](Function &F) -> TargetLibraryInfo & {
- return FAM.getResult<TargetLibraryAnalysis>(F);
- };
- bool Changed = AMDGPUPrintfRuntimeBindingImpl(GetDT, GetTLI).run(M);
+ bool Changed = AMDGPUPrintfRuntimeBindingImpl().run(M);
return Changed ? PreservedAnalyses::none() : PreservedAnalyses::all();
}
diff --git a/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll b/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
index 9eb52e40f683f6..63821c01e5b3c5 100644
--- a/llvm/test/CodeGen/AMDGPU/llc-pipeline.ll
+++ b/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: AMDGPU Inline All Functions
; GCN-O0-NEXT: Inliner for always_inline functions
@@ -149,9 +147,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
@@ -175,8 +170,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: AMDGPU Inline All Functions
; GCN-O1-NEXT: Inliner for always_inline functions
@@ -425,9 +418,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
@@ -451,8 +441,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: AMDGPU Inline All Functions
; GCN-O1-OPTS-NEXT: Inliner for always_inline functions
@@ -723,9 +711,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
@@ -749,8 +734,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: AMDGPU Inline All Functions
; GCN-O2-NEXT: Inliner for always_inline functions
@@ -1031,9 +1014,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
@@ -1057,8 +1037,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: AMDGPU Inline All Functions
; GCN-O3-NEXT: Inliner for always_inline functions
@@ -1351,9 +1329,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
More information about the llvm-commits
mailing list