[PATCH] D17939: AMDGPU: Don't use InstVisitor for AMDGPUPromoteAlloca
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 7 13:33:48 PST 2016
arsenm created this revision.
arsenm added a reviewer: tstellarAMD.
arsenm added a subscriber: llvm-commits.
Herald added a subscriber: arsenm.
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.
http://reviews.llvm.org/D17939
Files:
lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
Index: lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
===================================================================
--- lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
+++ 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 @@
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 @@
return "AMDGPU Promote Alloca";
}
- void visitAlloca(AllocaInst &I);
+ void handleAlloca(AllocaInst &I);
};
} // End anonymous namespace
@@ -140,7 +139,14 @@
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 @@
return true;
}
-void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) {
+void AMDGPUPromoteAlloca::handleAlloca(AllocaInst &I) {
if (!I.isStaticAlloca())
return;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17939.49992.patch
Type: text/x-patch
Size: 1587 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160307/a151fc43/attachment.bin>
More information about the llvm-commits
mailing list