summaryrefslogtreecommitdiff
path: root/test/Transforms/InstCombine/early_dce_clobbers_callgraph.ll
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/InstCombine/early_dce_clobbers_callgraph.ll')
-rw-r--r--test/Transforms/InstCombine/early_dce_clobbers_callgraph.ll31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/early_dce_clobbers_callgraph.ll b/test/Transforms/InstCombine/early_dce_clobbers_callgraph.ll
new file mode 100644
index 0000000000000..743477621fa18
--- /dev/null
+++ b/test/Transforms/InstCombine/early_dce_clobbers_callgraph.ll
@@ -0,0 +1,31 @@
+; RUN: opt < %s -inline -instcombine -S | FileCheck %s
+
+; This test case exposed a bug in instcombine where the early
+; DCE of a call wasn't recognized as changing the IR.
+; So when runOnFunction propagated the "made changes" upwards
+; to the CallGraphSCCPass it signalled that no changes had been
+; made, so CallGraphSCCPass assumed that the old CallGraph,
+; as known by that pass manager, still was up-to-date.
+;
+; This was detected as an assert when trying to remove the
+; no longer used function 'bar' (due to incorrect reference
+; count in the CallGraph).
+
+attributes #0 = { noinline norecurse nounwind readnone }
+
+define void @foo() #0 {
+; CHECK-LABEL: @foo(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: ret void
+;
+entry:
+ %call = call i32 @bar()
+ ret void
+}
+
+define internal i32 @bar() #0 {
+; CHECK-NOT: bar
+entry:
+ ret i32 42
+}
+