1 ; RUN: opt -mem2reg -S < %s | FileCheck %s
3 ; ModuleID = 'newvars.c'
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 ; Function Attrs: nounwind uwtable
9 define i32 @if_else(i32 %cond, i32 %a, i32 %b) !dbg !8 {
11 %x = alloca i32, align 4
12 call void @llvm.dbg.addr(metadata i32* %x, metadata !16, metadata !DIExpression()), !dbg !26
13 store i32 %a, i32* %x, align 4, !dbg !26, !tbaa !17
14 %tobool = icmp ne i32 %cond, 0, !dbg !28
15 br i1 %tobool, label %if.then, label %if.else, !dbg !30
17 if.then: ; preds = %entry
18 store i32 0, i32* %x, align 4, !dbg !31, !tbaa !17
19 br label %if.end, !dbg !33
21 if.else: ; preds = %entry
22 store i32 %b, i32* %x, align 4, !dbg !36, !tbaa !17
25 if.end: ; preds = %if.else, %if.then
26 %rv = load i32, i32* %x, align 4, !dbg !37, !tbaa !17
30 ; CHECK-LABEL: define i32 @if_else({{.*}})
32 ; CHECK-NOT: alloca i32
33 ; CHECK: call void @llvm.dbg.value(metadata i32 %a, metadata ![[X_LOCAL:[0-9]+]], metadata !DIExpression())
34 ; CHECK: if.then: ; preds = %entry
35 ; CHECK: call void @llvm.dbg.value(metadata i32 0, metadata ![[X_LOCAL]], metadata !DIExpression())
36 ; CHECK: if.else: ; preds = %entry
37 ; CHECK: call void @llvm.dbg.value(metadata i32 %b, metadata ![[X_LOCAL]], metadata !DIExpression())
38 ; CHECK: if.end: ; preds = %if.else, %if.then
39 ; CHECK: %[[PHI:[^ ]*]] = phi i32 [ 0, %if.then ], [ %b, %if.else ]
40 ; CHECK: call void @llvm.dbg.value(metadata i32 %[[PHI]], metadata ![[X_LOCAL]], metadata !DIExpression())
43 ; CHECK: ![[X_LOCAL]] = !DILocalVariable(name: "x", {{.*}})
45 ; Function Attrs: nounwind readnone speculatable
46 declare void @llvm.dbg.declare(metadata, metadata, metadata)
47 declare void @llvm.dbg.addr(metadata, metadata, metadata)
50 !llvm.module.flags = !{!3, !4, !5, !6}
53 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
54 !1 = !DIFile(filename: "newvars.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild")
56 !3 = !{i32 2, !"Dwarf Version", i32 4}
57 !4 = !{i32 2, !"Debug Info Version", i32 3}
58 !5 = !{i32 1, !"wchar_size", i32 2}
59 !6 = !{i32 7, !"PIC Level", i32 2}
60 !7 = !{!"clang version 6.0.0 "}
61 !8 = distinct !DISubprogram(name: "if_else", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !12)
62 !9 = !DISubroutineType(types: !10)
63 !10 = !{!11, !11, !11, !11}
64 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
65 !12 = !{!13, !14, !15, !16}
66 !13 = !DILocalVariable(name: "b", arg: 3, scope: !8, file: !1, line: 1, type: !11)
67 !14 = !DILocalVariable(name: "a", arg: 2, scope: !8, file: !1, line: 1, type: !11)
68 !15 = !DILocalVariable(name: "cond", arg: 1, scope: !8, file: !1, line: 1, type: !11)
69 !16 = !DILocalVariable(name: "x", scope: !8, file: !1, line: 2, type: !11)
70 !17 = !{!18, !18, i64 0}
71 !18 = !{!"int", !19, i64 0}
72 !19 = !{!"omnipotent char", !20, i64 0}
73 !20 = !{!"Simple C/C++ TBAA"}
74 !22 = !DILocation(line: 1, column: 34, scope: !8)
75 !23 = !DILocation(line: 1, column: 27, scope: !8)
76 !24 = !DILocation(line: 1, column: 17, scope: !8)
77 !25 = !DILocation(line: 2, column: 3, scope: !8)
78 !26 = !DILocation(line: 2, column: 7, scope: !8)
79 !27 = !DILocation(line: 2, column: 11, scope: !8)
80 !28 = !DILocation(line: 3, column: 7, scope: !29)
81 !29 = distinct !DILexicalBlock(scope: !8, file: !1, line: 3, column: 7)
82 !30 = !DILocation(line: 3, column: 7, scope: !8)
83 !31 = !DILocation(line: 4, column: 7, scope: !32)
84 !32 = distinct !DILexicalBlock(scope: !29, file: !1, line: 3, column: 13)
85 !33 = !DILocation(line: 5, column: 3, scope: !32)
86 !34 = !DILocation(line: 6, column: 9, scope: !35)
87 !35 = distinct !DILexicalBlock(scope: !29, file: !1, line: 5, column: 10)
88 !36 = !DILocation(line: 6, column: 7, scope: !35)
89 !37 = !DILocation(line: 8, column: 10, scope: !8)
90 !38 = !DILocation(line: 9, column: 1, scope: !8)
91 !39 = !DILocation(line: 8, column: 3, scope: !8)