diff options
| author | Tobias Grosser <tobias@grosser.es> | 2015-10-03 17:19:49 +0000 |
|---|---|---|
| committer | Tobias Grosser <tobias@grosser.es> | 2015-10-03 17:19:49 +0000 |
| commit | e9cb5a0983d45d6484f2e10bdf803bcf71cdd7e4 (patch) | |
| tree | 94c77ce60c0b23defd53e657cb8ed45e66b88f88 /polly/lib/CodeGen/BlockGenerators.cpp | |
| parent | a38d76a08798b8419ee3cad64535e1241725064b (diff) | |
BlockGenerator: Use AssertingVH in maps
By using asserting value handles, we will get assertions when we forget to clear
any of the Value maps instead of difficult to debug undefined behavior.
llvm-svn: 249237
Diffstat (limited to 'polly/lib/CodeGen/BlockGenerators.cpp')
| -rw-r--r-- | polly/lib/CodeGen/BlockGenerators.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp index 5cec72c7652b..c282fa5928e8 100644 --- a/polly/lib/CodeGen/BlockGenerators.cpp +++ b/polly/lib/CodeGen/BlockGenerators.cpp @@ -362,18 +362,17 @@ void BlockGenerator::copyBB(ScopStmt &Stmt, BasicBlock *BB, BasicBlock *CopyBB, Value *BlockGenerator::getOrCreateAlloca(Value *ScalarBase, ScalarAllocaMapTy &Map, const char *NameExt) { - // Check if an alloca was cached for the base instruction. - Value *&Addr = Map[ScalarBase]; - // If no alloca was found create one and insert it in the entry block. - if (!Addr) { + if (!Map.count(ScalarBase)) { auto *Ty = ScalarBase->getType(); auto NewAddr = new AllocaInst(Ty, ScalarBase->getName() + NameExt); EntryBB = &Builder.GetInsertBlock()->getParent()->getEntryBlock(); NewAddr->insertBefore(EntryBB->getFirstInsertionPt()); - Addr = NewAddr; + Map[ScalarBase] = NewAddr; } + auto Addr = Map[ScalarBase]; + if (GlobalMap.count(Addr)) return GlobalMap[Addr]; |
