Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 0e9c66d

Browse files
dccialexcrichton
authored andcommitted
[JumpThreading] Stop falsely preserving LazyValueInfo.
JumpThreading claims to preserve LVI, but it doesn't preserve the analyses which LVI holds a reference to (e.g. the Dominator). In the current pass manager infrastructure, after JT runs, the PM frees these analyses (including DominatorTree) but preserves LVI. CorrelatedValuePropagation runs immediately after and queries a corrupted domtree, causing weird miscompiles. This commit disables the preservation of LVI for the time being. Eventually, we should either move LVI to a proper dependency tracking mechanism (i.e. an analyses shouldn't hold references to other analyses and compute them on demand if needed), or we should teach all the passes preserving LVI to preserve the analyses LVI depends on. The new pass manager has a mechanism to invalidate LVI in case one of the analyses it depends on becomes invalid, so this problem shouldn't exist (at least not in this immediate form), but handling of analyses holding references is still a very delicate subject. Fixes PR33917 (and rustc). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309355 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent c7dfa21 commit 0e9c66d

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

lib/Transforms/Scalar/JumpThreading.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ namespace {
102102
AU.addRequired<DominatorTreeWrapperPass>();
103103
AU.addRequired<AAResultsWrapperPass>();
104104
AU.addRequired<LazyValueInfoWrapperPass>();
105-
AU.addPreserved<LazyValueInfoWrapperPass>();
106105
AU.addPreserved<GlobalsAAWrapperPass>();
107106
AU.addRequired<TargetLibraryInfoWrapperPass>();
108107
}
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -jump-threading -correlated-propagation %s -S | FileCheck %s
3+
4+
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5+
target triple = "x86_64-unknown-linux-gnu"
6+
7+
declare i8* @foo()
8+
9+
declare i32 @rust_eh_personality() unnamed_addr
10+
11+
; Function Attrs: nounwind
12+
declare void @llvm.assume(i1) #0
13+
14+
define void @patatino() personality i32 ()* @rust_eh_personality {
15+
; CHECK-LABEL: @patatino(
16+
; CHECK-NEXT: bb9:
17+
; CHECK-NEXT: [[T9:%.*]] = invoke i8* @foo()
18+
; CHECK-NEXT: to label [[GOOD:%.*]] unwind label [[BAD:%.*]]
19+
; CHECK: bad:
20+
; CHECK-NEXT: [[T10:%.*]] = landingpad { i8*, i32 }
21+
; CHECK-NEXT: cleanup
22+
; CHECK-NEXT: resume { i8*, i32 } [[T10]]
23+
; CHECK: good:
24+
; CHECK-NEXT: [[T11:%.*]] = icmp ne i8* [[T9]], null
25+
; CHECK-NEXT: [[T12:%.*]] = zext i1 [[T11]] to i64
26+
; CHECK-NEXT: [[COND:%.*]] = icmp eq i64 [[T12]], 1
27+
; CHECK-NEXT: br i1 [[COND]], label [[IF_TRUE:%.*]], label [[DONE:%.*]]
28+
; CHECK: if_true:
29+
; CHECK-NEXT: call void @llvm.assume(i1 [[T11]])
30+
; CHECK-NEXT: br label [[DONE]]
31+
; CHECK: done:
32+
; CHECK-NEXT: ret void
33+
;
34+
bb9:
35+
%t9 = invoke i8* @foo()
36+
to label %good unwind label %bad
37+
38+
bad:
39+
%t10 = landingpad { i8*, i32 }
40+
cleanup
41+
resume { i8*, i32 } %t10
42+
43+
good:
44+
%t11 = icmp ne i8* %t9, null
45+
%t12 = zext i1 %t11 to i64
46+
%cond = icmp eq i64 %t12, 1
47+
br i1 %cond, label %if_true, label %done
48+
49+
if_true:
50+
call void @llvm.assume(i1 %t11)
51+
br label %done
52+
53+
done:
54+
ret void
55+
}
56+
57+
attributes #0 = { nounwind }

0 commit comments

Comments
 (0)