1; RUN: opt < %s -instcombine -S | FileCheck %s 2 3declare void @llvm.dbg.declare(metadata, metadata, metadata) 4declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) 5declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) 6declare void @foo(i8* nocapture, i8* nocapture) 7 8define void @bar(i1 %flag) !dbg !4 { 9entry: 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.p0i8(i64 1, i8* nonnull %[[T]]) 21; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 1, i8* nonnull %[[B]]) 22; CHECK-NEXT: call void @foo(i8* nonnull %[[B]], i8* nonnull %[[T]]) 23; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %[[B]]) 24; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 1, i8* nonnull %[[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 31if: 32 call void @llvm.lifetime.start.p0i8(i64 1, i8* %0) 33 call void @llvm.lifetime.start.p0i8(i64 1, i8* %1) 34 call void @llvm.lifetime.end.p0i8(i64 1, i8* %1) 35 call void @llvm.lifetime.end.p0i8(i64 1, i8* %0) 36 br label %bb2 37 38bb2: 39 call void @llvm.lifetime.start.p0i8(i64 1, i8* %0) 40 call void @llvm.lifetime.start.p0i8(i64 1, i8* %1) 41 call void @llvm.lifetime.end.p0i8(i64 1, i8* %0) 42 call void @llvm.lifetime.end.p0i8(i64 1, i8* %1) 43 br label %bb3 44 45bb3: 46 call void @llvm.lifetime.start.p0i8(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.p0i8(i64 1, i8* %0) 49 br label %fin 50 51else: 52 call void @llvm.lifetime.start.p0i8(i64 1, i8* %0) 53 call void @llvm.lifetime.start.p0i8(i64 1, i8* %1) 54 call void @foo(i8* %1, i8* %0) 55 call void @llvm.lifetime.end.p0i8(i64 1, i8* %1) 56 call void @llvm.lifetime.end.p0i8(i64 1, i8* %0) 57 br label %fin 58 59fin: 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: FullDebug, enums: !2) 68!1 = !DIFile(filename: "test.cpp", directory: "/home/user") 69!2 = !{} 70!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, unit: !0, retainedNodes: !8) 71!5 = !DISubroutineType(types: !6) 72!6 = !{null, !7} 73!7 = !DIBasicType(name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean) 74!8 = !{!9, !11, !12, !14, !21} 75!9 = !DILocalVariable(name: "Size", arg: 1, scope: !4, file: !1, line: 2, type: !10) 76!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 77!11 = !DILocalVariable(name: "flag", arg: 2, scope: !4, file: !1, line: 2, type: !7) 78!12 = !DILocalVariable(name: "i", scope: !13, file: !1, line: 3, type: !10) 79!13 = distinct !DILexicalBlock(scope: !4, file: !1, line: 3, column: 3) 80!14 = !DILocalVariable(name: "text", scope: !15, file: !1, line: 4, type: !17) 81!15 = distinct !DILexicalBlock(scope: !16, file: !1, line: 3, column: 30) 82!16 = distinct !DILexicalBlock(scope: !13, file: !1, line: 3, column: 3) 83!17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 8, align: 8, elements: !19) 84!18 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) 85!19 = !{!20} 86!20 = !DISubrange(count: 1) 87!21 = !DILocalVariable(name: "buff", scope: !15, file: !1, line: 5, type: !17) 88!22 = !{i32 2, !"Dwarf Version", i32 4} 89!23 = !{i32 2, !"Debug Info Version", i32 3} 90!24 = !{!"clang version 3.8.0 (trunk 248826) (llvm/trunk 248827)"} 91!25 = !DIExpression() 92!26 = !DILocation(line: 4, column: 10, scope: !15) 93