1*9880d681SAndroid Build Coastguard Worker# RUN: llc -run-pass postrapseudos -mtriple=i386-apple-macosx -o - %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker# Verify that we correctly save and restore eax when copying eflags, 4*9880d681SAndroid Build Coastguard Worker# even when only a smaller alias of eax is used. We used to check only 5*9880d681SAndroid Build Coastguard Worker# eax and not its aliases. 6*9880d681SAndroid Build Coastguard Worker# PR27624. 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Worker--- | 9*9880d681SAndroid Build Coastguard Worker target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard Worker define void @foo() { 12*9880d681SAndroid Build Coastguard Worker entry: 13*9880d681SAndroid Build Coastguard Worker br label %false 14*9880d681SAndroid Build Coastguard Worker false: 15*9880d681SAndroid Build Coastguard Worker ret void 16*9880d681SAndroid Build Coastguard Worker } 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker... 19*9880d681SAndroid Build Coastguard Worker 20*9880d681SAndroid Build Coastguard Worker--- 21*9880d681SAndroid Build Coastguard Workername: foo 22*9880d681SAndroid Build Coastguard WorkerallVRegsAllocated: true 23*9880d681SAndroid Build Coastguard WorkerisSSA: false 24*9880d681SAndroid Build Coastguard WorkertracksRegLiveness: true 25*9880d681SAndroid Build Coastguard Workerliveins: 26*9880d681SAndroid Build Coastguard Worker - { reg: '%edi' } 27*9880d681SAndroid Build Coastguard Workerbody: | 28*9880d681SAndroid Build Coastguard Worker bb.0.entry: 29*9880d681SAndroid Build Coastguard Worker liveins: %edi 30*9880d681SAndroid Build Coastguard Worker successors: %bb.1.false 31*9880d681SAndroid Build Coastguard Worker NOOP implicit-def %al 32*9880d681SAndroid Build Coastguard Worker 33*9880d681SAndroid Build Coastguard Worker ; The bug was triggered only when LivePhysReg is used, which 34*9880d681SAndroid Build Coastguard Worker ; happens only when the heuristic for the liveness computation 35*9880d681SAndroid Build Coastguard Worker ; failed. The liveness computation heuristic looks at 10 instructions 36*9880d681SAndroid Build Coastguard Worker ; before and after the copy. Make sure we do not reach the definition of 37*9880d681SAndroid Build Coastguard Worker ; AL in 10 instructions, otherwise the heuristic will see that it is live. 38*9880d681SAndroid Build Coastguard Worker NOOP 39*9880d681SAndroid Build Coastguard Worker NOOP 40*9880d681SAndroid Build Coastguard Worker NOOP 41*9880d681SAndroid Build Coastguard Worker NOOP 42*9880d681SAndroid Build Coastguard Worker NOOP 43*9880d681SAndroid Build Coastguard Worker NOOP 44*9880d681SAndroid Build Coastguard Worker NOOP 45*9880d681SAndroid Build Coastguard Worker NOOP 46*9880d681SAndroid Build Coastguard Worker NOOP 47*9880d681SAndroid Build Coastguard Worker NOOP 48*9880d681SAndroid Build Coastguard Worker NOOP 49*9880d681SAndroid Build Coastguard Worker NOOP 50*9880d681SAndroid Build Coastguard Worker NOOP 51*9880d681SAndroid Build Coastguard Worker ; Save AL. 52*9880d681SAndroid Build Coastguard Worker ; CHECK: PUSH32r killed %eax 53*9880d681SAndroid Build Coastguard Worker 54*9880d681SAndroid Build Coastguard Worker ; Copy EDI into EFLAGS 55*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: %eax = MOV32rr %edi 56*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: %al = ADD8ri %al, 127, implicit-def %eflags 57*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: SAHF implicit-def %eflags, implicit %ah 58*9880d681SAndroid Build Coastguard Worker %eflags = COPY %edi 59*9880d681SAndroid Build Coastguard Worker 60*9880d681SAndroid Build Coastguard Worker ; Restore AL. 61*9880d681SAndroid Build Coastguard Worker ; CHECK-NEXT: %eax = POP32r 62*9880d681SAndroid Build Coastguard Worker bb.1.false: 63*9880d681SAndroid Build Coastguard Worker liveins: %al 64*9880d681SAndroid Build Coastguard Worker NOOP implicit %al 65*9880d681SAndroid Build Coastguard Worker RETQ 66*9880d681SAndroid Build Coastguard Worker 67*9880d681SAndroid Build Coastguard Worker... 68