Skip to content

Commit 7f78b6c

Browse files
committed
[nfc] Add regression test for large offsets in X86 ISel
1 parent 1fa0036 commit 7f78b6c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc < %s -mtriple=i386 --frame-pointer=all | FileCheck %s
3+
4+
; ISel will try to fold pointer arithmetic into the address displacement. However, we don't
5+
; want to do that if the offset is very close to the expressible limit because the final frame
6+
; layout may push it over/under the limit.
7+
8+
define i32 @foo(i1 %b) #0 {
9+
; CHECK-LABEL: foo:
10+
; CHECK: # %bb.0: # %entry
11+
; CHECK-NEXT: pushl %ebp
12+
; CHECK-NEXT: .cfi_def_cfa_offset 8
13+
; CHECK-NEXT: .cfi_offset %ebp, -8
14+
; CHECK-NEXT: movl %esp, %ebp
15+
; CHECK-NEXT: .cfi_def_cfa_register %ebp
16+
; CHECK-NEXT: subl $8, %esp
17+
; CHECK-NEXT: movl __stack_chk_guard, %eax
18+
; CHECK-NEXT: movl %eax, -4(%ebp)
19+
; CHECK-NEXT: testb $1, 8(%ebp)
20+
; CHECK-NEXT: jne .LBB0_1
21+
; CHECK-NEXT: # %bb.2: # %entry
22+
; CHECK-NEXT: xorl %eax, %eax
23+
; CHECK-NEXT: jmp .LBB0_3
24+
; CHECK-NEXT: .LBB0_1:
25+
; CHECK-NEXT: leal 2147483644(%ebp), %eax
26+
; CHECK-NEXT: .LBB0_3: # %entry
27+
; CHECK-NEXT: movl __stack_chk_guard, %ecx
28+
; CHECK-NEXT: cmpl -4(%ebp), %ecx
29+
; CHECK-NEXT: jne .LBB0_5
30+
; CHECK-NEXT: # %bb.4: # %entry
31+
; CHECK-NEXT: addl $8, %esp
32+
; CHECK-NEXT: popl %ebp
33+
; CHECK-NEXT: .cfi_def_cfa %esp, 4
34+
; CHECK-NEXT: retl
35+
; CHECK-NEXT: .LBB0_5: # %entry
36+
; CHECK-NEXT: .cfi_def_cfa %ebp, 8
37+
; CHECK-NEXT: calll __stack_chk_fail
38+
entry:
39+
%a = alloca i8, align 1
40+
%0 = ptrtoint ptr %a to i32
41+
%sub = add i32 %0, -2147483647
42+
%retval.0 = select i1 %b, i32 %sub, i32 0
43+
ret i32 %retval.0
44+
}
45+
46+
attributes #0 = { sspreq }

0 commit comments

Comments
 (0)