summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2019-09-23 22:23:01 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2019-09-23 22:23:01 +0000
commit082f895b1a9be3c08822a2f57730179a5c81c996 (patch)
tree8d04972e966c28cd8377acbc29db0f0612d6cdad
parent2eef85e24727999c628adc9b4bf919d67ae10a8f (diff)
downloadbcm5719-llvm-082f895b1a9be3c08822a2f57730179a5c81c996.tar.gz
bcm5719-llvm-082f895b1a9be3c08822a2f57730179a5c81c996.zip
HotColdSplitting: invalidate the AssumptionCache on split
When a cold path is outlined, the value tracking in the assumption cache may be invalidated due to the code motion. We would previously trip an assertion in subsequent passes (but required the passes to happen in a single run as the assumption cache is shared across the passes). Invalidating the cache ensures that we get the correct information when needed with the legacy pass manager as well. llvm-svn: 372667
-rw-r--r--llvm/lib/Transforms/IPO/HotColdSplitting.cpp5
-rw-r--r--llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll38
2 files changed, 43 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
index 79a5a9b80a9..49937a727fe 100644
--- a/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
+++ b/llvm/lib/Transforms/IPO/HotColdSplitting.cpp
@@ -659,6 +659,11 @@ bool HotColdSplitting::outlineColdRegions(Function &F, bool HasProfileSummary) {
} while (!Region.empty());
}
+ // We need to explicitly clear the assumption cache since the value tracking
+ // may now be invalid as part of the function has changed.
+ if (Changed)
+ if (AssumptionCache *AC = LookupAC(F))
+ AC->clear();
return Changed;
}
diff --git a/llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll b/llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll
new file mode 100644
index 00000000000..811b50783a5
--- /dev/null
+++ b/llvm/test/Transforms/HotColdSplit/assumption-cache-invalidation.ll
@@ -0,0 +1,38 @@
+; RUN: opt -instcombine -hotcoldsplit -instsimplify %s -o /dev/null
+
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64"
+
+%a = type { i64, i64 }
+%b = type { i64 }
+
+define void @f() {
+entry:
+ %0 = getelementptr inbounds %a, %a* null, i64 0, i32 1
+ br label %label
+
+label:
+ %1 = bitcast i64* %0 to %b**
+ %2 = load %b*, %b** %1, align 8
+ %3 = getelementptr inbounds %b, %b* %2, i64 undef, i32 0
+ %4 = load i64, i64* %3, align 8
+ %5 = icmp ugt i64 %4, 1
+ br i1 %5, label %if.then, label %if.else
+
+if.then:
+ unreachable
+
+if.else:
+ call void @g(i8* undef)
+ %6 = load i64, i64* undef, align 8
+ %7 = and i64 %6, -16
+ %8 = inttoptr i64 %7 to i8*
+ %9 = icmp eq i64 %4, 0
+ call void @llvm.assume(i1 %9)
+ unreachable
+}
+
+declare void @g(i8*)
+
+declare void @llvm.assume(i1)
+
OpenPOWER on IntegriCloud