summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2016-03-11 08:20:50 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2016-03-11 08:20:50 +0000
commitbafc9dc59104ec05876e46a49543c89d26f7e181 (patch)
tree29c0a54ec316bc6a42f4fc7080e0d8c3a4f8beac
parent91b4bd4b1261d22c3948caed959eccb03dc558ec (diff)
downloadbcm5719-llvm-bafc9dc59104ec05876e46a49543c89d26f7e181.tar.gz
bcm5719-llvm-bafc9dc59104ec05876e46a49543c89d26f7e181.zip
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. llvm-svn: 263206
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp b/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
index b5731e7781d..9de8ee888b9 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
+++ b/llvm/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<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;
OpenPOWER on IntegriCloud