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-check-access-address=0 -msan-track-origins=2 -S \
5 ; RUN: -passes=msan 2>&1 | FileCheck -check-prefix=CHECK \
6 ; RUN: -check-prefix=CHECK-ORIGINS2 %s
8 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"
9 target triple = "x86_64-unknown-linux-gnu"
12 ; Check origin instrumentation of stores.
13 ; Check that debug info for origin propagation code is set correctly.
15 @a8 = global i8 0, align 8
16 @a4 = global i8 0, align 4
17 @a2 = global i8 0, align 2
18 @a1 = global i8 0, align 1
20 ; 8-aligned store => 8-aligned origin store, origin address is not realigned
21 define void @Store8(i8 %x) sanitize_memory {
23 store i8 %x, ptr @a8, align 8
27 ; CHECK-LABEL: @Store8
28 ; CHECK-ORIGINS1: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
29 ; CHECK-ORIGINS2: [[ORIGIN0:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
30 ; CHECK-ORIGINS2: [[ORIGIN:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 [[ORIGIN0]])
31 ; CHECK: store i32 [[ORIGIN]], {{.*}}, align 8
35 ; 4-aligned store => 4-aligned origin store, origin address is not realigned
36 define void @Store4(i8 %x) sanitize_memory {
38 store i8 %x, ptr @a4, align 4
42 ; CHECK-LABEL: @Store4
43 ; CHECK-ORIGINS1: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
44 ; CHECK-ORIGINS2: [[ORIGIN0:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
45 ; CHECK-ORIGINS2: [[ORIGIN:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 [[ORIGIN0]])
46 ; CHECK: store i32 [[ORIGIN]], {{.*}}, align 4
50 ; 2-aligned store => 4-aligned origin store, origin address is realigned
51 define void @Store2(i8 %x) sanitize_memory {
53 store i8 %x, ptr @a2, align 2
57 ; CHECK-LABEL: @Store2
58 ; CHECK-ORIGINS1: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
59 ; CHECK-ORIGINS2: [[ORIGIN0:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
60 ; CHECK-ORIGINS2: [[ORIGIN:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 [[ORIGIN0]])
61 ; CHECK: store i32 [[ORIGIN]], {{.*}}, align 4
65 ; 1-aligned store => 4-aligned origin store, origin address is realigned
66 define void @Store1(i8 %x) sanitize_memory {
68 store i8 %x, ptr @a1, align 1
72 ; CHECK-LABEL: @Store1
73 ; CHECK-ORIGINS1: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
74 ; CHECK-ORIGINS2: [[ORIGIN0:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
75 ; CHECK-ORIGINS2: [[ORIGIN:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 [[ORIGIN0]])
76 ; CHECK: store i32 [[ORIGIN]], {{.*}}, align 4