Make the mem2reg interface use an ArrayRef as it keeps a copy of these
authorChandler Carruth <chandlerc@gmail.com>
Sun, 21 Jul 2013 08:37:58 +0000 (08:37 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sun, 21 Jul 2013 08:37:58 +0000 (08:37 +0000)
to iterate over.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186788 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Transforms/Utils/PromoteMemToReg.h
lib/Transforms/Utils/PromoteMemoryToRegister.cpp

index fde4b81d7f1f2e496e483244d5b9333794f5461e..22f46e5fc963c55b822a77ec5040272f9820fb26 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef LLVM_TRANSFORMS_UTILS_PROMOTEMEMTOREG_H
 #define LLVM_TRANSFORMS_UTILS_PROMOTEMEMTOREG_H
 
-#include <vector>
+#include "llvm/ADT/ArrayRef.h"
 
 namespace llvm {
 
@@ -40,8 +40,8 @@ bool isAllocaPromotable(const AllocaInst *AI);
 ///
 /// If AST is specified, the specified tracker is updated to reflect changes
 /// made to the IR.
-void PromoteMemToReg(const std::vector<AllocaInst*> &Allocas,
-                     DominatorTree &DT, AliasSetTracker *AST = 0);
+void PromoteMemToReg(ArrayRef<AllocaInst *> Allocas, DominatorTree &DT,
+                     AliasSetTracker *AST = 0);
 
 } // End llvm namespace
 
index 5ee812bbe888bc6fb86073a200107fa713f55c4a..b4ee4cb87fddeb023ab50b05173c7d369e5c187a 100644 (file)
@@ -27,6 +27,7 @@
 
 #define DEBUG_TYPE "mem2reg"
 #include "llvm/Transforms/Utils/PromoteMemToReg.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/STLExtras.h"
@@ -279,10 +280,10 @@ struct PromoteMem2Reg {
   DenseMap<const BasicBlock *, unsigned> BBNumPreds;
 
 public:
-  PromoteMem2Reg(const std::vector<AllocaInst *> &Allocas, DominatorTree &DT,
+  PromoteMem2Reg(ArrayRef<AllocaInst *> Allocas, DominatorTree &DT,
                  AliasSetTracker *AST)
-      : Allocas(Allocas), DT(DT), DIB(*DT.getRoot()->getParent()->getParent()),
-        AST(AST) {}
+      : Allocas(Allocas.begin(), Allocas.end()), DT(DT),
+        DIB(*DT.getRoot()->getParent()->getParent()), AST(AST) {}
 
   void run();
 
@@ -1089,8 +1090,8 @@ NextIteration:
   goto NextIteration;
 }
 
-void llvm::PromoteMemToReg(const std::vector<AllocaInst *> &Allocas,
-                           DominatorTree &DT, AliasSetTracker *AST) {
+void llvm::PromoteMemToReg(ArrayRef<AllocaInst *> Allocas, DominatorTree &DT,
+                           AliasSetTracker *AST) {
   // If there is nothing to do, bail out...
   if (Allocas.empty())
     return;