summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMax Kazantsev <max.kazantsev@azul.com>2018-10-16 09:58:09 +0000
committerMax Kazantsev <max.kazantsev@azul.com>2018-10-16 09:58:09 +0000
commit5f9acd279e8fe9ebaa354e8b2294d6a85234c24f (patch)
tree64637ceafa5f069daf69b923f6831ac85c1915d5 /llvm/lib
parent7d27cfdcb28df8d8a6e9b06082af0f326f1e2f77 (diff)
downloadbcm5719-llvm-5f9acd279e8fe9ebaa354e8b2294d6a85234c24f.tar.gz
bcm5719-llvm-5f9acd279e8fe9ebaa354e8b2294d6a85234c24f.zip
[NFC] Introduce ICFLoopSafetyInfo
This is an alternative implementation of LoopSafetyInfo that uses the implicit control flow tracking to give precise answers on queries "whether or not this block contains throwing instructions". This rules out false-positive answers on LoopSafetyInfo's queries. This patch only introduces the new implementation. It is not currently used in any pass. The enabling patches will go separately, through review. The plan is to completely replace all uses of LoopSafetyInfo with ICFLoopSafetyInfo in the future, but to avoid introducing functional problems, we will do it pass by pass. llvm-svn: 344601
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/MustExecute.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/MustExecute.cpp b/llvm/lib/Analysis/MustExecute.cpp
index 4e42f336dc7..64ee2a7e5b0 100644
--- a/llvm/lib/Analysis/MustExecute.cpp
+++ b/llvm/lib/Analysis/MustExecute.cpp
@@ -61,6 +61,31 @@ void SimpleLoopSafetyInfo::computeLoopSafetyInfo(const Loop *CurLoop) {
computeBlockColors(CurLoop);
}
+bool ICFLoopSafetyInfo::blockMayThrow(const BasicBlock *BB) const {
+ return ICF.hasICF(BB);
+}
+
+bool ICFLoopSafetyInfo::anyBlockMayThrow() const {
+ return MayThrow;
+}
+
+void ICFLoopSafetyInfo::computeLoopSafetyInfo(const Loop *CurLoop) {
+ assert(CurLoop != nullptr && "CurLoop can't be null");
+ ICF.clear();
+ MayThrow = false;
+ // Figure out the fact that at least one block may throw.
+ for (auto &BB : CurLoop->blocks())
+ if (ICF.hasICF(&*BB)) {
+ MayThrow = true;
+ break;
+ }
+ computeBlockColors(CurLoop);
+}
+
+void ICFLoopSafetyInfo::dropCachedInfo(const BasicBlock *BB) {
+ ICF.invalidateBlock(BB);
+}
+
void LoopSafetyInfo::computeBlockColors(const Loop *CurLoop) {
// Compute funclet colors if we might sink/hoist in a function with a funclet
// personality routine.
@@ -215,6 +240,12 @@ bool SimpleLoopSafetyInfo::isGuaranteedToExecute(const Instruction &Inst,
return allLoopPathsLeadToBlock(CurLoop, Inst.getParent(), DT);
}
+bool ICFLoopSafetyInfo::isGuaranteedToExecute(const Instruction &Inst,
+ const DominatorTree *DT,
+ const Loop *CurLoop) const {
+ return !ICF.isDominatedByICFIFromSameBlock(&Inst) &&
+ allLoopPathsLeadToBlock(CurLoop, Inst.getParent(), DT);
+}
namespace {
struct MustExecutePrinter : public FunctionPass {
OpenPOWER on IntegriCloud