Home | History | Annotate | Download | only in InstCombine
      1 ; RUN: opt < %s -instcombine -S | FileCheck %s
      2 
      3 declare void @llvm.dbg.declare(metadata, metadata, metadata)
      4 declare void @llvm.lifetime.start(i64, i8* nocapture)
      5 declare void @llvm.lifetime.end(i64, i8* nocapture)
      6 declare void @foo(i8* nocapture, i8* nocapture)
      7 
      8 define void @bar(i1 %flag) !dbg !4 {
      9 entry:
     10 ; CHECK-LABEL: @bar(
     11 ; CHECK: %[[T:[^ ]+]] = getelementptr inbounds [1 x i8], [1 x i8]* %text
     12 ; CHECK: %[[B:[^ ]+]] = getelementptr inbounds [1 x i8], [1 x i8]* %buff
     13 ; CHECK: if:
     14 ; CHECK-NEXT: br label %bb2
     15 ; CHECK: bb2:
     16 ; CHECK-NEXT: br label %bb3
     17 ; CHECK: bb3:
     18 ; CHECK-NEXT: call void @llvm.dbg.declare
     19 ; CHECK-NEXT: br label %fin
     20 ; CHECK: call void @llvm.lifetime.start(i64 1, i8* %[[T]])
     21 ; CHECK-NEXT: call void @llvm.lifetime.start(i64 1, i8* %[[B]])
     22 ; CHECK-NEXT: call void @foo(i8* %[[B]], i8* %[[T]])
     23 ; CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* %[[B]])
     24 ; CHECK-NEXT: call void @llvm.lifetime.end(i64 1, i8* %[[T]])
     25   %text = alloca [1 x i8], align 1
     26   %buff = alloca [1 x i8], align 1
     27   %0 = getelementptr inbounds [1 x i8], [1 x i8]* %text, i64 0, i64 0
     28   %1 = getelementptr inbounds [1 x i8], [1 x i8]* %buff, i64 0, i64 0
     29   br i1 %flag, label %if, label %else
     30 
     31 if:
     32   call void @llvm.lifetime.start(i64 1, i8* %0)
     33   call void @llvm.lifetime.start(i64 1, i8* %1)
     34   call void @llvm.lifetime.end(i64 1, i8* %1)
     35   call void @llvm.lifetime.end(i64 1, i8* %0)
     36   br label %bb2
     37 
     38 bb2:
     39   call void @llvm.lifetime.start(i64 1, i8* %0)
     40   call void @llvm.lifetime.start(i64 1, i8* %1)
     41   call void @llvm.lifetime.end(i64 1, i8* %0)
     42   call void @llvm.lifetime.end(i64 1, i8* %1)
     43   br label %bb3
     44 
     45 bb3:
     46   call void @llvm.lifetime.start(i64 1, i8* %0)
     47   call void @llvm.dbg.declare(metadata [1 x i8]* %text, metadata !14, metadata !25), !dbg !26
     48   call void @llvm.lifetime.end(i64 1, i8* %0)
     49   br label %fin
     50 
     51 else:
     52   call void @llvm.lifetime.start(i64 1, i8* %0)
     53   call void @llvm.lifetime.start(i64 1, i8* %1)
     54   call void @foo(i8* %1, i8* %0)
     55   call void @llvm.lifetime.end(i64 1, i8* %1)
     56   call void @llvm.lifetime.end(i64 1, i8* %0)
     57   br  label %fin
     58 
     59 fin:
     60   ret void
     61 }
     62 
     63 !llvm.dbg.cu = !{!0}
     64 !llvm.module.flags = !{!22, !23}
     65 !llvm.ident = !{!24}
     66 
     67 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 248826) (llvm/trunk 248827)", isOptimized: true, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3)
     68 !1 = !DIFile(filename: "test.cpp", directory: "/home/user")
     69 !2 = !{}
     70 !3 = !{!4}
     71 !4 = distinct !DISubprogram(name: "bar", linkageName: "bar", scope: !1, file: !1, line: 2, type: !5, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, variables: !8)
     72 !5 = !DISubroutineType(types: !6)
     73 !6 = !{null, !7}
     74 !7 = !DIBasicType(name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)
     75 !8 = !{!9, !11, !12, !14, !21}
     76 !9 = !DILocalVariable(name: "Size", arg: 1, scope: !4, file: !1, line: 2, type: !10)
     77 !10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
     78 !11 = !DILocalVariable(name: "flag", arg: 2, scope: !4, file: !1, line: 2, type: !7)
     79 !12 = !DILocalVariable(name: "i", scope: !13, file: !1, line: 3, type: !10)
     80 !13 = distinct !DILexicalBlock(scope: !4, file: !1, line: 3, column: 3)
     81 !14 = !DILocalVariable(name: "text", scope: !15, file: !1, line: 4, type: !17)
     82 !15 = distinct !DILexicalBlock(scope: !16, file: !1, line: 3, column: 30)
     83 !16 = distinct !DILexicalBlock(scope: !13, file: !1, line: 3, column: 3)
     84 !17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 8, align: 8, elements: !19)
     85 !18 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
     86 !19 = !{!20}
     87 !20 = !DISubrange(count: 1)
     88 !21 = !DILocalVariable(name: "buff", scope: !15, file: !1, line: 5, type: !17)
     89 !22 = !{i32 2, !"Dwarf Version", i32 4}
     90 !23 = !{i32 2, !"Debug Info Version", i32 3}
     91 !24 = !{!"clang version 3.8.0 (trunk 248826) (llvm/trunk 248827)"}
     92 !25 = !DIExpression()
     93 !26 = !DILocation(line: 4, column: 10, scope: !15)
     94