Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
------------------------------------------------------------------------ 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 ------------------------------------------------------------------------ llvm-svn: 271120
- Loading branch information
1 parent
84d4748
commit f11b653
Showing
2 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
llvm/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
; RUN: opt < %s -msan -S | FileCheck %s | ||
|
||
target datalayout = "E-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128" | ||
target triple = "mips64--linux" | ||
|
||
define i32 @foo(i32 %guard, ...) { | ||
%vl = alloca i8*, align 8 | ||
%1 = bitcast i8** %vl to i8* | ||
call void @llvm.lifetime.start(i64 32, i8* %1) | ||
call void @llvm.va_start(i8* %1) | ||
call void @llvm.va_end(i8* %1) | ||
call void @llvm.lifetime.end(i64 32, i8* %1) | ||
ret i32 0 | ||
} | ||
|
||
; First, check allocation of the save area. | ||
|
||
; CHECK-LABEL: @foo | ||
; CHECK: [[A:%.*]] = load {{.*}} @__msan_va_arg_overflow_size_tls | ||
; CHECK: [[B:%.*]] = add i64 0, [[A]] | ||
; CHECK: [[C:%.*]] = alloca {{.*}} [[B]] | ||
|
||
; CHECK: [[STACK:%.*]] = bitcast {{.*}} @__msan_va_arg_tls to i8* | ||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[C]], i8* [[STACK]], i64 [[B]], i32 8, i1 false) | ||
|
||
declare void @llvm.lifetime.start(i64, i8* nocapture) #1 | ||
declare void @llvm.va_start(i8*) #2 | ||
declare void @llvm.va_end(i8*) #2 | ||
declare void @llvm.lifetime.end(i64, i8* nocapture) #1 | ||
|
||
define i32 @bar() { | ||
%1 = call i32 (i32, ...) @foo(i32 0, i32 1, i64 2, double 3.000000e+00) | ||
ret i32 %1 | ||
} | ||
|
||
; Save the incoming shadow value from the arguments in the __msan_va_arg_tls | ||
; array. The first argument is stored at position 4, since it's right | ||
; justified. | ||
; CHECK-LABEL: @bar | ||
; 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 | ||
; 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 | ||
; 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 | ||
; CHECK: store {{.*}} 24, {{.*}} @__msan_va_arg_overflow_size_tls |
42 changes: 42 additions & 0 deletions
42
llvm/test/Instrumentation/MemorySanitizer/Mips/vararg-mips64el.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
; RUN: opt < %s -msan -S | FileCheck %s | ||
|
||
target datalayout = "e-m:m-i8:8:32-i16:16:32-i64:64-n32:64-S128" | ||
target triple = "mips64el--linux" | ||
|
||
define i32 @foo(i32 %guard, ...) { | ||
%vl = alloca i8*, align 8 | ||
%1 = bitcast i8** %vl to i8* | ||
call void @llvm.lifetime.start(i64 32, i8* %1) | ||
call void @llvm.va_start(i8* %1) | ||
call void @llvm.va_end(i8* %1) | ||
call void @llvm.lifetime.end(i64 32, i8* %1) | ||
ret i32 0 | ||
} | ||
|
||
; First, check allocation of the save area. | ||
|
||
; CHECK-LABEL: @foo | ||
; CHECK: [[A:%.*]] = load {{.*}} @__msan_va_arg_overflow_size_tls | ||
; CHECK: [[B:%.*]] = add i64 0, [[A]] | ||
; CHECK: [[C:%.*]] = alloca {{.*}} [[B]] | ||
|
||
; CHECK: [[STACK:%.*]] = bitcast {{.*}} @__msan_va_arg_tls to i8* | ||
; CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[C]], i8* [[STACK]], i64 [[B]], i32 8, i1 false) | ||
|
||
declare void @llvm.lifetime.start(i64, i8* nocapture) #1 | ||
declare void @llvm.va_start(i8*) #2 | ||
declare void @llvm.va_end(i8*) #2 | ||
declare void @llvm.lifetime.end(i64, i8* nocapture) #1 | ||
|
||
define i32 @bar() { | ||
%1 = call i32 (i32, ...) @foo(i32 0, i32 1, i64 2, double 3.000000e+00) | ||
ret i32 %1 | ||
} | ||
|
||
; Save the incoming shadow value from the arguments in the __msan_va_arg_tls | ||
; array. | ||
; CHECK-LABEL: @bar | ||
; CHECK: store i32 0, i32* bitcast ([100 x i64]* @__msan_va_arg_tls to i32*), align 8 | ||
; 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 | ||
; 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 | ||
; CHECK: store {{.*}} 24, {{.*}} @__msan_va_arg_overflow_size_tls |