1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -passes=instcombine -S | FileCheck %s 3; RUN: opt --try-experimental-debuginfo-iterators < %s -passes=instcombine -S | FileCheck %s 4 5declare void @llvm.dbg.declare(metadata, metadata, metadata) 6declare void @llvm.lifetime.start.p0(i64, ptr nocapture) 7declare void @llvm.lifetime.end.p0(i64, ptr nocapture) 8declare void @foo(ptr nocapture, ptr nocapture) 9 10define void @bar(i1 %flag) !dbg !4 { 11; CHECK-LABEL: @bar( 12; CHECK-NEXT: entry: 13; CHECK-NEXT: [[TEXT:%.*]] = alloca [1 x i8], align 1 14; CHECK-NEXT: [[BUFF:%.*]] = alloca [1 x i8], align 1 15; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[IF:%.*]], label [[ELSE:%.*]] 16; CHECK: if: 17; CHECK-NEXT: br label [[BB2:%.*]] 18; CHECK: bb2: 19; CHECK-NEXT: br label [[BB3:%.*]] 20; CHECK: bb3: 21; CHECK-NEXT: #dbg_declare(ptr [[TEXT]], [[META16:![0-9]+]], !DIExpression(), [[META24:![0-9]+]]) 22; CHECK-NEXT: br label [[FIN:%.*]] 23; CHECK: else: 24; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 1, ptr nonnull [[TEXT]]) 25; CHECK-NEXT: call void @llvm.lifetime.start.p0(i64 1, ptr nonnull [[BUFF]]) 26; CHECK-NEXT: call void @foo(ptr nonnull [[BUFF]], ptr nonnull [[TEXT]]) 27; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1, ptr nonnull [[BUFF]]) 28; CHECK-NEXT: call void @llvm.lifetime.end.p0(i64 1, ptr nonnull [[TEXT]]) 29; CHECK-NEXT: br label [[FIN]] 30; CHECK: fin: 31; CHECK-NEXT: ret void 32; 33entry: 34 %text = alloca [1 x i8], align 1 35 %buff = alloca [1 x i8], align 1 36 br i1 %flag, label %if, label %else 37 38if: 39 call void @llvm.lifetime.start.p0(i64 1, ptr %text) 40 call void @llvm.lifetime.start.p0(i64 1, ptr %buff) 41 call void @llvm.lifetime.end.p0(i64 1, ptr %buff) 42 call void @llvm.lifetime.end.p0(i64 1, ptr %text) 43 br label %bb2 44 45bb2: 46 call void @llvm.lifetime.start.p0(i64 1, ptr %text) 47 call void @llvm.lifetime.start.p0(i64 1, ptr %buff) 48 call void @llvm.lifetime.end.p0(i64 1, ptr %text) 49 call void @llvm.lifetime.end.p0(i64 1, ptr %buff) 50 br label %bb3 51 52bb3: 53 call void @llvm.lifetime.start.p0(i64 1, ptr %text) 54 call void @llvm.dbg.declare(metadata ptr %text, metadata !14, metadata !25), !dbg !26 55 call void @llvm.lifetime.end.p0(i64 1, ptr %text) 56 br label %fin 57 58else: 59 call void @llvm.lifetime.start.p0(i64 1, ptr %text) 60 call void @llvm.lifetime.start.p0(i64 1, ptr %buff) 61 call void @foo(ptr %buff, ptr %text) 62 call void @llvm.lifetime.end.p0(i64 1, ptr %buff) 63 call void @llvm.lifetime.end.p0(i64 1, ptr %text) 64 br label %fin 65 66fin: 67 ret void 68} 69 70!llvm.dbg.cu = !{!0} 71!llvm.module.flags = !{!22, !23} 72!llvm.ident = !{!24} 73 74!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) 75!1 = !DIFile(filename: "test.cpp", directory: "/home/user") 76!2 = !{} 77!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) 78!5 = !DISubroutineType(types: !6) 79!6 = !{null, !7} 80!7 = !DIBasicType(name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean) 81!8 = !{!9, !11, !12, !14, !21} 82!9 = !DILocalVariable(name: "Size", arg: 1, scope: !4, file: !1, line: 2, type: !10) 83!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 84!11 = !DILocalVariable(name: "flag", arg: 2, scope: !4, file: !1, line: 2, type: !7) 85!12 = !DILocalVariable(name: "i", scope: !13, file: !1, line: 3, type: !10) 86!13 = distinct !DILexicalBlock(scope: !4, file: !1, line: 3, column: 3) 87!14 = !DILocalVariable(name: "text", scope: !15, file: !1, line: 4, type: !17) 88!15 = distinct !DILexicalBlock(scope: !16, file: !1, line: 3, column: 30) 89!16 = distinct !DILexicalBlock(scope: !13, file: !1, line: 3, column: 3) 90!17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 8, align: 8, elements: !19) 91!18 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char) 92!19 = !{!20} 93!20 = !DISubrange(count: 1) 94!21 = !DILocalVariable(name: "buff", scope: !15, file: !1, line: 5, type: !17) 95!22 = !{i32 2, !"Dwarf Version", i32 4} 96!23 = !{i32 2, !"Debug Info Version", i32 3} 97!24 = !{!"clang version 3.8.0 (trunk 248826) (llvm/trunk 248827)"} 98!25 = !DIExpression() 99!26 = !DILocation(line: 4, column: 10, scope: !15) 100