blob: 624f30416e0fe749fb05ca277bfc629af35be8ed [file] [log] [blame]
Paul Robinson383c5c22017-02-06 22:19:04 +00001; RUN: opt -instcombine -S < %s | FileCheck %s
2;
3; Generated with:
4;
5; clang -S -gmlt -emit-llvm test.c -o 1.ll
6; opt -sroa -S 1.ll -o test.ll
7;
8; extern int bar(int i);
9; extern int bar2(int i);
10;
11; int foo(int a, int *d) {
12; if(a) {
13; *d = bar(a);
14; } else {
15; *d = bar2(a);
16; }
17;
18; return a;
19; }
20;
21; CHECK: define {{.*}}@foo
22; CHECK: if.end:
23; CHECK-NEXT: %storemerge = phi
24; This final check is the "real" test, verify no !dbg on the store.
25; CHECK-NEXT: store i32 %storemerge{{.*}}, align 4{{$}}
26;
27; ModuleID = 'test1.ll'
28source_filename = "test.c"
29target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
30target triple = "x86_64-unknown-linux-gnu"
31
32; Function Attrs: noinline nounwind uwtable
33define i32 @foo(i32 %a, i32* %d) !dbg !6 {
34entry:
35 %tobool = icmp ne i32 %a, 0, !dbg !8
36 br i1 %tobool, label %if.then, label %if.else, !dbg !8
37
38if.then: ; preds = %entry
39 %call = call i32 @bar(i32 %a), !dbg !9
40 store i32 %call, i32* %d, align 4, !dbg !10
41 br label %if.end, !dbg !11
42
43if.else: ; preds = %entry
44 %call1 = call i32 @bar2(i32 %a), !dbg !12
45 store i32 %call1, i32* %d, align 4, !dbg !13
46 br label %if.end
47
48if.end: ; preds = %if.else, %if.then
49 ret i32 %a, !dbg !14
50}
51
52declare i32 @bar(i32)
53
54declare i32 @bar2(i32)
55
56!llvm.dbg.cu = !{!0}
57!llvm.module.flags = !{!3, !4}
58
59!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
60!1 = !DIFile(filename: "test.c", directory: "/home/probinson/projects/scratch")
61!2 = !{}
62!3 = !{i32 2, !"Dwarf Version", i32 4}
63!4 = !{i32 2, !"Debug Info Version", i32 3}
64!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !7, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
65!7 = !DISubroutineType(types: !2)
66!8 = !DILocation(line: 5, column: 6, scope: !6)
67!9 = !DILocation(line: 6, column: 12, scope: !6)
68!10 = !DILocation(line: 6, column: 10, scope: !6)
69!11 = !DILocation(line: 7, column: 3, scope: !6)
70!12 = !DILocation(line: 8, column: 12, scope: !6)
71!13 = !DILocation(line: 8, column: 10, scope: !6)
72!14 = !DILocation(line: 10, column: 3, scope: !6)