1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 declare void @llvm.dbg.declare(metadata, metadata, metadata)
5 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture)
6 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture)
7 declare void @foo(i8* nocapture, i8* nocapture)
9 define void @bar(i1 %flag) #0 !dbg !4 {
12 ; CHECK-NEXT: [[TEXT:%.*]] = alloca [1 x i8], align 1
13 ; CHECK-NEXT: [[BUFF:%.*]] = alloca [1 x i8], align 1
14 ; CHECK-NEXT: [[TMP0:%.*]] = getelementptr inbounds [1 x i8], [1 x i8]* [[TEXT]], i64 0, i64 0
15 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [1 x i8], [1 x i8]* [[BUFF]], i64 0, i64 0
16 ; CHECK-NEXT: br i1 [[FLAG:%.*]], label [[IF:%.*]], label [[ELSE:%.*]]
18 ; CHECK-NEXT: br label [[BB2:%.*]]
20 ; CHECK-NEXT: br label [[BB3:%.*]]
22 ; CHECK-NEXT: call void @llvm.dbg.declare(metadata [1 x i8]* [[TEXT]], [[META16:metadata !.*]], metadata !DIExpression()), [[DBG24:!dbg !.*]]
23 ; CHECK-NEXT: br label [[FIN:%.*]]
25 ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 1, i8* [[TMP0]])
26 ; CHECK-NEXT: call void @llvm.lifetime.start.p0i8(i64 1, i8* [[TMP1]])
27 ; CHECK-NEXT: call void @foo(i8* [[TMP1]], i8* [[TMP0]])
28 ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 1, i8* [[TMP1]])
29 ; CHECK-NEXT: call void @llvm.lifetime.end.p0i8(i64 1, i8* [[TMP0]])
30 ; CHECK-NEXT: br label [[FIN]]
32 ; CHECK-NEXT: ret void
35 %text = alloca [1 x i8], align 1
36 %buff = alloca [1 x i8], align 1
37 %0 = getelementptr inbounds [1 x i8], [1 x i8]* %text, i64 0, i64 0
38 %1 = getelementptr inbounds [1 x i8], [1 x i8]* %buff, i64 0, i64 0
39 br i1 %flag, label %if, label %else
42 call void @llvm.lifetime.start.p0i8(i64 1, i8* %0)
43 call void @llvm.lifetime.start.p0i8(i64 1, i8* %1)
44 call void @llvm.lifetime.end.p0i8(i64 1, i8* %1)
45 call void @llvm.lifetime.end.p0i8(i64 1, i8* %0)
49 call void @llvm.lifetime.start.p0i8(i64 1, i8* %0)
50 call void @llvm.lifetime.start.p0i8(i64 1, i8* %1)
51 call void @llvm.lifetime.end.p0i8(i64 1, i8* %0)
52 call void @llvm.lifetime.end.p0i8(i64 1, i8* %1)
56 call void @llvm.lifetime.start.p0i8(i64 1, i8* %0)
57 call void @llvm.dbg.declare(metadata [1 x i8]* %text, metadata !14, metadata !25), !dbg !26
58 call void @llvm.lifetime.end.p0i8(i64 1, i8* %0)
62 call void @llvm.lifetime.start.p0i8(i64 1, i8* %0)
63 call void @llvm.lifetime.start.p0i8(i64 1, i8* %1)
64 call void @foo(i8* %1, i8* %0)
65 call void @llvm.lifetime.end.p0i8(i64 1, i8* %1)
66 call void @llvm.lifetime.end.p0i8(i64 1, i8* %0)
73 attributes #0 = { null_pointer_is_valid }
76 !llvm.module.flags = !{!22, !23}
79 !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)
80 !1 = !DIFile(filename: "test.cpp", directory: "/home/user")
82 !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)
83 !5 = !DISubroutineType(types: !6)
85 !7 = !DIBasicType(name: "bool", size: 8, align: 8, encoding: DW_ATE_boolean)
86 !8 = !{!9, !11, !12, !14, !21}
87 !9 = !DILocalVariable(name: "Size", arg: 1, scope: !4, file: !1, line: 2, type: !10)
88 !10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
89 !11 = !DILocalVariable(name: "flag", arg: 2, scope: !4, file: !1, line: 2, type: !7)
90 !12 = !DILocalVariable(name: "i", scope: !13, file: !1, line: 3, type: !10)
91 !13 = distinct !DILexicalBlock(scope: !4, file: !1, line: 3, column: 3)
92 !14 = !DILocalVariable(name: "text", scope: !15, file: !1, line: 4, type: !17)
93 !15 = distinct !DILexicalBlock(scope: !16, file: !1, line: 3, column: 30)
94 !16 = distinct !DILexicalBlock(scope: !13, file: !1, line: 3, column: 3)
95 !17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, size: 8, align: 8, elements: !19)
96 !18 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
98 !20 = !DISubrange(count: 1)
99 !21 = !DILocalVariable(name: "buff", scope: !15, file: !1, line: 5, type: !17)
100 !22 = !{i32 2, !"Dwarf Version", i32 4}
101 !23 = !{i32 2, !"Debug Info Version", i32 3}
102 !24 = !{!"clang version 3.8.0 (trunk 248826) (llvm/trunk 248827)"}
103 !25 = !DIExpression()
104 !26 = !DILocation(line: 4, column: 10, scope: !15)