diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2016-06-02 21:01:43 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2016-06-02 21:01:43 +0000 |
commit | e87dd1eda4bd3d6b42774cd1991ecd2a680ad213 (patch) | |
tree | bc7ad278509bc10a7cbe584ebb7c924cbab3c12d | |
parent | 20cbe932084081980cc1a36f03c3ab76730aaf79 (diff) | |
download | llvm-e87dd1eda4bd3d6b42774cd1991ecd2a680ad213.zip llvm-e87dd1eda4bd3d6b42774cd1991ecd2a680ad213.tar.gz llvm-e87dd1eda4bd3d6b42774cd1991ecd2a680ad213.tar.bz2 |
Merging part of r259297:
We need to correctly initialize the AMDGPUPromoteAlloca pass, because
later commits will add tests that try to pass the -amdgpu-promote-alloca
flag to opt.
llvm-svn: 271591
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPU.h | 5 | ||||
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp | 33 | ||||
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 3 |
3 files changed, 31 insertions, 10 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h index a6f49e8..0cff462 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPU.h +++ b/llvm/lib/Target/AMDGPU/AMDGPU.h @@ -70,7 +70,10 @@ void initializeSILoadStoreOptimizerPass(PassRegistry &); extern char &SILoadStoreOptimizerID; // Passes common to R600 and SI -FunctionPass *createAMDGPUPromoteAlloca(const AMDGPUSubtarget &ST); +FunctionPass *createAMDGPUPromoteAlloca(const TargetMachine *TM = nullptr); +void initializeAMDGPUPromoteAllocaPass(PassRegistry&); +extern char &AMDGPUPromoteAllocaID; + Pass *createAMDGPUStructurizeCFGPass(); FunctionPass *createAMDGPUISelDag(TargetMachine &tm); ModulePass *createAMDGPUAlwaysInlinePass(); diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp index ce2a452..8529342 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp @@ -27,16 +27,21 @@ using namespace llvm; namespace { class AMDGPUPromoteAlloca : public FunctionPass, - public InstVisitor<AMDGPUPromoteAlloca> { - - static char ID; + public InstVisitor<AMDGPUPromoteAlloca> { +private: + const TargetMachine *TM; Module *Mod; - const AMDGPUSubtarget &ST; int LocalMemAvailable; public: - AMDGPUPromoteAlloca(const AMDGPUSubtarget &st) : FunctionPass(ID), ST(st), - LocalMemAvailable(0) { } + static char ID; + + AMDGPUPromoteAlloca(const TargetMachine *TM_ = nullptr) : + FunctionPass(ID), + TM (TM_), + Mod(nullptr), + LocalMemAvailable(0) { } + bool doInitialization(Module &M) override; bool runOnFunction(Function &F) override; const char *getPassName() const override { return "AMDGPU Promote Alloca"; } @@ -47,12 +52,24 @@ public: char AMDGPUPromoteAlloca::ID = 0; +INITIALIZE_TM_PASS(AMDGPUPromoteAlloca, DEBUG_TYPE, + "AMDGPU promote alloca to vector or LDS", false, false) + +char &llvm::AMDGPUPromoteAllocaID = AMDGPUPromoteAlloca::ID; + bool AMDGPUPromoteAlloca::doInitialization(Module &M) { + if (!TM) + return false; + Mod = &M; return false; } bool AMDGPUPromoteAlloca::runOnFunction(Function &F) { + if (!TM) + return false; + + const AMDGPUSubtarget &ST = TM->getSubtarget<AMDGPUSubtarget>(F); FunctionType *FTy = F.getFunctionType(); @@ -428,6 +445,6 @@ void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) { } } -FunctionPass *llvm::createAMDGPUPromoteAlloca(const AMDGPUSubtarget &ST) { - return new AMDGPUPromoteAlloca(ST); +FunctionPass *llvm::createAMDGPUPromoteAlloca(const TargetMachine *TM) { + return new AMDGPUPromoteAlloca(TM); } diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index 5a91be4..7b4fbea 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -52,6 +52,7 @@ extern "C" void LLVMInitializeAMDGPUTarget() { initializeSILoadStoreOptimizerPass(*PR); initializeAMDGPUAnnotateKernelFeaturesPass(*PR); initializeAMDGPUAnnotateUniformValuesPass(*PR); + initializeAMDGPUPromoteAllocaPass(*PR); initializeSIAnnotateControlFlowPass(*PR); } @@ -228,7 +229,7 @@ void AMDGPUPassConfig::addIRPasses() { void AMDGPUPassConfig::addCodeGenPrepare() { const AMDGPUSubtarget &ST = *getAMDGPUTargetMachine().getSubtargetImpl(); if (ST.isPromoteAllocaEnabled()) { - addPass(createAMDGPUPromoteAlloca(ST)); + addPass(createAMDGPUPromoteAlloca(TM)); addPass(createSROAPass()); } TargetPassConfig::addCodeGenPrepare(); |