• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS1 %s
2; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=2 -S | FileCheck -check-prefix=CHECK -check-prefix=CHECK-ORIGINS2 %s
3
4target 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"
5target triple = "x86_64-unknown-linux-gnu"
6
7
8; Check origin instrumentation of stores.
9; Check that debug info for origin propagation code is set correctly.
10
11@a8 = global i8 0, align 8
12@a4 = global i8 0, align 4
13@a2 = global i8 0, align 2
14@a1 = global i8 0, align 1
15
16; 8-aligned store => 8-aligned origin store, origin address is not realigned
17define void @Store8(i8 %x) sanitize_memory {
18entry:
19  store i8 %x, i8* @a8, align 8
20  ret void
21}
22
23; CHECK-LABEL: @Store8
24; CHECK-ORIGINS1: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
25; CHECK-ORIGINS2: [[ORIGIN0:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
26; CHECK-ORIGINS2: [[ORIGIN:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 [[ORIGIN0]])
27; CHECK: store i32 [[ORIGIN]], {{.*}}, align 8
28; CHECK: ret void
29
30
31; 4-aligned store => 4-aligned origin store, origin address is not realigned
32define void @Store4(i8 %x) sanitize_memory {
33entry:
34  store i8 %x, i8* @a4, align 4
35  ret void
36}
37
38; CHECK-LABEL: @Store4
39; CHECK-ORIGINS1: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
40; CHECK-ORIGINS2: [[ORIGIN0:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
41; CHECK-ORIGINS2: [[ORIGIN:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 [[ORIGIN0]])
42; CHECK: store i32 [[ORIGIN]], {{.*}}, align 4
43; CHECK: ret void
44
45
46; 2-aligned store => 4-aligned origin store, origin address is realigned
47define void @Store2(i8 %x) sanitize_memory {
48entry:
49  store i8 %x, i8* @a2, align 2
50  ret void
51}
52
53; CHECK-LABEL: @Store2
54; CHECK-ORIGINS1: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
55; CHECK-ORIGINS2: [[ORIGIN0:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
56; CHECK-ORIGINS2: [[ORIGIN:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 [[ORIGIN0]])
57; CHECK: store i32 [[ORIGIN]], {{.*}}, align 4
58; CHECK: ret void
59
60
61; 1-aligned store => 4-aligned origin store, origin address is realigned
62define void @Store1(i8 %x) sanitize_memory {
63entry:
64  store i8 %x, i8* @a1, align 1
65  ret void
66}
67
68; CHECK-LABEL: @Store1
69; CHECK-ORIGINS1: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
70; CHECK-ORIGINS2: [[ORIGIN0:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
71; CHECK-ORIGINS2: [[ORIGIN:%[01-9a-z]+]] = call i32 @__msan_chain_origin(i32 [[ORIGIN0]])
72; CHECK: store i32 [[ORIGIN]], {{.*}}, align 4
73
74; CHECK: ret void
75