1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -stackrealign -mtriple i386-apple-darwin -mcpu=i486 | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker%struct.foo = type { [88 x i8] } 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Workerdeclare void @bar(i8* nocapture, %struct.foo* align 4 byval) nounwind 6*9880d681SAndroid Build Coastguard Workerdeclare void @baz(i8*) nounwind 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard Worker; PR15249 9*9880d681SAndroid Build Coastguard Worker; We can't use rep;movsl here because it clobbers the base pointer in %esi. 10*9880d681SAndroid Build Coastguard Workerdefine void @test1(%struct.foo* nocapture %x, i32 %y) nounwind { 11*9880d681SAndroid Build Coastguard Worker %dynalloc = alloca i8, i32 %y, align 1 12*9880d681SAndroid Build Coastguard Worker call void @bar(i8* %dynalloc, %struct.foo* align 4 byval %x) 13*9880d681SAndroid Build Coastguard Worker ret void 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test1: 16*9880d681SAndroid Build Coastguard Worker; CHECK: andl $-16, %esp 17*9880d681SAndroid Build Coastguard Worker; CHECK: movl %esp, %esi 18*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: rep;movsl 19*9880d681SAndroid Build Coastguard Worker} 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Worker; PR19012 22*9880d681SAndroid Build Coastguard Worker; Also don't clobber %esi if the dynamic alloca comes after the memcpy. 23*9880d681SAndroid Build Coastguard Workerdefine void @test2(%struct.foo* nocapture %x, i32 %y, i8* %z) nounwind { 24*9880d681SAndroid Build Coastguard Worker call void @bar(i8* %z, %struct.foo* align 4 byval %x) 25*9880d681SAndroid Build Coastguard Worker %dynalloc = alloca i8, i32 %y, align 1 26*9880d681SAndroid Build Coastguard Worker call void @baz(i8* %dynalloc) 27*9880d681SAndroid Build Coastguard Worker ret void 28*9880d681SAndroid Build Coastguard Worker 29*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test2: 30*9880d681SAndroid Build Coastguard Worker; CHECK: movl %esp, %esi 31*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: rep;movsl 32*9880d681SAndroid Build Coastguard Worker} 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Worker; Check that we do use rep movs if we make the alloca static. 35*9880d681SAndroid Build Coastguard Workerdefine void @test3(%struct.foo* nocapture %x, i32 %y, i8* %z) nounwind { 36*9880d681SAndroid Build Coastguard Worker call void @bar(i8* %z, %struct.foo* align 4 byval %x) 37*9880d681SAndroid Build Coastguard Worker %statalloc = alloca i8, i32 8, align 1 38*9880d681SAndroid Build Coastguard Worker call void @baz(i8* %statalloc) 39*9880d681SAndroid Build Coastguard Worker ret void 40*9880d681SAndroid Build Coastguard Worker 41*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test3: 42*9880d681SAndroid Build Coastguard Worker; CHECK: rep;movsl 43*9880d681SAndroid Build Coastguard Worker} 44