1 ; RUN: opt -S -mergefunc < %s | FileCheck %s
2 ; RUN: opt -S -passes=mergefunc < %s | FileCheck %s
4 ; These two functions are identical. The basic block labels are the same, and
5 ; induce the same CFG. We are testing that block addresses within different
6 ; functions are compared by their value, and not based on order. Both functions
7 ; come from the same C-code, but in the first the two val_0/val_1 basic blocks
8 ; are in a different order (they were manually switched post-compilation).
10 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
11 target triple = "x86_64-unknown-linux-gnu"
13 define i32 @_Z1fi(i32 %i) #0 {
15 %i.addr = alloca i32, align 4
16 %ret = alloca i32, align 4
17 %l = alloca i8*, align 8
18 store i32 %i, i32* %i.addr, align 4
19 store i32 0, i32* %ret, align 4
20 store i8* blockaddress(@_Z1fi, %val_0), i8** %l, align 8
21 %0 = load i32, i32* %i.addr, align 4
22 %and = and i32 %0, 256
23 %cmp = icmp eq i32 %and, 0
24 br i1 %cmp, label %if.then, label %if.end
27 store i8* blockaddress(@_Z1fi, %val_1), i8** %l, align 8
31 %1 = load i8*, i8** %l, align 8
32 br label %indirectgoto
35 store i32 42, i32* %ret, align 4
39 store i32 12, i32* %ret, align 4
44 %2 = load i32, i32* %ret, align 4
48 %indirect.goto.dest = phi i8* [ %1, %if.end ]
49 indirectbr i8* %indirect.goto.dest, [label %val_0, label %val_1]
52 define i32 @_Z1gi(i32 %i) #0 {
53 ; CHECK-LABEL: define i32 @_Z1gi
54 ; CHECK-NEXT: tail call i32 @_Z1fi
57 %i.addr = alloca i32, align 4
58 %ret = alloca i32, align 4
59 %l = alloca i8*, align 8
60 store i32 %i, i32* %i.addr, align 4
61 store i32 0, i32* %ret, align 4
62 store i8* blockaddress(@_Z1gi, %val_0), i8** %l, align 8
63 %0 = load i32, i32* %i.addr, align 4
64 %and = and i32 %0, 256
65 %cmp = icmp eq i32 %and, 0
66 br i1 %cmp, label %if.then, label %if.end
69 store i8* blockaddress(@_Z1gi, %val_1), i8** %l, align 8
73 %1 = load i8*, i8** %l, align 8
74 br label %indirectgoto
77 store i32 12, i32* %ret, align 4
81 store i32 42, i32* %ret, align 4
85 %2 = load i32, i32* %ret, align 4
89 %indirect.goto.dest = phi i8* [ %1, %if.end ]
90 indirectbr i8* %indirect.goto.dest, [label %val_0, label %val_1]