1 ; RUN: opt < %s -S -passes="msan<track-origins=1>" 2>&1 | FileCheck %s --implicit-check-not "call void @llvm.mem" --implicit-check-not " load" --implicit-check-not " store"
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
6 declare void @FnByVal(ptr byval(i128) %p);
7 declare void @Fn(ptr %p);
9 define i128 @ByValArgument(i32, ptr byval(i128) %p) sanitize_memory {
10 ; CHECK-LABEL: @ByValArgument(
12 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %[[#]], ptr align 8 inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), i64 16, i1 false)
13 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[#]], ptr align 4 inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_origin_tls to i64), i64 8) to ptr), i64 16, i1 false)
14 ; CHECK: [[X:%.*]] = load i128, ptr %p, align 8
15 ; CHECK: [[_MSLD:%.*]] = load i128, ptr %[[#]], align 8
16 ; CHECK: %[[#]] = load i32, ptr %[[#]], align 8
17 ; CHECK: store i128 [[_MSLD]], ptr @__msan_retval_tls, align 8
18 ; CHECK: store i32 %[[#]], ptr @__msan_retval_origin_tls, align 4
19 ; CHECK: ret i128 [[X]]
22 %x = load i128, ptr %p
26 define i128 @ByValArgumentNoSanitize(i32, ptr byval(i128) %p) {
27 ; CHECK-LABEL: @ByValArgumentNoSanitize(
29 ; CHECK: call void @llvm.memset.p0.i64(ptr align 8 %[[#]], i8 0, i64 16, i1 false)
30 ; CHECK: [[X:%.*]] = load i128, ptr %p, align 8
31 ; CHECK: store i128 0, ptr @__msan_retval_tls, align 8
32 ; CHECK: store i32 0, ptr @__msan_retval_origin_tls, align 4
33 ; CHECK: ret i128 [[X]]
36 %x = load i128, ptr %p
40 define void @ByValForward(i32, ptr byval(i128) %p) sanitize_memory {
41 ; CHECK-LABEL: @ByValForward(
43 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %[[#]], ptr align 8 inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), i64 16, i1 false)
44 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[#]], ptr align 4 inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_origin_tls to i64), i64 8) to ptr), i64 16, i1 false)
45 ; CHECK: store i64 0, ptr @__msan_param_tls, align 8
46 ; CHECK: call void @Fn(ptr %p)
54 define void @ByValForwardNoSanitize(i32, ptr byval(i128) %p) {
55 ; CHECK-LABEL: @ByValForwardNoSanitize(
57 ; CHECK: call void @llvm.memset.p0.i64(ptr align 8 %[[#]], i8 0, i64 16, i1 false)
58 ; CHECK: store i64 0, ptr @__msan_param_tls, align 8
59 ; CHECK: call void @Fn(ptr %p)
67 define void @ByValForwardByVal(i32, ptr byval(i128) %p) sanitize_memory {
68 ; CHECK-LABEL: @ByValForwardByVal(
70 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 8 %[[#]], ptr align 8 inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), i64 16, i1 false)
71 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[#]], ptr align 4 inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_origin_tls to i64), i64 8) to ptr), i64 16, i1 false)
72 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr @__msan_param_tls, ptr %[[#]], i64 16, i1 false)
73 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 @__msan_param_origin_tls, ptr align 4 %[[#]], i64 16, i1 false)
74 ; CHECK: call void @FnByVal(ptr byval(i128) %p)
78 call void @FnByVal(ptr byval(i128) %p)
82 define void @ByValForwardByValNoSanitize(i32, ptr byval(i128) %p) {
83 ; CHECK-LABEL: @ByValForwardByValNoSanitize(
85 ; CHECK: call void @llvm.memset.p0.i64(ptr align 8 %[[#]], i8 0, i64 16, i1 false)
86 ; CHECK: call void @llvm.memset.p0.i64(ptr @__msan_param_tls, i8 0, i64 16, i1 false)
87 ; CHECK: call void @FnByVal(ptr byval(i128) %p)
91 call void @FnByVal(ptr byval(i128) %p)
95 declare void @FnByVal8(ptr byval(i8) %p);
96 declare void @Fn8(ptr %p);
98 define i8 @ByValArgument8(i32, ptr byval(i8) %p) sanitize_memory {
99 ; CHECK-LABEL: @ByValArgument8(
101 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %[[#]], ptr align 1 inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), i64 1, i1 false)
102 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[#]], ptr align 4 inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_origin_tls to i64), i64 8) to ptr), i64 4, i1 false)
103 ; CHECK: [[X:%.*]] = load i8, ptr %p, align 1
104 ; CHECK: [[_MSLD:%.*]] = load i8, ptr %[[#]], align 1
105 ; CHECK: %[[#]] = load i32, ptr %[[#]], align 4
106 ; CHECK: store i8 [[_MSLD]], ptr @__msan_retval_tls, align 8
107 ; CHECK: store i32 %[[#]], ptr @__msan_retval_origin_tls, align 4
108 ; CHECK: ret i8 [[X]]
115 define i8 @ByValArgumentNoSanitize8(i32, ptr byval(i8) %p) {
116 ; CHECK-LABEL: @ByValArgumentNoSanitize8(
118 ; CHECK: call void @llvm.memset.p0.i64(ptr align 1 %[[#]], i8 0, i64 1, i1 false)
119 ; CHECK: [[X:%.*]] = load i8, ptr %p, align 1
120 ; CHECK: store i8 0, ptr @__msan_retval_tls, align 8
121 ; CHECK: store i32 0, ptr @__msan_retval_origin_tls, align 4
122 ; CHECK: ret i8 [[X]]
129 define void @ByValForward8(i32, ptr byval(i8) %p) sanitize_memory {
130 ; CHECK-LABEL: @ByValForward8(
132 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %[[#]], ptr align 1 inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), i64 1, i1 false)
133 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[#]], ptr align 4 inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_origin_tls to i64), i64 8) to ptr), i64 4, i1 false)
134 ; CHECK: store i64 0, ptr @__msan_param_tls, align 8
135 ; CHECK: call void @Fn8(ptr %p)
139 call void @Fn8(ptr %p)
143 define void @ByValForwardNoSanitize8(i32, ptr byval(i8) %p) {
144 ; CHECK-LABEL: @ByValForwardNoSanitize8(
146 ; CHECK: call void @llvm.memset.p0.i64(ptr align 1 %[[#]], i8 0, i64 1, i1 false)
147 ; CHECK: store i64 0, ptr @__msan_param_tls, align 8
148 ; CHECK: call void @Fn8(ptr %p)
152 call void @Fn8(ptr %p)
156 define void @ByValForwardByVal8(i32, ptr byval(i8) %p) sanitize_memory {
157 ; CHECK-LABEL: @ByValForwardByVal8(
159 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 1 %[[#]], ptr align 1 inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_tls to i64), i64 8) to ptr), i64 1, i1 false)
160 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 %[[#]], ptr align 4 inttoptr (i64 add (i64 ptrtoint (ptr @__msan_param_origin_tls to i64), i64 8) to ptr), i64 4, i1 false)
161 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr @__msan_param_tls, ptr %[[#]], i64 1, i1 false)
162 ; CHECK: call void @llvm.memcpy.p0.p0.i64(ptr align 4 @__msan_param_origin_tls, ptr align 4 %[[#]], i64 4, i1 false)
163 ; CHECK: call void @FnByVal8(ptr byval(i8) %p)
167 call void @FnByVal8(ptr byval(i8) %p)
171 define void @ByValForwardByValNoSanitize8(i32, ptr byval(i8) %p) {
172 ; CHECK-LABEL: @ByValForwardByValNoSanitize8(
174 ; CHECK: call void @llvm.memset.p0.i64(ptr align 1 %[[#]], i8 0, i64 1, i1 false)
175 ; CHECK: call void @llvm.memset.p0.i64(ptr @__msan_param_tls, i8 0, i64 1, i1 false)
176 ; CHECK: call void @FnByVal8(ptr byval(i8) %p)
180 call void @FnByVal8(ptr byval(i8) %p)