1; RUN: opt -S -mergefunc < %s | FileCheck %s
2
3; We should not merge these two functions, because the blocks are different.
4; This tests the handling of block addresses from different functions.
5; ModuleID = '<stdin>'
6target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
7target triple = "x86_64-unknown-linux-gnu"
8
9
10define internal i8* @Afunc(i32* %P) {
11; CHECK-LABEL: @Afunc
12; CHECK-NEXT: store
13; CHECK-NEXT: store
14; CHECK-NEXT: ret
15  store i32 1, i32* %P
16  store i32 3, i32* %P
17  ret i8* blockaddress(@_Z1fi, %if.then)
18}
19
20define internal i8* @Bfunc(i32* %P) {
21; CHECK-LABEL: @Bfunc
22; CHECK-NEXT: store
23; CHECK-NEXT: store
24; CHECK-NEXT: ret
25  store i32 1, i32* %P
26  store i32 3, i32* %P
27  ret i8* blockaddress(@_Z1fi, %if.then.2)
28}
29
30
31; Function Attrs: nounwind uwtable
32define i32 @_Z1fi(i32 %i) #0 {
33entry:
34  %retval = alloca i32, align 4
35  %i.addr = alloca i32, align 4
36  store i32 %i, i32* %i.addr, align 4
37  %0 = load i32, i32* %i.addr, align 4
38  %cmp = icmp eq i32 %0, 1
39  br i1 %cmp, label %if.then, label %if.end
40
41if.then:
42  store i32 3, i32* %retval
43  br label %return
44
45if.end:
46  %1 = load i32, i32* %i.addr, align 4
47  %cmp1 = icmp eq i32 %1, 3
48  br i1 %cmp1, label %if.then.2, label %if.end.3
49
50if.then.2:
51  store i32 56, i32* %retval
52  br label %return
53
54if.end.3:
55  store i32 0, i32* %retval
56  br label %return
57
58return:
59  %2 = load i32, i32* %retval
60  ret i32 %2
61}
62