1 ; RUN: opt -use-dbg-addr -sroa -S < %s | FileCheck %s
4 source_filename = "newvars.c"
5 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-pc-windows-msvc19.0.24215"
8 %struct.Pair = type { i32, i32 }
10 @pair = internal global %struct.Pair zeroinitializer
12 ; Function Attrs: nounwind uwtable
13 define void @if_else(i32 %cond, i32 %a, i32 %b) !dbg !8 {
15 %p = alloca %struct.Pair, align 4
16 %0 = bitcast %struct.Pair* %p to i8*, !dbg !25
17 call void @llvm.dbg.addr(metadata %struct.Pair* %p, metadata !20, metadata !DIExpression()), !dbg !26
18 %x = getelementptr inbounds %struct.Pair, %struct.Pair* %p, i32 0, i32 0, !dbg !27
19 store i32 %a, i32* %x, align 4, !dbg !28
20 %y = getelementptr inbounds %struct.Pair, %struct.Pair* %p, i32 0, i32 1, !dbg !34
21 store i32 %b, i32* %y, align 4, !dbg !35
22 %tobool = icmp ne i32 %cond, 0, !dbg !37
23 br i1 %tobool, label %if.then, label %if.else, !dbg !39
25 if.then: ; preds = %entry
26 %x1 = getelementptr inbounds %struct.Pair, %struct.Pair* %p, i32 0, i32 0, !dbg !40
27 store i32 0, i32* %x1, align 4, !dbg !42
28 %y2 = getelementptr inbounds %struct.Pair, %struct.Pair* %p, i32 0, i32 1, !dbg !43
29 store i32 %a, i32* %y2, align 4, !dbg !44
30 br label %if.end, !dbg !45
32 if.else: ; preds = %entry
33 %x3 = getelementptr inbounds %struct.Pair, %struct.Pair* %p, i32 0, i32 0, !dbg !46
34 store i32 %b, i32* %x3, align 4, !dbg !48
35 %y4 = getelementptr inbounds %struct.Pair, %struct.Pair* %p, i32 0, i32 1, !dbg !49
36 store i32 0, i32* %y4, align 4, !dbg !50
39 if.end: ; preds = %if.else, %if.then
40 %1 = bitcast %struct.Pair* %p to i8*, !dbg !51
41 %2 = bitcast %struct.Pair* @pair to i8*, !dbg !51
42 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %2, i8* align 4 %1, i64 8, i1 false), !dbg !51
46 ; CHECK-LABEL: define void @if_else(i32 %cond, i32 %a, i32 %b)
48 ; CHECK: call void @llvm.dbg.value(metadata i32 %a, metadata ![[PVAR:[0-9]+]], metadata ![[XFRAG:DIExpression\(DW_OP_LLVM_fragment, 0, 32\)]])
49 ; CHECK: call void @llvm.dbg.value(metadata i32 %b, metadata ![[PVAR]], metadata ![[YFRAG:DIExpression\(DW_OP_LLVM_fragment, 32, 32\)]])
51 ; CHECK: call void @llvm.dbg.value(metadata i32 0, metadata ![[PVAR]], metadata ![[XFRAG]])
52 ; CHECK: call void @llvm.dbg.value(metadata i32 %a, metadata ![[PVAR]], metadata ![[YFRAG]])
54 ; CHECK: call void @llvm.dbg.value(metadata i32 %b, metadata ![[PVAR]], metadata ![[XFRAG]])
55 ; CHECK: call void @llvm.dbg.value(metadata i32 0, metadata ![[PVAR]], metadata ![[YFRAG]])
57 ; CHECK: %p.sroa.4.0 = phi i32 [ %a, %if.then ], [ 0, %if.else ]
58 ; CHECK: %p.sroa.0.0 = phi i32 [ 0, %if.then ], [ %b, %if.else ]
59 ; CHECK: call void @llvm.dbg.value(metadata i32 %p.sroa.0.0, metadata ![[PVAR]], metadata ![[XFRAG]])
60 ; CHECK: call void @llvm.dbg.value(metadata i32 %p.sroa.4.0, metadata ![[PVAR]], metadata ![[YFRAG]])
62 ; CHECK: ![[PVAR]] = !DILocalVariable(name: "p", {{.*}})
64 ; Function Attrs: argmemonly nounwind
65 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1) #2
67 ; Function Attrs: nounwind readnone speculatable
68 declare void @llvm.dbg.addr(metadata, metadata, metadata)
71 !llvm.module.flags = !{!3, !4, !5, !6}
74 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
75 !1 = !DIFile(filename: "newvars.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild")
77 !3 = !{i32 2, !"Dwarf Version", i32 4}
78 !4 = !{i32 2, !"Debug Info Version", i32 3}
79 !5 = !{i32 1, !"wchar_size", i32 2}
80 !6 = !{i32 7, !"PIC Level", i32 2}
81 !7 = !{!"clang version 6.0.0 "}
82 !8 = distinct !DISubprogram(name: "if_else", scope: !1, file: !1, line: 2, type: !9, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !16)
83 !9 = !DISubroutineType(types: !10)
84 !10 = !{!11, !14, !14, !14}
85 !11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Pair", file: !1, line: 1, size: 64, elements: !12)
87 !13 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !11, file: !1, line: 1, baseType: !14, size: 32)
88 !14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
89 !15 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !11, file: !1, line: 1, baseType: !14, size: 32, offset: 32)
90 !16 = !{!17, !18, !19, !20}
91 !17 = !DILocalVariable(name: "b", arg: 3, scope: !8, file: !1, line: 2, type: !14)
92 !18 = !DILocalVariable(name: "a", arg: 2, scope: !8, file: !1, line: 2, type: !14)
93 !19 = !DILocalVariable(name: "cond", arg: 1, scope: !8, file: !1, line: 2, type: !14)
94 !20 = !DILocalVariable(name: "p", scope: !8, file: !1, line: 3, type: !11)
95 !22 = !DILocation(line: 2, column: 42, scope: !8)
96 !23 = !DILocation(line: 2, column: 35, scope: !8)
97 !24 = !DILocation(line: 2, column: 25, scope: !8)
98 !25 = !DILocation(line: 3, column: 3, scope: !8)
99 !26 = !DILocation(line: 3, column: 15, scope: !8)
100 !27 = !DILocation(line: 4, column: 5, scope: !8)
101 !28 = !DILocation(line: 4, column: 7, scope: !8)
102 !29 = !{!30, !31, i64 0}
103 !30 = !{!"Pair", !31, i64 0, !31, i64 4}
104 !31 = !{!"int", !32, i64 0}
105 !32 = !{!"omnipotent char", !33, i64 0}
106 !33 = !{!"Simple C/C++ TBAA"}
107 !34 = !DILocation(line: 5, column: 5, scope: !8)
108 !35 = !DILocation(line: 5, column: 7, scope: !8)
109 !36 = !{!30, !31, i64 4}
110 !37 = !DILocation(line: 6, column: 7, scope: !38)
111 !38 = distinct !DILexicalBlock(scope: !8, file: !1, line: 6, column: 7)
112 !39 = !DILocation(line: 6, column: 7, scope: !8)
113 !40 = !DILocation(line: 7, column: 7, scope: !41)
114 !41 = distinct !DILexicalBlock(scope: !38, file: !1, line: 6, column: 13)
115 !42 = !DILocation(line: 7, column: 9, scope: !41)
116 !43 = !DILocation(line: 8, column: 7, scope: !41)
117 !44 = !DILocation(line: 8, column: 9, scope: !41)
118 !45 = !DILocation(line: 9, column: 3, scope: !41)
119 !46 = !DILocation(line: 10, column: 7, scope: !47)
120 !47 = distinct !DILexicalBlock(scope: !38, file: !1, line: 9, column: 10)
121 !48 = !DILocation(line: 10, column: 9, scope: !47)
122 !49 = !DILocation(line: 11, column: 7, scope: !47)
123 !50 = !DILocation(line: 11, column: 9, scope: !47)
124 !51 = !DILocation(line: 13, column: 10, scope: !8)
125 !52 = !{i64 0, i64 4, !53, i64 4, i64 4, !53}
126 !53 = !{!31, !31, i64 0}
127 !54 = !DILocation(line: 14, column: 1, scope: !8)