Home | History | Annotate | Download | only in COFF
      1 ; RUN: llc < %s -filetype=obj | llvm-readobj - -codeview | FileCheck %s
      2 ;
      3 ; -- lexicablock.cxx begin ----------------------------------------------------
      4 ; int main(int argc, char *argv[]) {
      5 ;   int localA = 1;
      6 ;
      7 ;   { // S_BLOCK32 not emitted because it has multiple address ranges.
      8 ;     int localB = 2;
      9 ;
     10 ;     if (__builtin_expect(argc != 1, 0)) { // S_BLOCK32 containing 'localC'
     11 ;       int localC = 3;
     12 ;     }
     13 ;   }
     14 ;
     15 ;   { // S_BLOCK32 containing 'localD'
     16 ;     int localD = 4;
     17 ;     localA = localD;
     18 ;   }
     19 ;
     20 ;   { // S_BLOCK32 not emitted
     21 ;     { // S_BLOCK32 containing 'localE'
     22 ;       int localE = 5;
     23 ;       localA = localE;
     24 ;     }
     25 ;   }
     26 ;
     27 ;   { // S_BLOCK32 containing 'localF'
     28 ;     int localF = 6;
     29 ;     localA = localF;
     30 ;
     31 ;     { // S_BLOCK32 containing 'localG'
     32 ;       int localG = 7;
     33 ;       localA = localG;
     34 ;     }
     35 ;   }
     36 ;
     37 ;   if (localA == 7) { // S_BLOCK32 containing 'localH'
     38 ;     int localH = 8;
     39 ;     localA = localH;
     40 ;   }
     41 ;
     42 ;   return localA != 8 ? -1 : 0;
     43 ; }
     44 ; -- lexicalblock.cxx end -----------------------------------------------------
     45 ;
     46 ; To regenerate the IR below:
     47 ;   $ clang -cc1 -triple i686-pc-windows -emit-llvm -o lexicalblock.tmp -debug-info-kind=limited -gcodeview lexicablock.cxx -O1 -disable-llvm-passes
     48 ;   $ opt -lower-expect -S -o lexicalblock.ll < lexicalblock.tmp
     49 ;
     50 ; The commands above split the lexical block containing localB and localC into
     51 ; two parts, thus creating multiple ranges for the containing lexical block
     52 ; without optimizing out the whole thing.
     53 ;
     54 ; CHECK: {{.*}}Proc{{.*}}Sym {
     55 ; CHECK:   DisplayName: main
     56 ; CHECK: }
     57 ; CHECK: LocalSym {
     58 ; CHECK:   VarName: argc
     59 ; CHECK: }
     60 ; CHECK: LocalSym {
     61 ; CHECK:   VarName: argv
     62 ; CHECK: }
     63 ; CHECK: LocalSym {
     64 ; CHECK:   VarName: localA
     65 ; CHECK: }
     66 ; CHECK: LocalSym {
     67 ; CHECK:   VarName: localB
     68 ; CHECK: }
     69 ; CHECK: BlockSym {
     70 ; CHECK:   Kind: S_BLOCK32 {{.*}}
     71 ; CHECK:   BlockName: 
     72 ; CHECK: }
     73 ; CHECK: LocalSym {
     74 ; CHECK:   VarName: localC
     75 ; CHECK: }
     76 ; CHECK: ScopeEndSym {
     77 ; CHECK:   Kind: S_END {{.*}}
     78 ; CHECK: }
     79 ; CHECK: BlockSym {
     80 ; CHECK:   Kind: S_BLOCK32 {{.*}}
     81 ; CHECK:   BlockName: 
     82 ; CHECK: }
     83 ; CHECK: LocalSym {
     84 ; CHECK:   VarName: localD
     85 ; CHECK: }
     86 ; CHECK: ScopeEndSym {
     87 ; CHECK:   Kind: S_END {{.*}}
     88 ; CHECK: }
     89 ; CHECK: BlockSym {
     90 ; CHECK:   Kind: S_BLOCK32 {{.*}}
     91 ; CHECK:   BlockName: 
     92 ; CHECK: }
     93 ; CHECK: LocalSym {
     94 ; CHECK:   VarName: localE
     95 ; CHECK: }
     96 ; CHECK: ScopeEndSym {
     97 ; CHECK: }
     98 ; CHECK: BlockSym {
     99 ; CHECK:   Kind: S_BLOCK32 {{.*}}
    100 ; CHECK:   BlockName: 
    101 ; CHECK: }
    102 ; CHECK: LocalSym {
    103 ; CHECK:   VarName: localF
    104 ; CHECK: }
    105 ; CHECK: BlockSym {
    106 ; CHECK:   Kind: S_BLOCK32 {{.*}}
    107 ; CHECK:   BlockName: 
    108 ; CHECK: }
    109 ; CHECK: LocalSym {
    110 ; CHECK:   VarName: localG
    111 ; CHECK: }
    112 ; CHECK: ScopeEndSym {
    113 ; CHECK:   Kind: S_END {{.*}}
    114 ; CHECK: }
    115 ; CHECK: ScopeEndSym {
    116 ; CHECK:   Kind: S_END {{.*}}
    117 ; CHECK: }
    118 ; CHECK: BlockSym {
    119 ; CHECK:   Kind: S_BLOCK32 {{.*}}
    120 ; CHECK:   BlockName: 
    121 ; CHECK: }
    122 ; CHECK: LocalSym {
    123 ; CHECK:   VarName: localH
    124 ; CHECK: }
    125 ; CHECK: ScopeEndSym {
    126 ; CHECK:   Kind: S_END {{.*}}
    127 ; CHECK: }
    128 ; CHECK: ProcEnd {
    129 ; CHECK: }
    130 ;
    131 ; ModuleID = 'lexicalblock.cxx'
    132 source_filename = "lexicalblock.cxx"
    133 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
    134 target triple = "i686-pc-windows-msvc"
    135 
    136 ; Function Attrs: norecurse nounwind
    137 define i32 @main(i32 %argc, i8** %argv) #0 !dbg !8 {
    138 entry:
    139   %retval = alloca i32, align 4
    140   %argv.addr = alloca i8**, align 4
    141   %argc.addr = alloca i32, align 4
    142   %localA = alloca i32, align 4
    143   %localB = alloca i32, align 4
    144   %localC = alloca i32, align 4
    145   %localD = alloca i32, align 4
    146   %localE = alloca i32, align 4
    147   %localF = alloca i32, align 4
    148   %localG = alloca i32, align 4
    149   %localH = alloca i32, align 4
    150   store i32 0, i32* %retval, align 4
    151   store i8** %argv, i8*** %argv.addr, align 4, !tbaa !37
    152   call void @llvm.dbg.declare(metadata i8*** %argv.addr, metadata !17, metadata !DIExpression()), !dbg !41
    153   store i32 %argc, i32* %argc.addr, align 4, !tbaa !42
    154   call void @llvm.dbg.declare(metadata i32* %argc.addr, metadata !18, metadata !DIExpression()), !dbg !41
    155   %0 = bitcast i32* %localA to i8*, !dbg !44
    156   call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) #4, !dbg !44
    157   call void @llvm.dbg.declare(metadata i32* %localA, metadata !19, metadata !DIExpression()), !dbg !44
    158   store i32 1, i32* %localA, align 4, !dbg !44, !tbaa !42
    159   %1 = bitcast i32* %localB to i8*, !dbg !45
    160   call void @llvm.lifetime.start.p0i8(i64 4, i8* %1) #4, !dbg !45
    161   call void @llvm.dbg.declare(metadata i32* %localB, metadata !20, metadata !DIExpression()), !dbg !45
    162   store i32 2, i32* %localB, align 4, !dbg !45, !tbaa !42
    163   %2 = load i32, i32* %argc.addr, align 4, !dbg !46, !tbaa !42
    164   %cmp = icmp ne i32 %2, 1, !dbg !46
    165   %conv = zext i1 %cmp to i32, !dbg !46
    166   %tobool = icmp ne i32 %conv, 0, !dbg !46
    167   br i1 %tobool, label %if.then, label %if.end, !dbg !46, !prof !47
    168 
    169 if.then:                                          ; preds = %entry
    170   %3 = bitcast i32* %localC to i8*, !dbg !48
    171   call void @llvm.lifetime.start.p0i8(i64 4, i8* %3) #4, !dbg !48
    172   call void @llvm.dbg.declare(metadata i32* %localC, metadata !22, metadata !DIExpression()), !dbg !48
    173   store i32 3, i32* %localC, align 4, !dbg !48, !tbaa !42
    174   %4 = bitcast i32* %localC to i8*, !dbg !49
    175   call void @llvm.lifetime.end.p0i8(i64 4, i8* %4) #4, !dbg !49
    176   br label %if.end, !dbg !49
    177 
    178 if.end:                                           ; preds = %if.then, %entry
    179   %5 = bitcast i32* %localB to i8*, !dbg !50
    180   call void @llvm.lifetime.end.p0i8(i64 4, i8* %5) #4, !dbg !50
    181   %6 = bitcast i32* %localD to i8*, !dbg !51
    182   call void @llvm.lifetime.start.p0i8(i64 4, i8* %6) #4, !dbg !51
    183   call void @llvm.dbg.declare(metadata i32* %localD, metadata !25, metadata !DIExpression()), !dbg !51
    184   store i32 4, i32* %localD, align 4, !dbg !51, !tbaa !42
    185   %7 = load i32, i32* %localD, align 4, !dbg !52, !tbaa !42
    186   store i32 %7, i32* %localA, align 4, !dbg !52, !tbaa !42
    187   %8 = bitcast i32* %localD to i8*, !dbg !53
    188   call void @llvm.lifetime.end.p0i8(i64 4, i8* %8) #4, !dbg !53
    189   %9 = bitcast i32* %localE to i8*, !dbg !54
    190   call void @llvm.lifetime.start.p0i8(i64 4, i8* %9) #4, !dbg !54
    191   call void @llvm.dbg.declare(metadata i32* %localE, metadata !27, metadata !DIExpression()), !dbg !54
    192   store i32 5, i32* %localE, align 4, !dbg !54, !tbaa !42
    193   %10 = load i32, i32* %localE, align 4, !dbg !55, !tbaa !42
    194   store i32 %10, i32* %localA, align 4, !dbg !55, !tbaa !42
    195   %11 = bitcast i32* %localE to i8*, !dbg !56
    196   call void @llvm.lifetime.end.p0i8(i64 4, i8* %11) #4, !dbg !56
    197   %12 = bitcast i32* %localF to i8*, !dbg !57
    198   call void @llvm.lifetime.start.p0i8(i64 4, i8* %12) #4, !dbg !57
    199   call void @llvm.dbg.declare(metadata i32* %localF, metadata !30, metadata !DIExpression()), !dbg !57
    200   store i32 6, i32* %localF, align 4, !dbg !57, !tbaa !42
    201   %13 = load i32, i32* %localF, align 4, !dbg !58, !tbaa !42
    202   store i32 %13, i32* %localA, align 4, !dbg !58, !tbaa !42
    203   %14 = bitcast i32* %localG to i8*, !dbg !59
    204   call void @llvm.lifetime.start.p0i8(i64 4, i8* %14) #4, !dbg !59
    205   call void @llvm.dbg.declare(metadata i32* %localG, metadata !32, metadata !DIExpression()), !dbg !59
    206   store i32 7, i32* %localG, align 4, !dbg !59, !tbaa !42
    207   %15 = load i32, i32* %localG, align 4, !dbg !60, !tbaa !42
    208   store i32 %15, i32* %localA, align 4, !dbg !60, !tbaa !42
    209   %16 = bitcast i32* %localG to i8*, !dbg !61
    210   call void @llvm.lifetime.end.p0i8(i64 4, i8* %16) #4, !dbg !61
    211   %17 = bitcast i32* %localF to i8*, !dbg !62
    212   call void @llvm.lifetime.end.p0i8(i64 4, i8* %17) #4, !dbg !62
    213   %18 = load i32, i32* %localA, align 4, !dbg !63, !tbaa !42
    214   %cmp1 = icmp eq i32 %18, 7, !dbg !63
    215   br i1 %cmp1, label %if.then2, label %if.end3, !dbg !63
    216 
    217 if.then2:                                         ; preds = %if.end
    218   %19 = bitcast i32* %localH to i8*, !dbg !64
    219   call void @llvm.lifetime.start.p0i8(i64 4, i8* %19) #4, !dbg !64
    220   call void @llvm.dbg.declare(metadata i32* %localH, metadata !34, metadata !DIExpression()), !dbg !64
    221   store i32 8, i32* %localH, align 4, !dbg !64, !tbaa !42
    222   %20 = load i32, i32* %localH, align 4, !dbg !65, !tbaa !42
    223   store i32 %20, i32* %localA, align 4, !dbg !65, !tbaa !42
    224   %21 = bitcast i32* %localH to i8*, !dbg !66
    225   call void @llvm.lifetime.end.p0i8(i64 4, i8* %21) #4, !dbg !66
    226   br label %if.end3, !dbg !66
    227 
    228 if.end3:                                          ; preds = %if.then2, %if.end
    229   %22 = load i32, i32* %localA, align 4, !dbg !67, !tbaa !42
    230   %cmp4 = icmp ne i32 %22, 8, !dbg !67
    231   %23 = zext i1 %cmp4 to i64, !dbg !67
    232   %cond = select i1 %cmp4, i32 -1, i32 0, !dbg !67
    233   %24 = bitcast i32* %localA to i8*, !dbg !68
    234   call void @llvm.lifetime.end.p0i8(i64 4, i8* %24) #4, !dbg !68
    235   ret i32 %cond, !dbg !67
    236 }
    237 
    238 ; Function Attrs: nounwind readnone speculatable
    239 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
    240 
    241 ; Function Attrs: argmemonly nounwind
    242 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #2
    243 
    244 ; Function Attrs: nounwind readnone
    245 declare i32 @llvm.expect.i32(i32, i32) #3
    246 
    247 ; Function Attrs: argmemonly nounwind
    248 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #2
    249 
    250 attributes #0 = { norecurse nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-features"="+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
    251 attributes #1 = { nounwind readnone speculatable }
    252 attributes #2 = { argmemonly nounwind }
    253 attributes #3 = { nounwind readnone }
    254 attributes #4 = { nounwind }
    255 
    256 !llvm.dbg.cu = !{!0}
    257 !llvm.module.flags = !{!3, !4, !5, !6}
    258 !llvm.ident = !{!7}
    259 
    260 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 7.0.0 (trunk)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
    261 !1 = !DIFile(filename: "<stdin>", directory: "C:/path/to/directory", checksumkind: CSK_MD5, checksum: "169b810b4f895de9a9e19d8d0634af5d")
    262 !2 = !{}
    263 !3 = !{i32 1, !"NumRegisterParameters", i32 0}
    264 !4 = !{i32 2, !"CodeView", i32 1}
    265 !5 = !{i32 2, !"Debug Info Version", i32 3}
    266 !6 = !{i32 1, !"wchar_size", i32 2}
    267 !7 = !{!"clang version 7.0.0 (trunk)"}
    268 !8 = distinct !DISubprogram(name: "main", scope: !9, file: !9, line: 1, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !16)
    269 !9 = !DIFile(filename: "lexicalblock.cxx", directory: "C:/path/to/directory", checksumkind: CSK_MD5, checksum: "169b810b4f895de9a9e19d8d0634af5d")
    270 !10 = !DISubroutineType(types: !11)
    271 !11 = !{!12, !12, !13}
    272 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
    273 !13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 32)
    274 !14 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 32)
    275 !15 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
    276 !16 = !{!17, !18, !19, !20, !22, !25, !27, !30, !32, !34}
    277 !17 = !DILocalVariable(name: "argv", arg: 2, scope: !8, file: !9, line: 1, type: !13)
    278 !18 = !DILocalVariable(name: "argc", arg: 1, scope: !8, file: !9, line: 1, type: !12)
    279 !19 = !DILocalVariable(name: "localA", scope: !8, file: !9, line: 2, type: !12)
    280 !20 = !DILocalVariable(name: "localB", scope: !21, file: !9, line: 5, type: !12)
    281 !21 = distinct !DILexicalBlock(scope: !8, file: !9, line: 4)
    282 !22 = !DILocalVariable(name: "localC", scope: !23, file: !9, line: 8, type: !12)
    283 !23 = distinct !DILexicalBlock(scope: !24, file: !9, line: 7)
    284 !24 = distinct !DILexicalBlock(scope: !21, file: !9, line: 7)
    285 !25 = !DILocalVariable(name: "localD", scope: !26, file: !9, line: 13, type: !12)
    286 !26 = distinct !DILexicalBlock(scope: !8, file: !9, line: 12)
    287 !27 = !DILocalVariable(name: "localE", scope: !28, file: !9, line: 19, type: !12)
    288 !28 = distinct !DILexicalBlock(scope: !29, file: !9, line: 18)
    289 !29 = distinct !DILexicalBlock(scope: !8, file: !9, line: 17)
    290 !30 = !DILocalVariable(name: "localF", scope: !31, file: !9, line: 25, type: !12)
    291 !31 = distinct !DILexicalBlock(scope: !8, file: !9, line: 24)
    292 !32 = !DILocalVariable(name: "localG", scope: !33, file: !9, line: 29, type: !12)
    293 !33 = distinct !DILexicalBlock(scope: !31, file: !9, line: 28)
    294 !34 = !DILocalVariable(name: "localH", scope: !35, file: !9, line: 35, type: !12)
    295 !35 = distinct !DILexicalBlock(scope: !36, file: !9, line: 34)
    296 !36 = distinct !DILexicalBlock(scope: !8, file: !9, line: 34)
    297 !37 = !{!38, !38, i64 0}
    298 !38 = !{!"any pointer", !39, i64 0}
    299 !39 = !{!"omnipotent char", !40, i64 0}
    300 !40 = !{!"Simple C++ TBAA"}
    301 !41 = !DILocation(line: 1, scope: !8)
    302 !42 = !{!43, !43, i64 0}
    303 !43 = !{!"int", !39, i64 0}
    304 !44 = !DILocation(line: 2, scope: !8)
    305 !45 = !DILocation(line: 5, scope: !21)
    306 !46 = !DILocation(line: 7, scope: !21)
    307 !47 = !{!"branch_weights", i32 1, i32 2000}
    308 !48 = !DILocation(line: 8, scope: !23)
    309 !49 = !DILocation(line: 9, scope: !23)
    310 !50 = !DILocation(line: 10, scope: !21)
    311 !51 = !DILocation(line: 13, scope: !26)
    312 !52 = !DILocation(line: 14, scope: !26)
    313 !53 = !DILocation(line: 15, scope: !26)
    314 !54 = !DILocation(line: 19, scope: !28)
    315 !55 = !DILocation(line: 20, scope: !28)
    316 !56 = !DILocation(line: 21, scope: !28)
    317 !57 = !DILocation(line: 25, scope: !31)
    318 !58 = !DILocation(line: 26, scope: !31)
    319 !59 = !DILocation(line: 29, scope: !33)
    320 !60 = !DILocation(line: 30, scope: !33)
    321 !61 = !DILocation(line: 31, scope: !33)
    322 !62 = !DILocation(line: 32, scope: !31)
    323 !63 = !DILocation(line: 34, scope: !8)
    324 !64 = !DILocation(line: 35, scope: !35)
    325 !65 = !DILocation(line: 36, scope: !35)
    326 !66 = !DILocation(line: 37, scope: !35)
    327 !67 = !DILocation(line: 39, scope: !8)
    328 !68 = !DILocation(line: 40, scope: !8)
    329