diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-17 18:53:24 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-17 18:53:24 +0000 |
commit | 3d555ac96d8b23106a6eaf970c0382f84266bc4c (patch) | |
tree | 50bc234bdf2bfcf26fd98350e30697e6048bcec9 | |
parent | 3c1c9875b9749e4e644b7fd783993a1c74a006f9 (diff) | |
download | bcm5719-llvm-3d555ac96d8b23106a6eaf970c0382f84266bc4c.tar.gz bcm5719-llvm-3d555ac96d8b23106a6eaf970c0382f84266bc4c.zip |
ValueMapper: Don't allow explicit null mappings of Values, NFC
As a follow-up to r123058, assert that there are no null mappings in the
ValueMap instead of just ignoring them when they are there. There were
a couple of accidental insertions in CloneFunction so I cleaned those up
(caught by testcases).
llvm-svn: 266565
-rw-r--r-- | llvm/lib/Transforms/Utils/CloneFunction.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/ValueMapper.cpp | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Utils/CloneFunction.cpp b/llvm/lib/Transforms/Utils/CloneFunction.cpp index 41d340b3080..781238e7cc6 100644 --- a/llvm/lib/Transforms/Utils/CloneFunction.cpp +++ b/llvm/lib/Transforms/Utils/CloneFunction.cpp @@ -346,7 +346,7 @@ void PruningFunctionCloner::CloneBlock(const BasicBlock *BB, ConstantInt *Cond = dyn_cast<ConstantInt>(BI->getCondition()); // Or is a known constant in the caller... if (!Cond) { - Value *V = VMap[BI->getCondition()]; + Value *V = VMap.lookup(BI->getCondition()); Cond = dyn_cast_or_null<ConstantInt>(V); } @@ -449,7 +449,7 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc, // Defer PHI resolution until rest of function is resolved. SmallVector<const PHINode*, 16> PHIToResolve; for (const BasicBlock &BI : *OldFunc) { - Value *V = VMap[&BI]; + Value *V = VMap.lookup(&BI); BasicBlock *NewBB = cast_or_null<BasicBlock>(V); if (!NewBB) continue; // Dead block. diff --git a/llvm/lib/Transforms/Utils/ValueMapper.cpp b/llvm/lib/Transforms/Utils/ValueMapper.cpp index f8fa61329e2..84dcb42a749 100644 --- a/llvm/lib/Transforms/Utils/ValueMapper.cpp +++ b/llvm/lib/Transforms/Utils/ValueMapper.cpp @@ -341,8 +341,10 @@ Value *Mapper::mapValue(const Value *V) { ValueToValueMapTy::iterator I = getVM().find(V); // If the value already exists in the map, use it. - if (I != getVM().end() && I->second) + if (I != getVM().end()) { + assert(I->second && "Unexpected null mapping"); return I->second; + } // If we have a materializer and it can materialize a value, use that. if (auto *Materializer = getMaterializer()) { |