1 ; RUN: opt -S -passes=mergefunc < %s | FileCheck %s
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
8 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
9 target triple = "x86_64-unknown-linux-gnu"
11 ; Function Attrs: nounwind uwtable
12 define i32 @_Z1fi(i32 %i) #0 {
13 ; CHECK-LABEL: define i32 @_Z1fi
17 %i.addr = alloca i32, align 4
18 %ret = alloca i32, align 4
19 %l = alloca ptr, align 8
20 store i32 %i, ptr %i.addr, align 4
21 store i32 0, ptr %ret, align 4
22 ; Right here, this is val_0, and later the if might assign val_1
23 store ptr blockaddress(@_Z1fi, %val_0), ptr %l, align 8
24 %0 = load i32, ptr %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
30 store ptr blockaddress(@_Z1fi, %val_1), ptr %l, align 8
34 %1 = load ptr, ptr %l, align 8
35 br label %indirectgoto
38 store i32 12, ptr %ret, align 4
42 store i32 42, ptr %ret, align 4
46 %2 = load i32, ptr %ret, align 4
50 %indirect.goto.dest = phi ptr [ %1, %if.end ]
51 indirectbr ptr %indirect.goto.dest, [label %val_0, label %val_1]
54 ; Function Attrs: nounwind uwtable
55 define i32 @_Z1gi(i32 %i) #0 {
56 ; CHECK-LABEL: define i32 @_Z1gi
60 %i.addr = alloca i32, align 4
61 %ret = alloca i32, align 4
62 %l = alloca ptr, align 8
63 store i32 %i, ptr %i.addr, align 4
64 store i32 0, ptr %ret, align 4
65 ; This time, we store val_1 initially, and later the if might assign val_0
66 store ptr blockaddress(@_Z1gi, %val_1), ptr %l, align 8
67 %0 = load i32, ptr %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
73 store ptr blockaddress(@_Z1gi, %val_0), ptr %l, align 8
77 %1 = load ptr, ptr %l, align 8
78 br label %indirectgoto
81 store i32 12, ptr %ret, align 4
85 store i32 42, ptr %ret, align 4
89 %2 = load i32, ptr %ret, align 4
93 %indirect.goto.dest = phi ptr [ %1, %if.end ]
94 indirectbr ptr %indirect.goto.dest, [label %val_1, label %val_0]