Home | History | Annotate | Download | only in X86
      1 ; RUN: llc -mtriple=x86_64-linux-gnueabi -disable-debug-info-print < %s | FileCheck %s
      2 ; RUN: opt -strip -S < %s | llc -mtriple=x86_64-linux-gnueabi -disable-debug-info-print | FileCheck %s
      3 
      4 ; This test checks if the code is generated correctly with and without debug info.
      5 
      6 ; This LL file was generated by running 'clang -g -gcodeview' on the
      7 ; following code:
      8 ;  1: extern "C" volatile int x;
      9 ;  2: extern "C" void capture(int *p);
     10 ;  3: static __forceinline inline void will_be_inlined() {
     11 ;  4:   int v = 3;
     12 ;  5:   capture(&v);
     13 ;  6: }
     14 ;  7: extern "C" void f(int param) {
     15 ;  8:   if (param) {
     16 ;  9:     int a = 42;
     17 ; 10:     will_be_inlined();
     18 ; 11:     capture(&a);
     19 ; 12:   } else {
     20 ; 13:     int b = 42;
     21 ; 14:     will_be_inlined();
     22 ; 15:     capture(&b);
     23 ; 16:   }
     24 ; 17: }
     25 
     26 ; ModuleID = 't.cpp'
     27 
     28 ; Function Attrs: nounwind uwtable
     29 define void @f(i32 %param) #0 !dbg !4 {
     30 entry:
     31   %v.i1 = alloca i32, align 4
     32   call void @llvm.dbg.declare(metadata i32* %v.i1, metadata !15, metadata !16), !dbg !17
     33   %v.i = alloca i32, align 4
     34   call void @llvm.dbg.declare(metadata i32* %v.i, metadata !15, metadata !16), !dbg !21
     35   %param.addr = alloca i32, align 4
     36   %a = alloca i32, align 4
     37   %b = alloca i32, align 4
     38   store i32 %param, i32* %param.addr, align 4
     39   call void @llvm.dbg.declare(metadata i32* %param.addr, metadata !24, metadata !16), !dbg !25
     40   %0 = load i32, i32* %param.addr, align 4, !dbg !26
     41   %tobool = icmp ne i32 %0, 0, !dbg !26
     42   br i1 %tobool, label %if.then, label %if.else, !dbg !27
     43 
     44 ;CHECK: movl [[REG:.*]], 20(%rsp)
     45 ;CHECK: je [[LABEL:.*]]
     46 
     47 if.then:                                          ; preds = %entry
     48   call void @llvm.dbg.declare(metadata i32* %a, metadata !28, metadata !16), !dbg !29
     49   store i32 42, i32* %a, align 4, !dbg !29
     50   store i32 3, i32* %v.i, align 4, !dbg !21
     51   call void @capture(i32* %v.i) #3, !dbg !30
     52   call void @capture(i32* %a), !dbg !31
     53   br label %if.end, !dbg !32
     54 
     55 ;CHECK: movl    $3, 12(%rsp)
     56 
     57 if.else:                                          ; preds = %entry
     58   call void @llvm.dbg.declare(metadata i32* %b, metadata !33, metadata !16), !dbg !34
     59   store i32 42, i32* %b, align 4, !dbg !34
     60   store i32 3, i32* %v.i1, align 4, !dbg !17
     61   call void @capture(i32* %v.i1) #3, !dbg !35
     62   call void @capture(i32* %b), !dbg !36
     63   br label %if.end
     64 
     65 ;CHECK: [[LABEL]]:
     66 ;CHECK: movl    $3, 16(%rsp)
     67 
     68 if.end:                                           ; preds = %if.else, %if.then
     69   ret void, !dbg !37
     70 }
     71 
     72 ; Function Attrs: nounwind readnone
     73 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
     74 
     75 declare void @capture(i32*) #2
     76 
     77 attributes #0 = { nounwind uwtable "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-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
     78 attributes #1 = { nounwind readnone }
     79 attributes #2 = { "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-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
     80 attributes #3 = { nounwind }
     81 
     82 !llvm.dbg.cu = !{!0}
     83 !llvm.module.flags = !{!11, !12, !13}
     84 !llvm.ident = !{!14}
     85 
     86 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
     87 !1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
     88 !2 = !{}
     89 !4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 7, type: !5, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
     90 !5 = !DISubroutineType(types: !6)
     91 !6 = !{null, !7}
     92 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
     93 !8 = distinct !DISubprogram(name: "will_be_inlined", linkageName: "\01?will_be_inlined@@YAXXZ", scope: !1, file: !1, line: 3, type: !9, isLocal: true, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
     94 !9 = !DISubroutineType(types: !10)
     95 !10 = !{null}
     96 !11 = !{i32 2, !"CodeView", i32 1}
     97 !12 = !{i32 2, !"Debug Info Version", i32 3}
     98 !13 = !{i32 1, !"PIC Level", i32 2}
     99 !14 = !{!"clang version 3.9.0 "}
    100 !15 = !DILocalVariable(name: "v", scope: !8, file: !1, line: 4, type: !7)
    101 !16 = !DIExpression()
    102 !17 = !DILocation(line: 4, column: 7, scope: !8, inlinedAt: !18)
    103 !18 = distinct !DILocation(line: 14, column: 5, scope: !19)
    104 !19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 12, column: 10)
    105 !20 = distinct !DILexicalBlock(scope: !4, file: !1, line: 8, column: 7)
    106 !21 = !DILocation(line: 4, column: 7, scope: !8, inlinedAt: !22)
    107 !22 = distinct !DILocation(line: 10, column: 5, scope: !23)
    108 !23 = distinct !DILexicalBlock(scope: !20, file: !1, line: 8, column: 14)
    109 !24 = !DILocalVariable(name: "param", arg: 1, scope: !4, file: !1, line: 7, type: !7)
    110 !25 = !DILocation(line: 7, column: 23, scope: !4)
    111 !26 = !DILocation(line: 8, column: 7, scope: !20)
    112 !27 = !DILocation(line: 8, column: 7, scope: !4)
    113 !28 = !DILocalVariable(name: "a", scope: !23, file: !1, line: 9, type: !7)
    114 !29 = !DILocation(line: 9, column: 9, scope: !23)
    115 !30 = !DILocation(line: 5, column: 3, scope: !8, inlinedAt: !22)
    116 !31 = !DILocation(line: 11, column: 5, scope: !23)
    117 !32 = !DILocation(line: 12, column: 3, scope: !23)
    118 !33 = !DILocalVariable(name: "b", scope: !19, file: !1, line: 13, type: !7)
    119 !34 = !DILocation(line: 13, column: 9, scope: !19)
    120 !35 = !DILocation(line: 5, column: 3, scope: !8, inlinedAt: !18)
    121 !36 = !DILocation(line: 15, column: 5, scope: !19)
    122 !37 = !DILocation(line: 17, column: 1, scope: !4)
    123