JF Bastien | f5aa1ca | 2015-08-28 16:49:09 +0000 | [diff] [blame] | 1 | ; 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 | |
| 8 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 9 | target triple = "x86_64-unknown-linux-gnu" |
| 10 | |
| 11 | ; Function Attrs: nounwind uwtable |
| 12 | define i32 @_Z1fi(i32 %i) #0 { |
| 13 | ; CHECK-LABEL: define i32 @_Z1fi |
| 14 | ; CHECK-NEXT: entry: |
| 15 | ; CHECK-NEXT: alloca |
| 16 | entry: |
| 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 | |
| 29 | if.then: |
| 30 | store i8* blockaddress(@_Z1fi, %val_1), i8** %l, align 8 |
| 31 | br label %if.end |
| 32 | |
| 33 | if.end: |
| 34 | %1 = load i8*, i8** %l, align 8 |
| 35 | br label %indirectgoto |
| 36 | |
| 37 | val_0: |
| 38 | store i32 12, i32* %ret, align 4 |
| 39 | br label %end |
| 40 | |
| 41 | val_1: |
| 42 | store i32 42, i32* %ret, align 4 |
| 43 | br label %end |
| 44 | |
| 45 | end: |
| 46 | %2 = load i32, i32* %ret, align 4 |
| 47 | ret i32 %2 |
| 48 | |
| 49 | indirectgoto: |
| 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 |
| 55 | define i32 @_Z1gi(i32 %i) #0 { |
| 56 | ; CHECK-LABEL: define i32 @_Z1gi |
| 57 | ; CHECK-NEXT: entry: |
| 58 | ; CHECK-NEXT: alloca |
| 59 | entry: |
| 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 | |
| 72 | if.then: |
| 73 | store i8* blockaddress(@_Z1gi, %val_0), i8** %l, align 8 |
| 74 | br label %if.end |
| 75 | |
| 76 | if.end: |
| 77 | %1 = load i8*, i8** %l, align 8 |
| 78 | br label %indirectgoto |
| 79 | |
| 80 | val_0: |
| 81 | store i32 12, i32* %ret, align 4 |
| 82 | br label %end |
| 83 | |
| 84 | val_1: |
| 85 | store i32 42, i32* %ret, align 4 |
| 86 | br label %end |
| 87 | |
| 88 | end: |
| 89 | %2 = load i32, i32* %ret, align 4 |
| 90 | ret i32 %2 |
| 91 | |
| 92 | indirectgoto: |
| 93 | %indirect.goto.dest = phi i8* [ %1, %if.end ] |
| 94 | indirectbr i8* %indirect.goto.dest, [label %val_1, label %val_0] |
| 95 | } |
| 96 | |