[polly] r247970 - Store EscapeMap as Value* instead of AllocInst

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 17 23:01:11 PDT 2015


Author: grosser
Date: Fri Sep 18 01:01:11 2015
New Revision: 247970

URL: http://llvm.org/viewvc/llvm-project?rev=247970&view=rev
Log:
Store EscapeMap as Value* instead of AllocInst

This currently does not change the behavior in Polly, but it allows us to later
also overwrite the EscapeMap with our GlobalMap.

Modified:
    polly/trunk/include/polly/CodeGen/BlockGenerators.h
    polly/trunk/lib/CodeGen/BlockGenerators.cpp

Modified: polly/trunk/include/polly/CodeGen/BlockGenerators.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/CodeGen/BlockGenerators.h?rev=247970&r1=247969&r2=247970&view=diff
==============================================================================
--- polly/trunk/include/polly/CodeGen/BlockGenerators.h (original)
+++ polly/trunk/include/polly/CodeGen/BlockGenerators.h Fri Sep 18 01:01:11 2015
@@ -68,7 +68,7 @@ public:
   ///@{
 
   /// @see The ScalarMap and PHIOpMap member.
-  using ScalarAllocaMapTy = DenseMap<Value *, AllocaInst *>;
+  using ScalarAllocaMapTy = DenseMap<Value *, Value *>;
 
   /// @brief Simple vector of instructions to store escape users.
   using EscapeUserVectorTy = SmallVector<Instruction *, 4>;
@@ -77,7 +77,7 @@ public:
   ///
   /// @see The EscapeMap member.
   using EscapeUsersAllocaMapTy =
-      DenseMap<Instruction *, std::pair<AllocaInst *, EscapeUserVectorTy>>;
+      DenseMap<Instruction *, std::pair<Value *, EscapeUserVectorTy>>;
 
   ///@}
 
@@ -388,7 +388,7 @@ protected:
   ///                  SCoP.
   /// @param Address   If given it is used as the escape address for @p Inst.
   void handleOutsideUsers(const Region &R, Instruction *Inst, Value *InstCopy,
-                          AllocaInst *Address = nullptr);
+                          Value *Address = nullptr);
 
   /// @brief Initialize the memory of demoted scalars.
   ///

Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=247970&r1=247969&r2=247970&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Fri Sep 18 01:01:11 2015
@@ -333,14 +333,15 @@ Value *BlockGenerator::getOrCreateAlloca
                                          ScalarAllocaMapTy &Map,
                                          const char *NameExt) {
   // Check if an alloca was cached for the base instruction.
-  AllocaInst *&Addr = Map[ScalarBase];
+  Value *&Addr = Map[ScalarBase];
 
   // If no alloca was found create one and insert it in the entry block.
   if (!Addr) {
     auto *Ty = ScalarBase->getType();
-    Addr = new AllocaInst(Ty, ScalarBase->getName() + NameExt);
+    auto NewAddr = new AllocaInst(Ty, ScalarBase->getName() + NameExt);
     EntryBB = &Builder.GetInsertBlock()->getParent()->getEntryBlock();
-    Addr->insertBefore(EntryBB->getFirstInsertionPt());
+    NewAddr->insertBefore(EntryBB->getFirstInsertionPt());
+    Addr = NewAddr;
   }
 
   if (GlobalMap.count(Addr))
@@ -365,7 +366,7 @@ Value *BlockGenerator::getOrCreatePHIAll
 }
 
 void BlockGenerator::handleOutsideUsers(const Region &R, Instruction *Inst,
-                                        Value *InstCopy, AllocaInst *Address) {
+                                        Value *InstCopy, Value *Address) {
   // If there are escape users we get the alloca for this instruction and put it
   // in the EscapeMap for later finalization. Lastly, if the instruction was
   // copied multiple times we already did this and can exit.
@@ -391,8 +392,7 @@ void BlockGenerator::handleOutsideUsers(
     return;
 
   // Get or create an escape alloca for this instruction.
-  auto *ScalarAddr =
-      Address ? Address : cast<AllocaInst>(getOrCreateScalarAlloca(Inst));
+  auto *ScalarAddr = Address ? Address : getOrCreateScalarAlloca(Inst);
 
   // Remember that this instruction has escape uses and the escape alloca.
   EscapeMap[Inst] = std::make_pair(ScalarAddr, std::move(EscapeUsers));




More information about the llvm-commits mailing list