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