OLD | NEW |
(Empty) | |
| 1 ; Test how we handle eliding (pointer) bitcast instructions. |
| 2 |
| 3 ; RUN: llvm-as < %s | pnacl-freeze \ |
| 4 ; RUN: | pnacl-bcanalyzer -dump-records \ |
| 5 ; RUN: | FileCheck %s -check-prefix=PF2 |
| 6 |
| 7 ; RUN: llvm-as < %s | pnacl-freeze -allow-local-symbol-tables \ |
| 8 ; RUN: | pnacl-thaw -allow-local-symbol-tables \ |
| 9 ; RUN: | llvm-dis - | FileCheck %s -check-prefix=TD2 |
| 10 |
| 11 ; ------------------------------------------------------ |
| 12 |
| 13 @bytes = internal global [4 x i8] c"abcd" |
| 14 |
| 15 ; ------------------------------------------------------ |
| 16 |
| 17 ; Test that we elide the simple case of global. |
| 18 define void @SimpleLoad() { |
| 19 %1 = bitcast [4 x i8]* @bytes to i32* |
| 20 %2 = load i32* %1, align 4 |
| 21 ret void |
| 22 } |
| 23 |
| 24 ; TD2: define void @SimpleLoad() { |
| 25 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32* |
| 26 ; TD2-NEXT: %2 = load i32* %1, align 4 |
| 27 ; TD2-NEXT: ret void |
| 28 ; TD2-NEXT: } |
| 29 |
| 30 ; PF2: <FUNCTION_BLOCK> |
| 31 ; PF2-NEXT: <DECLAREBLOCKS op0=1/> |
| 32 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> |
| 33 ; PF2-NEXT: <INST_RET/> |
| 34 ; PF2-NEXT: </FUNCTION_BLOCK> |
| 35 |
| 36 ; ------------------------------------------------------ |
| 37 |
| 38 ; Test that we elide the simple case of an alloca. |
| 39 define void @SimpleLoadAlloca() { |
| 40 %1 = alloca i8, i32 4, align 4 |
| 41 %2 = bitcast i8* %1 to i32* |
| 42 %3 = load i32* %2, align 4 |
| 43 ret void |
| 44 } |
| 45 |
| 46 ; TD2: define void @SimpleLoadAlloca() { |
| 47 ; TD2-NEXT: %1 = alloca i8, i32 4, align 4 |
| 48 ; TD2-NEXT: %2 = bitcast i8* %1 to i32* |
| 49 ; TD2-NEXT: %3 = load i32* %2, align 4 |
| 50 ; TD2-NEXT: ret void |
| 51 ; TD2-NEXT: } |
| 52 |
| 53 ; PF2: <FUNCTION_BLOCK> |
| 54 ; PF2: </CONSTANTS_BLOCK> |
| 55 ; PF2-NEXT: <INST_ALLOCA op0=1 op1=3/> |
| 56 ; PF2-NEXT: <INST_LOAD op0=1 op1=3 op2=0/> |
| 57 ; PF2-NEXT: <INST_RET/> |
| 58 ; PF2-NEXT: </FUNCTION_BLOCK> |
| 59 |
| 60 ; ------------------------------------------------------ |
| 61 |
| 62 ; Test that we can handle multiple bitcasts. |
| 63 define i32 @TwoLoads(i32 %i) { |
| 64 %1 = bitcast [4 x i8]* @bytes to i32* |
| 65 %2 = load i32* %1, align 4 |
| 66 %3 = bitcast [4 x i8]* @bytes to i32* |
| 67 %4 = load i32* %3, align 4 |
| 68 %5 = add i32 %2, %4 |
| 69 ret i32 %5 |
| 70 } |
| 71 |
| 72 ; TD2: define i32 @TwoLoads(i32 %i) { |
| 73 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32* |
| 74 ; TD2-NEXT: %2 = load i32* %1, align 4 |
| 75 ; TD2-NEXT: %3 = load i32* %1, align 4 |
| 76 ; TD2-NEXT: %4 = add i32 %2, %3 |
| 77 ; TD2-NEXT: ret i32 %4 |
| 78 ; TD2-NEXT: } |
| 79 |
| 80 ; PF2: <FUNCTION_BLOCK> |
| 81 ; PF2-NEXT: <DECLAREBLOCKS op0=1/> |
| 82 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> |
| 83 ; PF2-NEXT: <INST_LOAD op0=3 op1=3 op2=0/> |
| 84 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> |
| 85 ; PF2-NEXT: <INST_RET op0=1/> |
| 86 ; PF2: </FUNCTION_BLOCK> |
| 87 |
| 88 ; ------------------------------------------------------ |
| 89 |
| 90 ; Test how we handle bitcasts if optimized in the input file. This |
| 91 ; case tests within a single block. |
| 92 define i32 @TwoLoadOptOneBlock(i32 %i) { |
| 93 %1 = bitcast [4 x i8]* @bytes to i32* |
| 94 %2 = load i32* %1, align 4 |
| 95 %3 = load i32* %1, align 4 |
| 96 %4 = add i32 %2, %3 |
| 97 ret i32 %4 |
| 98 } |
| 99 |
| 100 ; TD2: define i32 @TwoLoadOptOneBlock(i32 %i) { |
| 101 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32* |
| 102 ; TD2-NEXT: %2 = load i32* %1, align 4 |
| 103 ; TD2-NEXT: %3 = load i32* %1, align 4 |
| 104 ; TD2-NEXT: %4 = add i32 %2, %3 |
| 105 ; TD2-NEXT: ret i32 %4 |
| 106 ; TD2-NEXT: } |
| 107 |
| 108 ; PF2: <FUNCTION_BLOCK> |
| 109 ; PF2-NEXT: <DECLAREBLOCKS op0=1/> |
| 110 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> |
| 111 ; PF2-NEXT: <INST_LOAD op0=3 op1=3 op2=0/> |
| 112 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> |
| 113 ; PF2-NEXT: <INST_RET op0=1/> |
| 114 ; PF2: </FUNCTION_BLOCK> |
| 115 |
| 116 ; ------------------------------------------------------ |
| 117 |
| 118 ; Test how we handle bitcasts if optimized in the input file. This |
| 119 ; case tests accross blocks. |
| 120 define i32 @TwoLoadOptTwoBlocks(i32 %i) { |
| 121 %1 = bitcast [4 x i8]* @bytes to i32* |
| 122 %2 = load i32* %1, align 4 |
| 123 %3 = load i32* %1, align 4 |
| 124 %4 = add i32 %2, %3 |
| 125 br label %BB |
| 126 |
| 127 BB: |
| 128 %5 = load i32* %1, align 4 |
| 129 %6 = load i32* %1, align 4 |
| 130 %7 = add i32 %5, %6 |
| 131 ret i32 %4 |
| 132 } |
| 133 |
| 134 ; TD2: define i32 @TwoLoadOptTwoBlocks(i32 %i) { |
| 135 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32* |
| 136 ; TD2-NEXT: %2 = load i32* %1, align 4 |
| 137 ; TD2-NEXT: %3 = load i32* %1, align 4 |
| 138 ; TD2-NEXT: %4 = add i32 %2, %3 |
| 139 ; TD2-NEXT: br label %BB |
| 140 ; TD2: BB: |
| 141 ; TD2-NEXT: %5 = bitcast [4 x i8]* @bytes to i32* |
| 142 ; TD2-NEXT: %6 = load i32* %5, align 4 |
| 143 ; TD2-NEXT: %7 = load i32* %5, align 4 |
| 144 ; TD2-NEXT: %8 = add i32 %6, %7 |
| 145 ; TD2-NEXT: ret i32 %4 |
| 146 ; TD2-NEXT: } |
| 147 |
| 148 ; PF2: <FUNCTION_BLOCK> |
| 149 ; PF2-NEXT: <DECLAREBLOCKS op0=2/> |
| 150 ; PF2-NEXT: <INST_LOAD op0=2 op1=3 op2=0/> |
| 151 ; PF2-NEXT: <INST_LOAD op0=3 op1=3 op2=0/> |
| 152 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> |
| 153 ; PF2-NEXT: <INST_BR op0=1/> |
| 154 ; PF2-NEXT: <INST_LOAD op0=5 op1=3 op2=0/> |
| 155 ; PF2-NEXT: <INST_LOAD op0=6 op1=3 op2=0/> |
| 156 ; PF2-NEXT: <INST_BINOP op0=2 op1=1 op2=0/> |
| 157 ; PF2-NEXT: <INST_RET op0=4/> |
| 158 ; PF2: </FUNCTION_BLOCK> |
| 159 |
| 160 ; ------------------------------------------------------ |
| 161 |
| 162 ; Test that we elide the simple case of bitcast for a store. |
| 163 define void @SimpleStore(i32 %i) { |
| 164 %1 = bitcast [4 x i8]* @bytes to i32* |
| 165 store i32 %i, i32* %1, align 4 |
| 166 ret void |
| 167 } |
| 168 |
| 169 ; TD2: define void @SimpleStore(i32 %i) { |
| 170 ; TD2-NEXT: %1 = bitcast [4 x i8]* @bytes to i32* |
| 171 ; TD2-NEXT: store i32 %i, i32* %1, align 4 |
| 172 ; TD2-NEXT: ret void |
| 173 ; TD2-NEXT: } |
| 174 |
| 175 ; PF2: <FUNCTION_BLOCK> |
| 176 ; PF2-NEXT: <DECLAREBLOCKS op0=1/> |
| 177 ; PF2-NEXT: <INST_STORE op0=2 op1=1 op2=3/> |
| 178 ; PF2-NEXT: <INST_RET/> |
| 179 ; PF2: </FUNCTION_BLOCK> |
OLD | NEW |