1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s | FileCheck %s
4 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-unknown-linux-gnu"
7 ; https://github.com/llvm/llvm-project/issues/49509
8 ; Stack probes must not clobber live EFLAGS. Previously, the prologue was
9 ; inserted in %bb.2, with "subq $8, %rsp" clobbering the "sets %bl" flag.
11 define i32 @f(i32 %a, i32 %b) #0 {
13 ; CHECK: # %bb.0: # %bb13.i
14 ; CHECK-NEXT: pushq %rbp
15 ; CHECK-NEXT: pushq %rbx
16 ; CHECK-NEXT: pushq %rax
17 ; CHECK-NEXT: testl %edi, %edi
18 ; CHECK-NEXT: je .LBB0_1
19 ; CHECK-NEXT: # %bb.2: # %bb16.i
20 ; CHECK-NEXT: sets %bl
21 ; CHECK-NEXT: testl %esi, %esi
22 ; CHECK-NEXT: sets %bpl
23 ; CHECK-NEXT: xorl %eax, %eax
24 ; CHECK-NEXT: callq *%rax
25 ; CHECK-NEXT: movb $1, %al
26 ; CHECK-NEXT: testb %al, %al
27 ; CHECK-NEXT: xorb %bpl, %bl
28 ; CHECK-NEXT: testb %al, %al
29 ; CHECK-NEXT: xorb $1, %bl
30 ; CHECK-NEXT: movzbl %bl, %eax
31 ; CHECK-NEXT: jmp .LBB0_3
32 ; CHECK-NEXT: .LBB0_1:
33 ; CHECK-NEXT: xorl %eax, %eax
34 ; CHECK-NEXT: .LBB0_3: # %exit2
35 ; CHECK-NEXT: addq $8, %rsp
36 ; CHECK-NEXT: popq %rbx
37 ; CHECK-NEXT: popq %rbp
40 %0 = icmp eq i32 %a, 0
41 br i1 %0, label %exit2, label %bb16.i
43 bb16.i: ; preds = %bb13.i
44 %1 = icmp slt i32 %a, 0
45 %2 = icmp slt i32 %b, 0
46 %sign_z.i = xor i1 %1, %2
49 exit1: ; preds = %bb16.i
50 %3 = call { i64, i64 } null()
52 br i1 %4, label %bb41.i, label %bb33.i
54 bb33.i: ; preds = %exit1
55 %rcarry.not.i = icmp ult i64 0, 0
58 bb41.i: ; preds = %bb33.i, %exit1
61 bb62.i: ; preds = %bb41.i
62 %_109.not.i = icmp eq i8 0, 0
63 br i1 %_109.not.i, label %bb70.i, label %bb64.i
65 bb64.i: ; preds = %bb62.i
69 bb70.i: ; preds = %bb64.i, %bb62.i
70 %spec.select.i.i = select i1 %sign_z.i, i32 0, i32 1
73 exit2: ; preds = %bb70.i, %bb13.i
74 %.1.i = phi i32 [ %spec.select.i.i, %bb70.i ], [ 0, %bb13.i ]
78 define void @CSE_eflags_live(i64 %length) "probe-stack"="__chkstk_darwin" {
79 ; CHECK-LABEL: CSE_eflags_live:
80 ; CHECK: # %bb.0: # %entry
81 ; CHECK-NEXT: pushq %rbp
82 ; CHECK-NEXT: .cfi_def_cfa_offset 16
83 ; CHECK-NEXT: .cfi_offset %rbp, -16
84 ; CHECK-NEXT: movq %rsp, %rbp
85 ; CHECK-NEXT: .cfi_def_cfa_register %rbp
86 ; CHECK-NEXT: testq %rdi, %rdi
87 ; CHECK-NEXT: je .LBB1_2
88 ; CHECK-NEXT: # %bb.1: # %if.end6
89 ; CHECK-NEXT: movq $-1, %rax
90 ; CHECK-NEXT: cmovnsq %rdi, %rax
91 ; CHECK-NEXT: addq $15, %rax
92 ; CHECK-NEXT: andq $-16, %rax
93 ; CHECK-NEXT: callq __chkstk_darwin
94 ; CHECK-NEXT: subq %rax, %rsp
95 ; CHECK-NEXT: .LBB1_2: # %cleanup78
96 ; CHECK-NEXT: movq %rbp, %rsp
97 ; CHECK-NEXT: popq %rbp
98 ; CHECK-NEXT: .cfi_def_cfa %rsp, 8
101 %cmp4 = icmp eq i64 %length, 0
102 br i1 %cmp4, label %cleanup78, label %if.end6
105 %0 = tail call i64 @llvm.smax.i64(i64 %length, i64 -1)
106 %vla = alloca i8, i64 %0, align 16
113 declare i64 @llvm.smax.i64(i64, i64)
115 attributes #0 = { nounwind "probe-stack"="inline-asm" }