summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/OrderedBasicBlock.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2019-03-28 23:11:00 +0000
committerFlorian Hahn <flo@fhahn.com>2019-03-28 23:11:00 +0000
commit64cccfcc72c44ea62f441b782d2177a90912769a (patch)
tree853fb299474ba9cd0e6ed56cc321bb3922b0805a /llvm/lib/Analysis/OrderedBasicBlock.cpp
parent1dc28b6d2b89ed160038c14c9cc7aa7c29004c5c (diff)
downloadbcm5719-llvm-64cccfcc72c44ea62f441b782d2177a90912769a.tar.gz
bcm5719-llvm-64cccfcc72c44ea62f441b782d2177a90912769a.zip
Recommit "[DSE] Preserve basic block ordering using OrderedBasicBlock."
Recommitting after addressing a buildbot failure. This reverts commit c87869ebea000dd6483de7c7451cb36c1d36f866. llvm-svn: 357222
Diffstat (limited to 'llvm/lib/Analysis/OrderedBasicBlock.cpp')
-rw-r--r--llvm/lib/Analysis/OrderedBasicBlock.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/OrderedBasicBlock.cpp b/llvm/lib/Analysis/OrderedBasicBlock.cpp
index 3cc6319028d..401f818f12d 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[New] = OI->second;
+ if (LastInstFound != BB->end() && Old == &*LastInstFound)
+ LastInstFound = New->getIterator();
+ NumberedInsts.erase(Old);
+}
OpenPOWER on IntegriCloud