blob: 3024a9a76a7e064cd1f099ebd352dca55890898f [file] [log] [blame]
JF Bastienf5aa1ca2015-08-28 16:49:09 +00001; RUN: opt -S -mergefunc < %s | FileCheck %s
2
3; There is a slight different in these two functions, in that the label values
4; are switched. They are thus not mergeable. This tests that block addresses
5; referring to blocks within each respective compared function are correctly
6; ordered.
7
8target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
9target triple = "x86_64-unknown-linux-gnu"
10
11; Function Attrs: nounwind uwtable
12define i32 @_Z1fi(i32 %i) #0 {
13; CHECK-LABEL: define i32 @_Z1fi
14; CHECK-NEXT: entry:
15; CHECK-NEXT: alloca
16entry:
17 %i.addr = alloca i32, align 4
18 %ret = alloca i32, align 4
19 %l = alloca i8*, align 8
20 store i32 %i, i32* %i.addr, align 4
21 store i32 0, i32* %ret, align 4
22; Right here, this is val_0, and later the if might assign val_1
23 store i8* blockaddress(@_Z1fi, %val_0), i8** %l, align 8
24 %0 = load i32, i32* %i.addr, align 4
25 %and = and i32 %0, 256
26 %cmp = icmp eq i32 %and, 0
27 br i1 %cmp, label %if.then, label %if.end
28
29if.then:
30 store i8* blockaddress(@_Z1fi, %val_1), i8** %l, align 8
31 br label %if.end
32
33if.end:
34 %1 = load i8*, i8** %l, align 8
35 br label %indirectgoto
36
37val_0:
38 store i32 12, i32* %ret, align 4
39 br label %end
40
41val_1:
42 store i32 42, i32* %ret, align 4
43 br label %end
44
45end:
46 %2 = load i32, i32* %ret, align 4
47 ret i32 %2
48
49indirectgoto:
50 %indirect.goto.dest = phi i8* [ %1, %if.end ]
51 indirectbr i8* %indirect.goto.dest, [label %val_0, label %val_1]
52}
53
54; Function Attrs: nounwind uwtable
55define i32 @_Z1gi(i32 %i) #0 {
56; CHECK-LABEL: define i32 @_Z1gi
57; CHECK-NEXT: entry:
58; CHECK-NEXT: alloca
59entry:
60 %i.addr = alloca i32, align 4
61 %ret = alloca i32, align 4
62 %l = alloca i8*, align 8
63 store i32 %i, i32* %i.addr, align 4
64 store i32 0, i32* %ret, align 4
65; This time, we store val_1 initially, and later the if might assign val_0
66 store i8* blockaddress(@_Z1gi, %val_1), i8** %l, align 8
67 %0 = load i32, i32* %i.addr, align 4
68 %and = and i32 %0, 256
69 %cmp = icmp eq i32 %and, 0
70 br i1 %cmp, label %if.then, label %if.end
71
72if.then:
73 store i8* blockaddress(@_Z1gi, %val_0), i8** %l, align 8
74 br label %if.end
75
76if.end:
77 %1 = load i8*, i8** %l, align 8
78 br label %indirectgoto
79
80val_0:
81 store i32 12, i32* %ret, align 4
82 br label %end
83
84val_1:
85 store i32 42, i32* %ret, align 4
86 br label %end
87
88end:
89 %2 = load i32, i32* %ret, align 4
90 ret i32 %2
91
92indirectgoto:
93 %indirect.goto.dest = phi i8* [ %1, %if.end ]
94 indirectbr i8* %indirect.goto.dest, [label %val_1, label %val_0]
95}
96