diff options
author | Florian Hahn <flo@fhahn.com> | 2019-03-28 20:02:33 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2019-03-28 20:02:33 +0000 |
commit | c0bfd37d385c93711ef3a349599dba20e6b101ef (patch) | |
tree | 253d53ae2851ef55b79938117500a429408f22fc /llvm/lib/Analysis/OrderedBasicBlock.cpp | |
parent | 43aaafc0e1fdd879e8939c60c7b24d9f77f6b5f8 (diff) | |
download | bcm5719-llvm-c0bfd37d385c93711ef3a349599dba20e6b101ef.tar.gz bcm5719-llvm-c0bfd37d385c93711ef3a349599dba20e6b101ef.zip |
[DSE] Preserve basic block ordering using OrderedBasicBlock.
By extending OrderedBB to allow removing and replacing cached
instructions, we can preserve OrderedBBs in DSE easily. This eliminates
one source of quadratic compile time in DSE.
Fixes PR38829.
Reviewers: rnk, efriedma, hfinkel
Reviewed By: efriedma
Differential Revision: https://reviews.llvm.org/D59789
llvm-svn: 357208
Diffstat (limited to 'llvm/lib/Analysis/OrderedBasicBlock.cpp')
-rw-r--r-- | llvm/lib/Analysis/OrderedBasicBlock.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/OrderedBasicBlock.cpp b/llvm/lib/Analysis/OrderedBasicBlock.cpp index 3cc6319028d..ad80a66fa4e 100644 --- a/llvm/lib/Analysis/OrderedBasicBlock.cpp +++ b/llvm/lib/Analysis/OrderedBasicBlock.cpp @@ -85,3 +85,26 @@ 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(); + 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); +} |