From b09455dee0426cb16c8185fc3e58795c2b1b69ae Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Fri, 18 Sep 2015 06:01:11 +0000 Subject: [PATCH] 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. llvm-svn: 247970 --- polly/include/polly/CodeGen/BlockGenerators.h | 6 +++--- polly/lib/CodeGen/BlockGenerators.cpp | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/polly/include/polly/CodeGen/BlockGenerators.h b/polly/include/polly/CodeGen/BlockGenerators.h index 7ec5060d2382..ee961e731d83 100644 --- a/polly/include/polly/CodeGen/BlockGenerators.h +++ b/polly/include/polly/CodeGen/BlockGenerators.h @@ -68,7 +68,7 @@ public: ///@{ /// @see The ScalarMap and PHIOpMap member. - using ScalarAllocaMapTy = DenseMap; + using ScalarAllocaMapTy = DenseMap; /// @brief Simple vector of instructions to store escape users. using EscapeUserVectorTy = SmallVector; @@ -77,7 +77,7 @@ public: /// /// @see The EscapeMap member. using EscapeUsersAllocaMapTy = - DenseMap>; + DenseMap>; ///@} @@ -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. /// diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index d7788c11ea7c..b0212cd12546 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -333,14 +333,15 @@ Value *BlockGenerator::getOrCreateAlloca(Value *ScalarBase, 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::getOrCreatePHIAlloca(Value *ScalarBase) { } 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(const Region &R, Instruction *Inst, return; // Get or create an escape alloca for this instruction. - auto *ScalarAddr = - Address ? Address : cast(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));