Skip to content

Commit 378f4e5

Browse files
committed
[AssumptionCache] Do not track llvm.assume calls (PR49043)
This fixes PR49043 by invalidating the handle on RAUW. This will work fine assuming all existing RAUW users add the new assumption to the cache. That means, if a new llvm.assume call replaces an old one, you need to add the new one now as a RAUW is not enough anymore. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D96208
1 parent 624ce59 commit 378f4e5

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

llvm/include/llvm/Analysis/AssumptionCache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class AssumptionCache {
4545
enum : unsigned { ExprResultIdx = std::numeric_limits<unsigned>::max() };
4646

4747
struct ResultElem {
48-
WeakTrackingVH Assume;
48+
WeakVH Assume;
4949

5050
/// contains either ExprResultIdx or the index of the operand bundle
5151
/// containing the knowledge.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
; RUN: opt < %s -S -passes="print<assumptions>,gvn-sink,loop-unroll" -unroll-count=3 | FileCheck %s
2+
;
3+
; This crashed because the cached assumption was replaced and the replacement
4+
; was then in the cache twice.
5+
;
6+
; PR49043
7+
8+
@g = external global i32
9+
10+
define void @main() {
11+
bb:
12+
%i1.i = load volatile i32, i32* @g
13+
%i32.i = icmp eq i32 %i1.i, 0
14+
call void @llvm.assume(i1 %i32.i) #3
15+
br label %bb4.i
16+
17+
bb4.i: ; preds = %bb4.i, %bb
18+
%i.i = load volatile i32, i32* @g
19+
%i3.i = icmp eq i32 %i.i, 0
20+
call void @llvm.assume(i1 %i3.i) #3
21+
br label %bb4.i
22+
23+
func_1.exit: ; No predecessors!
24+
unreachable
25+
}
26+
27+
declare void @llvm.assume(i1)
28+
29+
; CHECK: call void @llvm.assume(
30+
; CHECK: call void @llvm.assume(
31+
; CHECK: call void @llvm.assume(
32+

0 commit comments

Comments
 (0)