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 9 10target 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" 11target triple = "x86_64-unknown-linux-gnu" 12 13 14; Check origin instrumentation of stores. 15; Check that debug info for origin propagation code is set correctly. 16 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 21 22; 8-aligned store => 8-aligned origin store, origin address is not realigned 23define void @Store8(i8 %x) sanitize_memory { 24entry: 25 store i8 %x, i8* @a8, align 8 26 ret void 27} 28 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 34; CHECK: ret void 35 36 37; 4-aligned store => 4-aligned origin store, origin address is not realigned 38define void @Store4(i8 %x) sanitize_memory { 39entry: 40 store i8 %x, i8* @a4, align 4 41 ret void 42} 43 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 49; CHECK: ret void 50 51 52; 2-aligned store => 4-aligned origin store, origin address is realigned 53define void @Store2(i8 %x) sanitize_memory { 54entry: 55 store i8 %x, i8* @a2, align 2 56 ret void 57} 58 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 64; CHECK: ret void 65 66 67; 1-aligned store => 4-aligned origin store, origin address is realigned 68define void @Store1(i8 %x) sanitize_memory { 69entry: 70 store i8 %x, i8* @a1, align 1 71 ret void 72} 73 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 79 80; CHECK: ret void 81