[llvm] r263206 - AMDGPU: Don't use InstVisitor for AMDGPUPromoteAlloca

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 00:20:51 PST 2016


Author: arsenm
Date: Fri Mar 11 02:20:50 2016
New Revision: 263206

URL: http://llvm.org/viewvc/llvm-project?rev=263206&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp

Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp?rev=263206&r1=263205&r2=263206&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp Fri Mar 11 02:20:50 2016
@@ -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(
   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(Valu
   return true;
 }
 
-void AMDGPUPromoteAlloca::visitAlloca(AllocaInst &I) {
+void AMDGPUPromoteAlloca::handleAlloca(AllocaInst &I) {
   if (!I.isStaticAlloca())
     return;
 




More information about the llvm-commits mailing list