1; RUN: llc < %s 2; RUN: llc < %s -stack-symbol-ordering=0 -march=x86-64 -verify-machineinstrs | FileCheck %s 3; PR3538 4target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128" 5target triple = "i386-apple-darwin9" 6define signext i8 @foo(i8* %s1) nounwind ssp { 7 8; Make sure we generate: 9; movq -40(%rbp), %rsp 10; Instead of: 11; movq -40(%rbp), %rax 12; movq %rax, %rsp 13 14; CHECK-LABEL: @foo 15; CHECK: movq -{{[0-9]+}}(%rbp), %rsp 16 17entry: 18 %s1_addr = alloca i8* ; <i8**> [#uses=2] 19 %retval = alloca i32 ; <i32*> [#uses=2] 20 %saved_stack.1 = alloca i8* ; <i8**> [#uses=2] 21 %0 = alloca i32 ; <i32*> [#uses=2] 22 %str.0 = alloca [0 x i8]* ; <[0 x i8]**> [#uses=3] 23 %1 = alloca i64 ; <i64*> [#uses=2] 24 %2 = alloca i64 ; <i64*> [#uses=1] 25 %3 = alloca i64 ; <i64*> [#uses=6] 26 %"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0] 27 call void @llvm.dbg.declare(metadata i8** %s1_addr, metadata !0, metadata !DIExpression()), !dbg !7 28 store i8* %s1, i8** %s1_addr 29 call void @llvm.dbg.declare(metadata [0 x i8]** %str.0, metadata !8, metadata !DIExpression()), !dbg !7 30 %4 = call i8* @llvm.stacksave(), !dbg !7 ; <i8*> [#uses=1] 31 store i8* %4, i8** %saved_stack.1, align 8, !dbg !7 32 %5 = load i8*, i8** %s1_addr, align 8, !dbg !13 ; <i8*> [#uses=1] 33 %6 = call i64 @strlen(i8* %5) nounwind readonly, !dbg !13 ; <i64> [#uses=1] 34 %7 = add i64 %6, 1, !dbg !13 ; <i64> [#uses=1] 35 store i64 %7, i64* %3, align 8, !dbg !13 36 %8 = load i64, i64* %3, align 8, !dbg !13 ; <i64> [#uses=1] 37 %9 = sub nsw i64 %8, 1, !dbg !13 ; <i64> [#uses=0] 38 %10 = load i64, i64* %3, align 8, !dbg !13 ; <i64> [#uses=1] 39 %11 = mul i64 %10, 8, !dbg !13 ; <i64> [#uses=0] 40 %12 = load i64, i64* %3, align 8, !dbg !13 ; <i64> [#uses=1] 41 store i64 %12, i64* %2, align 8, !dbg !13 42 %13 = load i64, i64* %3, align 8, !dbg !13 ; <i64> [#uses=1] 43 %14 = mul i64 %13, 8, !dbg !13 ; <i64> [#uses=0] 44 %15 = load i64, i64* %3, align 8, !dbg !13 ; <i64> [#uses=1] 45 store i64 %15, i64* %1, align 8, !dbg !13 46 %16 = load i64, i64* %1, align 8, !dbg !13 ; <i64> [#uses=1] 47 %17 = trunc i64 %16 to i32, !dbg !13 ; <i32> [#uses=1] 48 %18 = alloca i8, i32 %17, !dbg !13 ; <i8*> [#uses=1] 49 %19 = bitcast i8* %18 to [0 x i8]*, !dbg !13 ; <[0 x i8]*> [#uses=1] 50 store [0 x i8]* %19, [0 x i8]** %str.0, align 8, !dbg !13 51 %20 = load [0 x i8]*, [0 x i8]** %str.0, align 8, !dbg !15 ; <[0 x i8]*> [#uses=1] 52 %21 = getelementptr inbounds [0 x i8], [0 x i8]* %20, i64 0, i64 0, !dbg !15 ; <i8*> [#uses=1] 53 store i8 0, i8* %21, align 1, !dbg !15 54 %22 = load [0 x i8]*, [0 x i8]** %str.0, align 8, !dbg !16 ; <[0 x i8]*> [#uses=1] 55 %23 = getelementptr inbounds [0 x i8], [0 x i8]* %22, i64 0, i64 0, !dbg !16 ; <i8*> [#uses=1] 56 %24 = load i8, i8* %23, align 1, !dbg !16 ; <i8> [#uses=1] 57 %25 = sext i8 %24 to i32, !dbg !16 ; <i32> [#uses=1] 58 store i32 %25, i32* %0, align 4, !dbg !16 59 %26 = load i8*, i8** %saved_stack.1, align 8, !dbg !16 ; <i8*> [#uses=1] 60 call void @llvm.stackrestore(i8* %26), !dbg !16 61 %27 = load i32, i32* %0, align 4, !dbg !16 ; <i32> [#uses=1] 62 store i32 %27, i32* %retval, align 4, !dbg !16 63 br label %return, !dbg !16 64 65return: ; preds = %entry 66 %retval1 = load i32, i32* %retval, !dbg !16 ; <i32> [#uses=1] 67 %retval12 = trunc i32 %retval1 to i8, !dbg !16 ; <i8> [#uses=1] 68 ret i8 %retval12, !dbg !16 69} 70 71declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone 72 73declare i8* @llvm.stacksave() nounwind 74 75declare i64 @strlen(i8*) nounwind readonly 76 77declare void @llvm.stackrestore(i8*) nounwind 78 79!llvm.dbg.cu = !{!2} 80!0 = !DILocalVariable(name: "s1", line: 2, arg: 1, scope: !1, file: !2, type: !6) 81!1 = distinct !DISubprogram(name: "foo", linkageName: "foo", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: false, unit: !2, scope: !2, type: !3) 82!2 = distinct !DICompileUnit(language: DW_LANG_C89, producer: "4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", isOptimized: true, emissionKind: FullDebug, file: !17, enums: !18, retainedTypes: !18) 83!3 = !DISubroutineType(types: !4) 84!4 = !{!5, !6} 85!5 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) 86!6 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, scope: !2, baseType: !5) 87!7 = !DILocation(line: 2, scope: !1) 88!8 = !DILocalVariable(name: "str.0", line: 3, scope: !1, file: !2, type: !9) 89!9 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial, scope: !2, baseType: !10) 90!10 = !DICompositeType(tag: DW_TAG_array_type, size: 8, align: 8, scope: !2, baseType: !5, elements: !11) 91!11 = !{!12} 92!12 = !DISubrange(count: 1) 93!13 = !DILocation(line: 3, scope: !14) 94!14 = distinct !DILexicalBlock(line: 0, column: 0, file: !17, scope: !1) 95!15 = !DILocation(line: 4, scope: !14) 96!16 = !DILocation(line: 5, scope: !14) 97!17 = !DIFile(filename: "vla.c", directory: "/tmp/") 98!18 = !{i32 0} 99