Hans Wennborg | 6596977 | 2016-03-30 23:38:01 +0000 | [diff] [blame] | 1 | ; RUN: llc %s -o - -enable-shrink-wrap=true -no-x86-call-frame-opt | FileCheck %s --check-prefix=CHECK --check-prefix=ENABLE |
| 2 | ; RUN: llc %s -o - -enable-shrink-wrap=false -no-x86-call-frame-opt | FileCheck %s --check-prefix=CHECK --check-prefix=DISABLE |
Quentin Colombet | f1e91c8 | 2015-12-02 01:22:54 +0000 | [diff] [blame] | 3 | target datalayout = "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128" |
| 4 | target triple = "i386-apple-macosx" |
| 5 | |
| 6 | @a = common global i32 0, align 4 |
| 7 | @d = internal unnamed_addr global i1 false |
| 8 | @b = common global i32 0, align 4 |
| 9 | @e = common global i8 0, align 1 |
| 10 | @f = common global i8 0, align 1 |
| 11 | @c = common global i32 0, align 4 |
| 12 | @.str = private unnamed_addr constant [4 x i8] c"%d\0A\00", align 1 |
| 13 | |
| 14 | |
| 15 | ; Check that we are clobbering the flags when they are live-in of the |
| 16 | ; prologue block and the prologue needs to adjust the stack. |
| 17 | ; PR25607. |
| 18 | ; |
| 19 | ; CHECK-LABEL: eflagsLiveInPrologue: |
| 20 | ; |
| 21 | ; DISABLE: pushl |
| 22 | ; DISABLE-NEXT: pushl |
| 23 | ; DISABLE-NEXT: subl $20, %esp |
| 24 | ; |
| 25 | ; CHECK: movl L_a$non_lazy_ptr, [[A:%[a-z]+]] |
| 26 | ; CHECK-NEXT: cmpl $0, ([[A]]) |
| 27 | ; CHECK-NEXT: je [[PREHEADER_LABEL:LBB[0-9_]+]] |
| 28 | ; |
| 29 | ; CHECK: movb $1, _d |
| 30 | ; |
| 31 | ; CHECK: [[PREHEADER_LABEL]]: |
| 32 | ; CHECK-NEXT: movl L_b$non_lazy_ptr, [[B:%[a-z]+]] |
| 33 | ; CHECK-NEXT: movl ([[B]]), [[TMP1:%[a-z]+]] |
| 34 | ; CHECK-NEXT: testl [[TMP1]], [[TMP1]] |
| 35 | ; CHECK-NEXT: je [[FOREND_LABEL:LBB[0-9_]+]] |
| 36 | ; |
| 37 | ; Skip the loop. |
| 38 | ; [...] |
| 39 | ; |
| 40 | ; The for.end block is split to accomadate the different selects. |
| 41 | ; We are interested in the one with the call, so skip until the branch. |
| 42 | ; CHECK: [[FOREND_LABEL]]: |
| 43 | ; CHECK-NEXT: movb _d, [[D:%[a-z]+]] |
| 44 | ; [...] |
| 45 | ; CHECK: jne [[CALL_LABEL:LBB[0-9_]+]] |
| 46 | ; |
| 47 | ; CHECK: movb $6, [[D]] |
| 48 | ; |
| 49 | ; CHECK: [[CALL_LABEL]] |
| 50 | ; |
| 51 | ; ENABLE-NEXT: pushl |
| 52 | ; ENABLE-NEXT: pushl |
| 53 | ; We must not use sub here otherwise we will clobber the eflags. |
| 54 | ; ENABLE-NEXT: leal -20(%esp), %esp |
| 55 | ; |
| 56 | ; CHECK-NEXT: L_e$non_lazy_ptr, [[E:%[a-z]+]] |
| 57 | ; CHECK-NEXT: movb [[D]], ([[E]]) |
| 58 | ; CHECK-NEXT: L_f$non_lazy_ptr, [[F:%[a-z]+]] |
| 59 | ; CHECK-NEXT: movsbl ([[F]]), [[CONV:%[a-z]+]] |
| 60 | ; CHECK-NEXT: movl $6, [[CONV:%[a-z]+]] |
| 61 | ; The eflags is used in the next instruction. |
| 62 | ; If that instruction disappear, we are not exercising the bug |
| 63 | ; anymore. |
| 64 | ; CHECK-NEXT: cmovnel {{%[a-z]+}}, [[CONV]] |
| 65 | ; |
| 66 | ; Skip all the crust of vaarg lowering. |
| 67 | ; CHECK: calll L_varfunc$stub |
| 68 | ; Set the return value to 0. |
| 69 | ; CHECK-NEXT: xorl %eax, %eax |
| 70 | ; CHECK-NEXT: addl $20, %esp |
| 71 | ; CHECK-NEXT: popl |
| 72 | ; CHECK-NEXT: popl |
| 73 | ; CHECK-NEXT: retl |
| 74 | define i32 @eflagsLiveInPrologue() #0 { |
| 75 | entry: |
| 76 | %tmp = load i32, i32* @a, align 4 |
| 77 | %tobool = icmp eq i32 %tmp, 0 |
| 78 | br i1 %tobool, label %for.cond.preheader, label %if.then |
| 79 | |
| 80 | if.then: ; preds = %entry |
| 81 | store i1 true, i1* @d, align 1 |
| 82 | br label %for.cond.preheader |
| 83 | |
| 84 | for.cond.preheader: ; preds = %if.then, %entry |
| 85 | %tmp1 = load i32, i32* @b, align 4 |
| 86 | %tobool14 = icmp eq i32 %tmp1, 0 |
| 87 | br i1 %tobool14, label %for.end, label %for.body.preheader |
| 88 | |
| 89 | for.body.preheader: ; preds = %for.cond.preheader |
| 90 | br label %for.body |
| 91 | |
| 92 | for.body: ; preds = %for.body, %for.body.preheader |
| 93 | br label %for.body |
| 94 | |
| 95 | for.end: ; preds = %for.cond.preheader |
| 96 | %.b3 = load i1, i1* @d, align 1 |
| 97 | %tmp2 = select i1 %.b3, i8 0, i8 6 |
| 98 | store i8 %tmp2, i8* @e, align 1 |
| 99 | %tmp3 = load i8, i8* @f, align 1 |
| 100 | %conv = sext i8 %tmp3 to i32 |
| 101 | %add = add nsw i32 %conv, 1 |
| 102 | %rem = srem i32 %tmp1, %add |
| 103 | store i32 %rem, i32* @c, align 4 |
| 104 | %conv2 = select i1 %.b3, i32 0, i32 6 |
| 105 | %call = tail call i32 (i8*, ...) @varfunc(i8* nonnull getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i32 %conv2) #1 |
| 106 | ret i32 0 |
| 107 | } |
| 108 | |
| 109 | ; Function Attrs: nounwind |
| 110 | declare i32 @varfunc(i8* nocapture readonly, ...) #0 |
| 111 | |
| 112 | attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-features"="+mmx,+sse" "unsafe-fp-math"="false" "use-soft-float"="false" } |
| 113 | attributes #1 = { nounwind } |