diff --git a/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp index b5731e7781d..9de8ee888b9 100644 --- a/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp +++ b/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp @@ -16,7 +16,7 @@ #include "AMDGPUSubtarget.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/IRBuilder.h" -#include "llvm/IR/InstVisitor.h" +#include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/MDBuilder.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -28,8 +28,7 @@ using namespace llvm; namespace { // FIXME: This can create globals so should be a module pass. -class AMDGPUPromoteAlloca : public FunctionPass, - public InstVisitor { +class AMDGPUPromoteAlloca : public FunctionPass { private: const TargetMachine *TM; Module *Mod; @@ -63,7 +62,7 @@ public: return "AMDGPU Promote Alloca"; } - void visitAlloca(AllocaInst &I); + void handleAlloca(AllocaInst &I); }; } // End anonymous namespace @@ -140,7 +139,14 @@ bool AMDGPUPromoteAlloca::runOnFunction(Function &F) { LocalMemAvailable = std::max(0, LocalMemAvailable); DEBUG(dbgs() << LocalMemAvailable << " bytes free in local memory.\n"); - visit(F); + BasicBlock &EntryBB = *F.begin(); + for (auto I = EntryBB.begin(), E = EntryBB.end(); I != E; ) { + AllocaInst *AI = dyn_cast(I); + + ++I; + if (AI) + handleAlloca(*AI); + } return true; } @@ -461,7 +467,7 @@ static bool collectUsesWithPtrTypes(Value *Val, std::vector &WorkList) { return true; } -void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) { +void AMDGPUPromoteAlloca::handleAlloca(AllocaInst &I) { if (!I.isStaticAlloca()) return;