diff options
author | Florian Hahn <flo@fhahn.com> | 2019-03-29 14:10:24 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2019-03-29 14:10:24 +0000 |
commit | 9b41a7320dc6aee2008273ad5198c90444c6d5bd (patch) | |
tree | dd9a4499d926f8bc0f408baac643ad1732051993 /llvm/lib/Analysis/OrderedBasicBlock.cpp | |
parent | 9259de217e608ae965d12531e06e10805072a212 (diff) | |
download | bcm5719-llvm-9b41a7320dc6aee2008273ad5198c90444c6d5bd.tar.gz bcm5719-llvm-9b41a7320dc6aee2008273ad5198c90444c6d5bd.zip |
Recommit "[DSE] Preserve basic block ordering using OrderedBasicBlock."
Updated to use DenseMap::insert instead of [] operator for insertion, to
avoid a crash caused by epoch checks.
This reverts commit 2b85de438326f9d27bc96dc934ec98b98abdb337.
llvm-svn: 357257
Diffstat (limited to 'llvm/lib/Analysis/OrderedBasicBlock.cpp')
-rw-r--r-- | llvm/lib/Analysis/OrderedBasicBlock.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/OrderedBasicBlock.cpp b/llvm/lib/Analysis/OrderedBasicBlock.cpp index 3cc6319028d..48f2a4020c6 100644 --- a/llvm/lib/Analysis/OrderedBasicBlock.cpp +++ b/llvm/lib/Analysis/OrderedBasicBlock.cpp @@ -85,3 +85,27 @@ bool OrderedBasicBlock::dominates(const Instruction *A, const Instruction *B) { return comesBefore(A, B); } + +void OrderedBasicBlock::eraseInstruction(const Instruction *I) { + if (LastInstFound != BB->end() && I == &*LastInstFound) { + if (LastInstFound == BB->begin()) { + LastInstFound = BB->end(); + NextInstPos = 0; + } else + LastInstFound--; + } + + NumberedInsts.erase(I); +} + +void OrderedBasicBlock::replaceInstruction(const Instruction *Old, + const Instruction *New) { + auto OI = NumberedInsts.find(Old); + if (OI == NumberedInsts.end()) + return; + + NumberedInsts.insert({New, OI->second}); + if (LastInstFound != BB->end() && Old == &*LastInstFound) + LastInstFound = New->getIterator(); + NumberedInsts.erase(Old); +} |