1 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
2 ; RUN: -passes=msan 2>&1 | FileCheck -check-prefix=CHECK \
3 ; RUN: -check-prefix=CHECK-ORIGINS1 %s
4 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS1 %s
5 ; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=2 -S \
6 ; RUN: -passes=msan 2>&1 | FileCheck -check-prefix=CHECK \
7 ; RUN: -check-prefix=CHECK-ORIGINS2 %s
8 ; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=2 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS2 %s
10 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"
11 target triple = "x86_64-unknown-linux-gnu"
14 ; Check origin instrumentation of stores.
15 ; Check that debug info for origin propagation code is set correctly.
17 @a8 = global i8 0, align 8
18 @a4 = global i8 0, align 4
19 @a2 = global i8 0, align 2
20 @a1 = global i8 0, align 1
22 ; 8-aligned store => 8-aligned origin store, origin address is not realigned
23 define void @Store8(i8 %x) sanitize_memory {
25 store i8 %x, i8* @a8, align 8
29 ; CHECK-LABEL: @Store8
30 ; CHECK-ORIGINS1: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
31 ; CHECK-ORIGINS2: [[ORIGIN0:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
32 ; CHECK-ORIGINS2: [[ORIGIN:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 [[ORIGIN0]])
33 ; CHECK: store i32 [[ORIGIN]], {{.*}}, align 8
37 ; 4-aligned store => 4-aligned origin store, origin address is not realigned
38 define void @Store4(i8 %x) sanitize_memory {
40 store i8 %x, i8* @a4, align 4
44 ; CHECK-LABEL: @Store4
45 ; CHECK-ORIGINS1: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
46 ; CHECK-ORIGINS2: [[ORIGIN0:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
47 ; CHECK-ORIGINS2: [[ORIGIN:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 [[ORIGIN0]])
48 ; CHECK: store i32 [[ORIGIN]], {{.*}}, align 4
52 ; 2-aligned store => 4-aligned origin store, origin address is realigned
53 define void @Store2(i8 %x) sanitize_memory {
55 store i8 %x, i8* @a2, align 2
59 ; CHECK-LABEL: @Store2
60 ; CHECK-ORIGINS1: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
61 ; CHECK-ORIGINS2: [[ORIGIN0:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
62 ; CHECK-ORIGINS2: [[ORIGIN:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 [[ORIGIN0]])
63 ; CHECK: store i32 [[ORIGIN]], {{.*}}, align 4
67 ; 1-aligned store => 4-aligned origin store, origin address is realigned
68 define void @Store1(i8 %x) sanitize_memory {
70 store i8 %x, i8* @a1, align 1
74 ; CHECK-LABEL: @Store1
75 ; CHECK-ORIGINS1: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
76 ; CHECK-ORIGINS2: [[ORIGIN0:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
77 ; CHECK-ORIGINS2: [[ORIGIN:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 [[ORIGIN0]])
78 ; CHECK: store i32 [[ORIGIN]], {{.*}}, align 4