1; RUN: opt -S -mergefunc < %s | FileCheck %s 2; RUN: opt -S -passes=mergefunc < %s | FileCheck %s 3 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). 9 10target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 11target triple = "x86_64-unknown-linux-gnu" 12 13define i32 @_Z1fi(i32 %i) #0 { 14entry: 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 25 26if.then: 27 store i8* blockaddress(@_Z1fi, %val_1), i8** %l, align 8 28 br label %if.end 29 30if.end: 31 %1 = load i8*, i8** %l, align 8 32 br label %indirectgoto 33 34val_1: 35 store i32 42, i32* %ret, align 4 36 br label %end 37 38val_0: 39 store i32 12, i32* %ret, align 4 40 br label %end 41 42 43end: 44 %2 = load i32, i32* %ret, align 4 45 ret i32 %2 46 47indirectgoto: 48 %indirect.goto.dest = phi i8* [ %1, %if.end ] 49 indirectbr i8* %indirect.goto.dest, [label %val_0, label %val_1] 50} 51 52define i32 @_Z1gi(i32 %i) #0 { 53; CHECK-LABEL: define i32 @_Z1gi 54; CHECK-NEXT: tail call i32 @_Z1fi 55; CHECK-NEXT: ret 56entry: 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 67 68if.then: 69 store i8* blockaddress(@_Z1gi, %val_1), i8** %l, align 8 70 br label %if.end 71 72if.end: 73 %1 = load i8*, i8** %l, align 8 74 br label %indirectgoto 75 76val_0: 77 store i32 12, i32* %ret, align 4 78 br label %end 79 80val_1: 81 store i32 42, i32* %ret, align 4 82 br label %end 83 84end: 85 %2 = load i32, i32* %ret, align 4 86 ret i32 %2 87 88indirectgoto: 89 %indirect.goto.dest = phi i8* [ %1, %if.end ] 90 indirectbr i8* %indirect.goto.dest, [label %val_0, label %val_1] 91} 92 93