AMDGPU: Don't use InstVisitor for AMDGPUPromoteAlloca

Frontend authors are strongly encouraged to keep allocas
in the entry block, so don't bother visiting every instruction
in the other blocks of the function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@263206 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Matt Arsenault 2016-03-11 08:20:50 +00:00
parent 7137d0dce6
commit 6da276af59

View File

@ -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<AMDGPUPromoteAlloca> {
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<AllocaInst>(I);
++I;
if (AI)
handleAlloca(*AI);
}
return true;
}
@ -461,7 +467,7 @@ static bool collectUsesWithPtrTypes(Value *Val, std::vector<Value*> &WorkList) {
return true;
}
void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) {
void AMDGPUPromoteAlloca::handleAlloca(AllocaInst &I) {
if (!I.isStaticAlloca())
return;