llvm.org GIT mirror llvm / 2b7d8c6
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_38@271591 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 3 years ago
3 changed file(s) with 35 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
6969 extern char &SILoadStoreOptimizerID;
7070
7171 // Passes common to R600 and SI
72 FunctionPass *createAMDGPUPromoteAlloca(const AMDGPUSubtarget &ST);
72 FunctionPass *createAMDGPUPromoteAlloca(const TargetMachine *TM = nullptr);
73 void initializeAMDGPUPromoteAllocaPass(PassRegistry&);
74 extern char &AMDGPUPromoteAllocaID;
75
7376 Pass *createAMDGPUStructurizeCFGPass();
7477 FunctionPass *createAMDGPUISelDag(TargetMachine &tm);
7578 ModulePass *createAMDGPUAlwaysInlinePass();
2626 namespace {
2727
2828 class AMDGPUPromoteAlloca : public FunctionPass,
29 public InstVisitor {
30
29 public InstVisitor {
30 private:
31 const TargetMachine *TM;
32 Module *Mod;
33 int LocalMemAvailable;
34
35 public:
3136 static char ID;
32 Module *Mod;
33 const AMDGPUSubtarget &ST;
34 int LocalMemAvailable;
35
36 public:
37 AMDGPUPromoteAlloca(const AMDGPUSubtarget &st) : FunctionPass(ID), ST(st),
38 LocalMemAvailable(0) { }
37
38 AMDGPUPromoteAlloca(const TargetMachine *TM_ = nullptr) :
39 FunctionPass(ID),
40 TM (TM_),
41 Mod(nullptr),
42 LocalMemAvailable(0) { }
43
3944 bool doInitialization(Module &M) override;
4045 bool runOnFunction(Function &F) override;
4146 const char *getPassName() const override { return "AMDGPU Promote Alloca"; }
4651
4752 char AMDGPUPromoteAlloca::ID = 0;
4853
54 INITIALIZE_TM_PASS(AMDGPUPromoteAlloca, DEBUG_TYPE,
55 "AMDGPU promote alloca to vector or LDS", false, false)
56
57 char &llvm::AMDGPUPromoteAllocaID = AMDGPUPromoteAlloca::ID;
58
4959 bool AMDGPUPromoteAlloca::doInitialization(Module &M) {
60 if (!TM)
61 return false;
62
5063 Mod = &M;
5164 return false;
5265 }
5366
5467 bool AMDGPUPromoteAlloca::runOnFunction(Function &F) {
68 if (!TM)
69 return false;
70
71 const AMDGPUSubtarget &ST = TM->getSubtarget(F);
5572
5673 FunctionType *FTy = F.getFunctionType();
5774
427444 }
428445 }
429446
430 FunctionPass *llvm::createAMDGPUPromoteAlloca(const AMDGPUSubtarget &ST) {
431 return new AMDGPUPromoteAlloca(ST);
432 }
447 FunctionPass *llvm::createAMDGPUPromoteAlloca(const TargetMachine *TM) {
448 return new AMDGPUPromoteAlloca(TM);
449 }
5151 initializeSILoadStoreOptimizerPass(*PR);
5252 initializeAMDGPUAnnotateKernelFeaturesPass(*PR);
5353 initializeAMDGPUAnnotateUniformValuesPass(*PR);
54 initializeAMDGPUPromoteAllocaPass(*PR);
5455 initializeSIAnnotateControlFlowPass(*PR);
5556 }
5657
227228 void AMDGPUPassConfig::addCodeGenPrepare() {
228229 const AMDGPUSubtarget &ST = *getAMDGPUTargetMachine().getSubtargetImpl();
229230 if (ST.isPromoteAllocaEnabled()) {
230 addPass(createAMDGPUPromoteAlloca(ST));
231 addPass(createAMDGPUPromoteAlloca(TM));
231232 addPass(createSROAPass());
232233 }
233234 TargetPassConfig::addCodeGenPrepare();