1; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck \ 2; RUN: %s "--check-prefixes=CHECK,INLINE" 3; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s --check-prefixes=CHECK,INLINE 4; RUN: opt < %s -msan-check-access-address=0 -msan-poison-stack-with-call=1 -S \ 5; RUN: -passes=msan 2>&1 | FileCheck %s "--check-prefixes=CHECK,CALL" 6; RUN: opt < %s -msan -msan-check-access-address=0 -msan-poison-stack-with-call=1 -S | FileCheck %s --check-prefixes=CHECK,CALL 7; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \ 8; RUN: -passes=msan 2>&1 | FileCheck %s "--check-prefixes=CHECK,ORIGIN" 9; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck %s --check-prefixes=CHECK,ORIGIN 10; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=2 -S \ 11; RUN: -passes=msan 2>&1 | FileCheck %s "--check-prefixes=CHECK,ORIGIN" 12; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=2 -S | FileCheck %s --check-prefixes=CHECK,ORIGIN 13; RUN: opt < %s -msan-kernel=1 -S -passes=msan 2>&1 | FileCheck %s \ 14; RUN: "--check-prefixes=CHECK,KMSAN" 15; RUN: opt < %s -msan -msan-kernel=1 -S | FileCheck %s --check-prefixes=CHECK,KMSAN 16 17target 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" 18target triple = "x86_64-unknown-linux-gnu" 19 20define void @static() sanitize_memory { 21entry: 22 %x = alloca i32, align 4 23 ret void 24} 25 26; CHECK-LABEL: define void @static( 27; INLINE: call void @llvm.memset.p0i8.i64(i8* align 4 {{.*}}, i8 -1, i64 4, i1 false) 28; CALL: call void @__msan_poison_stack(i8* {{.*}}, i64 4) 29; ORIGIN: call void @__msan_set_alloca_origin4(i8* {{.*}}, i64 4, 30; KMSAN: call void @__msan_poison_alloca(i8* {{.*}}, i64 4, 31; CHECK: ret void 32 33 34define void @dynamic() sanitize_memory { 35entry: 36 br label %l 37l: 38 %x = alloca i32, align 4 39 ret void 40} 41 42; CHECK-LABEL: define void @dynamic( 43; INLINE: call void @llvm.memset.p0i8.i64(i8* align 4 {{.*}}, i8 -1, i64 4, i1 false) 44; CALL: call void @__msan_poison_stack(i8* {{.*}}, i64 4) 45; ORIGIN: call void @__msan_set_alloca_origin4(i8* {{.*}}, i64 4, 46; KMSAN: call void @__msan_poison_alloca(i8* {{.*}}, i64 4, 47; CHECK: ret void 48 49define void @array() sanitize_memory { 50entry: 51 %x = alloca i32, i64 5, align 4 52 ret void 53} 54 55; CHECK-LABEL: define void @array( 56; INLINE: call void @llvm.memset.p0i8.i64(i8* align 4 {{.*}}, i8 -1, i64 20, i1 false) 57; CALL: call void @__msan_poison_stack(i8* {{.*}}, i64 20) 58; ORIGIN: call void @__msan_set_alloca_origin4(i8* {{.*}}, i64 20, 59; KMSAN: call void @__msan_poison_alloca(i8* {{.*}}, i64 20, 60; CHECK: ret void 61 62define void @array_non_const(i64 %cnt) sanitize_memory { 63entry: 64 %x = alloca i32, i64 %cnt, align 4 65 ret void 66} 67 68; CHECK-LABEL: define void @array_non_const( 69; CHECK: %[[A:.*]] = mul i64 4, %cnt 70; INLINE: call void @llvm.memset.p0i8.i64(i8* align 4 {{.*}}, i8 -1, i64 %[[A]], i1 false) 71; CALL: call void @__msan_poison_stack(i8* {{.*}}, i64 %[[A]]) 72; ORIGIN: call void @__msan_set_alloca_origin4(i8* {{.*}}, i64 %[[A]], 73; KMSAN: call void @__msan_poison_alloca(i8* {{.*}}, i64 %[[A]], 74; CHECK: ret void 75 76; Check that the local is unpoisoned in the absence of sanitize_memory 77define void @unpoison_local() { 78entry: 79 %x = alloca i32, i64 5, align 4 80 ret void 81} 82 83; CHECK-LABEL: define void @unpoison_local( 84; INLINE: call void @llvm.memset.p0i8.i64(i8* align 4 {{.*}}, i8 0, i64 20, i1 false) 85; CALL: call void @llvm.memset.p0i8.i64(i8* align 4 {{.*}}, i8 0, i64 20, i1 false) 86; ORIGIN-NOT: call void @__msan_set_alloca_origin4(i8* {{.*}}, i64 20, 87; KMSAN: call void @__msan_unpoison_alloca(i8* {{.*}}, i64 20) 88; CHECK: ret void 89 90