llvm.org GIT mirror llvm / 5b74b7b
Merging r268531: ------------------------------------------------------------------------ r268531 | koriakin | 2016-05-04 19:39:14 +0100 (Wed, 04 May 2016) | 3 lines [MSan] [Mips64] Add tests for vararg handling. Differential Revision: http://reviews.llvm.org/D19919 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_38@271120 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 3 years ago
2 changed file(s) with 85 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: opt < %s -msan -S | FileCheck %s
1
2 target datalayout = "E-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128"
3 target triple = "mips64--linux"
4
5 define i32 @foo(i32 %guard, ...) {
6 %vl = alloca i8*, align 8
7 %1 = bitcast i8** %vl to i8*
8 call void @llvm.lifetime.start(i64 32, i8* %1)
9 call void @llvm.va_start(i8* %1)
10 call void @llvm.va_end(i8* %1)
11 call void @llvm.lifetime.end(i64 32, i8* %1)
12 ret i32 0
13 }
14
15 ; First, check allocation of the save area.
16
17 ; CHECK-LABEL: @foo
18 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_va_arg_overflow_size_tls
19 ; CHECK: [[B:%.*]] = add i64 0, [[A]]
20 ; CHECK: [[C:%.*]] = alloca {{.*}} [[B]]
21
22 ; CHECK: [[STACK:%.*]] = bitcast {{.*}} @__msan_va_arg_tls to i8*
23 ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[C]], i8* [[STACK]], i64 [[B]], i32 8, i1 false)
24
25 declare void @llvm.lifetime.start(i64, i8* nocapture) #1
26 declare void @llvm.va_start(i8*) #2
27 declare void @llvm.va_end(i8*) #2
28 declare void @llvm.lifetime.end(i64, i8* nocapture) #1
29
30 define i32 @bar() {
31 %1 = call i32 (i32, ...) @foo(i32 0, i32 1, i64 2, double 3.000000e+00)
32 ret i32 %1
33 }
34
35 ; Save the incoming shadow value from the arguments in the __msan_va_arg_tls
36 ; array. The first argument is stored at position 4, since it's right
37 ; justified.
38 ; CHECK-LABEL: @bar
39 ; CHECK: store i32 0, i32* inttoptr (i64 add (i64 ptrtoint ([100 x i64]* @__msan_va_arg_tls to i64), i64 4) to i32*), align 8
40 ; CHECK: store i64 0, i64* inttoptr (i64 add (i64 ptrtoint ([100 x i64]* @__msan_va_arg_tls to i64), i64 8) to i64*), align 8
41 ; CHECK: store i64 0, i64* inttoptr (i64 add (i64 ptrtoint ([100 x i64]* @__msan_va_arg_tls to i64), i64 16) to i64*), align 8
42 ; CHECK: store {{.*}} 24, {{.*}} @__msan_va_arg_overflow_size_tls
0 ; RUN: opt < %s -msan -S | FileCheck %s
1
2 target datalayout = "e-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128"
3 target triple = "mips64el--linux"
4
5 define i32 @foo(i32 %guard, ...) {
6 %vl = alloca i8*, align 8
7 %1 = bitcast i8** %vl to i8*
8 call void @llvm.lifetime.start(i64 32, i8* %1)
9 call void @llvm.va_start(i8* %1)
10 call void @llvm.va_end(i8* %1)
11 call void @llvm.lifetime.end(i64 32, i8* %1)
12 ret i32 0
13 }
14
15 ; First, check allocation of the save area.
16
17 ; CHECK-LABEL: @foo
18 ; CHECK: [[A:%.*]] = load {{.*}} @__msan_va_arg_overflow_size_tls
19 ; CHECK: [[B:%.*]] = add i64 0, [[A]]
20 ; CHECK: [[C:%.*]] = alloca {{.*}} [[B]]
21
22 ; CHECK: [[STACK:%.*]] = bitcast {{.*}} @__msan_va_arg_tls to i8*
23 ; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[C]], i8* [[STACK]], i64 [[B]], i32 8, i1 false)
24
25 declare void @llvm.lifetime.start(i64, i8* nocapture) #1
26 declare void @llvm.va_start(i8*) #2
27 declare void @llvm.va_end(i8*) #2
28 declare void @llvm.lifetime.end(i64, i8* nocapture) #1
29
30 define i32 @bar() {
31 %1 = call i32 (i32, ...) @foo(i32 0, i32 1, i64 2, double 3.000000e+00)
32 ret i32 %1
33 }
34
35 ; Save the incoming shadow value from the arguments in the __msan_va_arg_tls
36 ; array.
37 ; CHECK-LABEL: @bar
38 ; CHECK: store i32 0, i32* bitcast ([100 x i64]* @__msan_va_arg_tls to i32*), align 8
39 ; CHECK: store i64 0, i64* inttoptr (i64 add (i64 ptrtoint ([100 x i64]* @__msan_va_arg_tls to i64), i64 8) to i64*), align 8
40 ; CHECK: store i64 0, i64* inttoptr (i64 add (i64 ptrtoint ([100 x i64]* @__msan_va_arg_tls to i64), i64 16) to i64*), align 8
41 ; CHECK: store {{.*}} 24, {{.*}} @__msan_va_arg_overflow_size_tls