Skip to content

Commit c9b8020

Browse files
committed
!fixup allow non-constant integer.
1 parent e3fb9f0 commit c9b8020

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

llvm/lib/IR/Verifier.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5536,6 +5536,15 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
55365536
"third argument should be an integer if present", Call);
55375537
continue;
55385538
}
5539+
if (Kind == Attribute::Dereferenceable) {
5540+
Check(ArgCount == 2,
5541+
"dereferenceable assumptions should have 2 arguments", Call);
5542+
Check(Call.getOperand(Elem.Begin)->getType()->isPointerTy(),
5543+
"first argument should be a pointer", Call);
5544+
Check(Call.getOperand(Elem.Begin + 1)->getType()->isIntegerTy(),
5545+
"second argument should be an integer", Call);
5546+
continue;
5547+
}
55395548
Check(ArgCount <= 2, "too many arguments", Call);
55405549
if (Kind == Attribute::None)
55415550
break;

llvm/test/Transforms/LoopVectorize/early_exit_store_legality.ll

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,35 @@ exit:
165165
ret void
166166
}
167167

168+
define void @loop_contains_store_assumed_bounds(ptr noalias %array, ptr readonly %pred, i32 %n) {
169+
; CHECK-LABEL: LV: Checking a loop in 'loop_contains_store_assumed_bounds'
170+
; CHECK: LV: Not vectorizing: Writes to memory unsupported in early exit loops.
171+
entry:
172+
%n_bytes = mul nuw nsw i32 %n, 2
173+
call void @llvm.assume(i1 true) [ "align"(ptr %pred, i64 2), "dereferenceable"(ptr %pred, i32 %n_bytes) ]
174+
%tc = sext i32 %n to i64
175+
br label %for.body
176+
177+
for.body:
178+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %for.inc ]
179+
%st.addr = getelementptr inbounds nuw i16, ptr %array, i64 %iv
180+
%data = load i16, ptr %st.addr, align 2
181+
%inc = add nsw i16 %data, 1
182+
store i16 %inc, ptr %st.addr, align 2
183+
%ee.addr = getelementptr inbounds nuw i16, ptr %pred, i64 %iv
184+
%ee.val = load i16, ptr %ee.addr, align 2
185+
%ee.cond = icmp sgt i16 %ee.val, 500
186+
br i1 %ee.cond, label %exit, label %for.inc
187+
188+
for.inc:
189+
%iv.next = add nuw nsw i64 %iv, 1
190+
%counted.cond = icmp eq i64 %iv.next, %tc
191+
br i1 %counted.cond, label %exit, label %for.body
192+
193+
exit:
194+
ret void
195+
}
196+
168197
define void @loop_contains_store_to_pointer_with_no_deref_info(ptr align 2 dereferenceable(40) readonly %load.array, ptr align 2 noalias %array, ptr align 2 dereferenceable(40) readonly %pred) {
169198
; CHECK-LABEL: LV: Checking a loop in 'loop_contains_store_to_pointer_with_no_deref_info'
170199
; CHECK: LV: Not vectorizing: Writes to memory unsupported in early exit loops.

llvm/test/Verifier/assume-bundles.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ define void @func(ptr %P, i32 %P1, ptr %P2, ptr %P3) {
77
; CHECK: tags must be valid attribute names
88
; CHECK: "adazdazd"
99
call void @llvm.assume(i1 true) ["adazdazd"()]
10-
; CHECK: the second argument should be a constant integral value
10+
; CHECK-NOT: call{{.+}}deref
1111
call void @llvm.assume(i1 true) ["dereferenceable"(ptr %P, i32 %P1)]
12-
; CHECK: the second argument should be a constant integral value
12+
; CHECK: second argument should be an integer
1313
call void @llvm.assume(i1 true) ["dereferenceable"(ptr %P, float 1.5)]
14-
; CHECK: too many arguments
14+
; CHECK: dereferenceable assumptions should have 2 arguments
1515
call void @llvm.assume(i1 true) ["dereferenceable"(ptr %P, i32 8, i32 8)]
16-
; CHECK: this attribute should have 2 arguments
16+
; CHECK: dereferenceable assumptions should have 2 arguments
1717
call void @llvm.assume(i1 true) ["dereferenceable"(ptr %P)]
1818
; CHECK: this attribute has no argument
1919
call void @llvm.assume(i1 true) ["dereferenceable"(ptr %P, i32 4), "cold"(ptr %P)]
@@ -30,7 +30,7 @@ define void @func(ptr %P, i32 %P1, ptr %P2, ptr %P3) {
3030
call void @llvm.assume(i1 true) ["separate_storage"(ptr %P)]
3131
; CHECK: arguments to separate_storage assumptions should be pointers
3232
call void @llvm.assume(i1 true) ["separate_storage"(ptr %P, i32 123)]
33-
; CHECK: this attribute should have 2 arguments
33+
; CHECK: dereferenceable assumptions should have 2 arguments
3434
call void @llvm.assume(i1 true) ["align"(ptr %P, i32 4), "dereferenceable"(ptr %P)]
3535
ret void
3636
}

0 commit comments

Comments
 (0)