Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s
      2 ; RUN: llc < %s -march=x86-64
      3 ; PR3538
      4 target 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"
      5 target triple = "i386-apple-darwin9"
      6 define signext i8 @foo(i8* %s1) nounwind ssp {
      7 entry:
      8   %s1_addr = alloca i8*                           ; <i8**> [#uses=2]
      9   %retval = alloca i32                            ; <i32*> [#uses=2]
     10   %saved_stack.1 = alloca i8*                     ; <i8**> [#uses=2]
     11   %0 = alloca i32                                 ; <i32*> [#uses=2]
     12   %str.0 = alloca [0 x i8]*                       ; <[0 x i8]**> [#uses=3]
     13   %1 = alloca i64                                 ; <i64*> [#uses=2]
     14   %2 = alloca i64                                 ; <i64*> [#uses=1]
     15   %3 = alloca i64                                 ; <i64*> [#uses=6]
     16   %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
     17   call void @llvm.dbg.declare(metadata !{i8** %s1_addr}, metadata !0), !dbg !7
     18   store i8* %s1, i8** %s1_addr
     19   call void @llvm.dbg.declare(metadata !{[0 x i8]** %str.0}, metadata !8), !dbg !7
     20   %4 = call i8* @llvm.stacksave(), !dbg !7        ; <i8*> [#uses=1]
     21   store i8* %4, i8** %saved_stack.1, align 8, !dbg !7
     22   %5 = load i8** %s1_addr, align 8, !dbg !13      ; <i8*> [#uses=1]
     23   %6 = call i64 @strlen(i8* %5) nounwind readonly, !dbg !13 ; <i64> [#uses=1]
     24   %7 = add i64 %6, 1, !dbg !13                    ; <i64> [#uses=1]
     25   store i64 %7, i64* %3, align 8, !dbg !13
     26   %8 = load i64* %3, align 8, !dbg !13            ; <i64> [#uses=1]
     27   %9 = sub nsw i64 %8, 1, !dbg !13                ; <i64> [#uses=0]
     28   %10 = load i64* %3, align 8, !dbg !13           ; <i64> [#uses=1]
     29   %11 = mul i64 %10, 8, !dbg !13                  ; <i64> [#uses=0]
     30   %12 = load i64* %3, align 8, !dbg !13           ; <i64> [#uses=1]
     31   store i64 %12, i64* %2, align 8, !dbg !13
     32   %13 = load i64* %3, align 8, !dbg !13           ; <i64> [#uses=1]
     33   %14 = mul i64 %13, 8, !dbg !13                  ; <i64> [#uses=0]
     34   %15 = load i64* %3, align 8, !dbg !13           ; <i64> [#uses=1]
     35   store i64 %15, i64* %1, align 8, !dbg !13
     36   %16 = load i64* %1, align 8, !dbg !13           ; <i64> [#uses=1]
     37   %17 = trunc i64 %16 to i32, !dbg !13            ; <i32> [#uses=1]
     38   %18 = alloca i8, i32 %17, !dbg !13              ; <i8*> [#uses=1]
     39   %19 = bitcast i8* %18 to [0 x i8]*, !dbg !13    ; <[0 x i8]*> [#uses=1]
     40   store [0 x i8]* %19, [0 x i8]** %str.0, align 8, !dbg !13
     41   %20 = load [0 x i8]** %str.0, align 8, !dbg !15 ; <[0 x i8]*> [#uses=1]
     42   %21 = getelementptr inbounds [0 x i8]* %20, i64 0, i64 0, !dbg !15 ; <i8*> [#uses=1]
     43   store i8 0, i8* %21, align 1, !dbg !15
     44   %22 = load [0 x i8]** %str.0, align 8, !dbg !16 ; <[0 x i8]*> [#uses=1]
     45   %23 = getelementptr inbounds [0 x i8]* %22, i64 0, i64 0, !dbg !16 ; <i8*> [#uses=1]
     46   %24 = load i8* %23, align 1, !dbg !16           ; <i8> [#uses=1]
     47   %25 = sext i8 %24 to i32, !dbg !16              ; <i32> [#uses=1]
     48   store i32 %25, i32* %0, align 4, !dbg !16
     49   %26 = load i8** %saved_stack.1, align 8, !dbg !16 ; <i8*> [#uses=1]
     50   call void @llvm.stackrestore(i8* %26), !dbg !16
     51   %27 = load i32* %0, align 4, !dbg !16           ; <i32> [#uses=1]
     52   store i32 %27, i32* %retval, align 4, !dbg !16
     53   br label %return, !dbg !16
     54 
     55 return:                                           ; preds = %entry
     56   %retval1 = load i32* %retval, !dbg !16          ; <i32> [#uses=1]
     57   %retval12 = trunc i32 %retval1 to i8, !dbg !16  ; <i8> [#uses=1]
     58   ret i8 %retval12, !dbg !16
     59 }
     60 
     61 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
     62 
     63 declare i8* @llvm.stacksave() nounwind
     64 
     65 declare i64 @strlen(i8*) nounwind readonly
     66 
     67 declare void @llvm.stackrestore(i8*) nounwind
     68 
     69 !0 = metadata !{i32 459009, metadata !1, metadata !"s1", metadata !2, i32 2, metadata !6} ; [ DW_TAG_arg_variable ]
     70 !1 = metadata !{i32 458798, i32 0, metadata !2, metadata !"foo", metadata !"foo", metadata !"foo", metadata !2, i32 2, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false} ; [ DW_TAG_subprogram ]
     71 !2 = metadata !{i32 458769, i32 0, i32 1, metadata !"vla.c", metadata !"/tmp/", metadata !"4.2.1 (Based on Apple Inc. build 5658) (LLVM build)", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ]
     72 !3 = metadata !{i32 458773, metadata !2, metadata !"", metadata !2, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ]
     73 !4 = metadata !{metadata !5, metadata !6}
     74 !5 = metadata !{i32 458788, metadata !2, metadata !"char", metadata !2, i32 0, i64 8, i64 8, i64 0, i32 0, i32 6} ; [ DW_TAG_base_type ]
     75 !6 = metadata !{i32 458767, metadata !2, metadata !"", metadata !2, i32 0, i64 64, i64 64, i64 0, i32 0, metadata !5} ; [ DW_TAG_pointer_type ]
     76 !7 = metadata !{i32 2, i32 0, metadata !1, null}
     77 !8 = metadata !{i32 459008, metadata !1, metadata !"str.0", metadata !2, i32 3, metadata !9} ; [ DW_TAG_auto_variable ]
     78 !9 = metadata !{i32 458767, metadata !2, metadata !"", metadata !2, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !10} ; [ DW_TAG_pointer_type ]
     79 !10 = metadata !{i32 458753, metadata !2, metadata !"", metadata !2, i32 0, i64 8, i64 8, i64 0, i32 0, metadata !5, metadata !11, i32 0, null} ; [ DW_TAG_array_type ]
     80 !11 = metadata !{metadata !12}
     81 !12 = metadata !{i32 458785, i64 0, i64 0}        ; [ DW_TAG_subrange_type ]
     82 !13 = metadata !{i32 3, i32 0, metadata !14, null}
     83 !14 = metadata !{i32 458763, metadata !1, i32 0, i32 0} ; [ DW_TAG_lexical_block ]
     84 !15 = metadata !{i32 4, i32 0, metadata !14, null}
     85 !16 = metadata !{i32 5, i32 0, metadata !14, null}
     86