Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 156cc49

Browse files
committed
[SROA] Further test cleanup and add a test for the actual propagation of
the nonnull attribute distinct from rewriting it into an assume. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306358 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 8ff688d commit 156cc49

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

test/Transforms/SROA/preserve-nonnull.ll

+25-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,31 @@
33
; Make sure that SROA doesn't lose nonnull metadata
44
; on loads from allocas that get optimized out.
55

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(
831
; CHECK-NEXT: entry:
932
; CHECK-NEXT: %[[RETURN:.*]] = load float*, float** %arg, align 8
1033
; CHECK-NEXT: %[[ASSUME:.*]] = icmp ne float* %[[RETURN]], null
@@ -19,6 +42,4 @@ entry:
1942
ret float* %ret
2043
}
2144

22-
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1)
23-
2445
!0 = !{}

0 commit comments

Comments
 (0)