Skip to content

Commit 334c1ab

Browse files
authored
Add regression tests from ConstantData uselist removal (#138960)
Add some examples of failures after 87f312a
1 parent a11d864 commit 334c1ab

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
3+
4+
; Make sure codegen doesn't try to inspect the use list of constants
5+
6+
; Make sure we do not try to make use of the uselist of a constant
7+
; null when looking for the alignment of the pointer.
8+
define <2 x i32> @no_uselist_null_isDereferenceableAndAlignedPointer(i1 %arg0, ptr align(4) %arg) {
9+
; CHECK-LABEL: no_uselist_null_isDereferenceableAndAlignedPointer:
10+
; CHECK: # %bb.0:
11+
; CHECK-NEXT: xorl %eax, %eax
12+
; CHECK-NEXT: testb $1, %dil
13+
; CHECK-NEXT: cmoveq %rsi, %rax
14+
; CHECK-NEXT: movss {{.*#+}} xmm0 = mem[0],zero,zero,zero
15+
; CHECK-NEXT: retq
16+
%select.ptr = select i1 %arg0, ptr null, ptr %arg
17+
%load = load i32, ptr %select.ptr
18+
%insert = insertelement <2 x i32> zeroinitializer, i32 %load, i64 0
19+
ret <2 x i32> %insert
20+
}
21+
22+
; Make sure we do not try to inspect the uselist of a constant null
23+
; when processing a memcpy
24+
define void @gep_nullptr_no_inspect_uselist(ptr %arg) {
25+
; CHECK-LABEL: gep_nullptr_no_inspect_uselist:
26+
; CHECK: # %bb.0:
27+
; CHECK-NEXT: movzbl 16, %eax
28+
; CHECK-NEXT: movb %al, (%rdi)
29+
; CHECK-NEXT: retq
30+
%null_gep = getelementptr i8, ptr null, i64 16
31+
call void @llvm.memcpy.p0.p0.i64(ptr %arg, ptr %null_gep, i64 1, i1 false)
32+
ret void
33+
}
34+
35+
define <16 x i8> @load_null_offset() {
36+
; CHECK-LABEL: load_null_offset:
37+
; CHECK: # %bb.0:
38+
; CHECK-NEXT: movzbl 11, %eax
39+
; CHECK-NEXT: movd %eax, %xmm1
40+
; CHECK-NEXT: pslld $8, %xmm1
41+
; CHECK-NEXT: xorps %xmm0, %xmm0
42+
; CHECK-NEXT: movss {{.*#+}} xmm0 = xmm1[0],xmm0[1,2,3]
43+
; CHECK-NEXT: retq
44+
%gep.null = getelementptr i8, ptr null, i64 11
45+
%load = load i8, ptr %gep.null, align 1
46+
%insert = insertelement <16 x i8> zeroinitializer, i8 %load, i64 1
47+
ret <16 x i8> %insert
48+
}
49+
50+
declare void @llvm.memcpy.p0.p0.i64(ptr noalias writeonly captures(none), ptr noalias readonly captures(none), i64, i1 immarg) #0
51+
52+
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S -passes=correlated-propagation < %s | FileCheck %s
3+
4+
; Test for regression after 87f312aad6e from trying to use the uselist of constantdata
5+
6+
define ptr @_ZN4mlir6Region15getParentOfTypeINS_19FunctionOpInterfaceEEET_v() {
7+
; CHECK-LABEL: define ptr @_ZN4mlir6Region15getParentOfTypeINS_19FunctionOpInterfaceEEET_v() {
8+
; CHECK-NEXT: [[ENTRY:.*:]]
9+
; CHECK-NEXT: [[CALL_FCA_0_EXTRACT:%.*]] = extractvalue [2 x i64] zeroinitializer, 0
10+
; CHECK-NEXT: [[I2P:%.*]] = inttoptr i64 [[CALL_FCA_0_EXTRACT]] to ptr
11+
; CHECK-NEXT: [[CMP_I:%.*]] = icmp ne ptr [[I2P]], null
12+
; CHECK-NEXT: br i1 [[CMP_I]], label %[[CLEANUP:.*]], label %[[DO_COND:.*]]
13+
; CHECK: [[DO_COND]]:
14+
; CHECK-NEXT: br label %[[CLEANUP]]
15+
; CHECK: [[CLEANUP]]:
16+
; CHECK-NEXT: ret ptr [[I2P]]
17+
;
18+
entry:
19+
%call.fca.0.extract = extractvalue [2 x i64] zeroinitializer, 0
20+
%i2p = inttoptr i64 %call.fca.0.extract to ptr
21+
%cmp.i = icmp ne ptr %i2p, null
22+
br i1 %cmp.i, label %cleanup, label %do.cond
23+
24+
do.cond: ; preds = %entry
25+
br label %cleanup
26+
27+
cleanup: ; preds = %do.cond, %entry
28+
%phi = phi ptr [ %i2p, %entry ], [ null, %do.cond ]
29+
ret ptr %phi
30+
}

0 commit comments

Comments
 (0)