|
3 | 3 | ; Make sure that SROA doesn't lose nonnull metadata
|
4 | 4 | ; on loads from allocas that get optimized out.
|
5 | 5 |
|
6 |
| -define float* @yummy_nonnull(float** %arg) { |
7 |
| -; CHECK-LABEL: define float* @yummy_nonnull( |
| 6 | +declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) |
| 7 | + |
| 8 | +; Check that we do basic propagation of nonnull when rewriting. |
| 9 | +define i8* @propagate_nonnull(i32* %v) { |
| 10 | +; CHECK-LABEL: define i8* @propagate_nonnull( |
| 11 | +; CHECK-NEXT: entry: |
| 12 | +; CHECK-NEXT: %[[A:.*]] = alloca i8* |
| 13 | +; CHECK-NEXT: %[[V_CAST:.*]] = bitcast i32* %v to i8* |
| 14 | +; CHECK-NEXT: store i8* %[[V_CAST]], i8** %[[A]] |
| 15 | +; CHECK-NEXT: %[[LOAD:.*]] = load volatile i8*, i8** %[[A]], !nonnull !0 |
| 16 | +; CHECK-NEXT: ret i8* %[[LOAD]] |
| 17 | +entry: |
| 18 | + %a = alloca [2 x i8*] |
| 19 | + %a.gep0 = getelementptr [2 x i8*], [2 x i8*]* %a, i32 0, i32 0 |
| 20 | + %a.gep1 = getelementptr [2 x i8*], [2 x i8*]* %a, i32 0, i32 1 |
| 21 | + %a.gep0.cast = bitcast i8** %a.gep0 to i32** |
| 22 | + %a.gep1.cast = bitcast i8** %a.gep1 to i32** |
| 23 | + store i32* %v, i32** %a.gep1.cast |
| 24 | + store i32* null, i32** %a.gep0.cast |
| 25 | + %load = load volatile i8*, i8** %a.gep1, !nonnull !0 |
| 26 | + ret i8* %load |
| 27 | +} |
| 28 | + |
| 29 | +define float* @turn_nonnull_into_assume(float** %arg) { |
| 30 | +; CHECK-LABEL: define float* @turn_nonnull_into_assume( |
8 | 31 | ; CHECK-NEXT: entry:
|
9 | 32 | ; CHECK-NEXT: %[[RETURN:.*]] = load float*, float** %arg, align 8
|
10 | 33 | ; CHECK-NEXT: %[[ASSUME:.*]] = icmp ne float* %[[RETURN]], null
|
|
19 | 42 | ret float* %ret
|
20 | 43 | }
|
21 | 44 |
|
22 |
| -declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) |
23 |
| - |
24 | 45 | !0 = !{}
|
0 commit comments