• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -msan-check-access-address=0 -S -passes=msan 2>&1 | FileCheck  \
2; RUN: %s
3; RUN: opt < %s -msan -msan-check-access-address=0 -S | FileCheck %s
4; RUN: opt < %s -msan-check-access-address=1 -S -passes=msan 2>&1 | FileCheck  \
5; RUN: %s --check-prefix=ADDR
6; RUN: opt < %s -msan -msan-check-access-address=1 -S | FileCheck %s --check-prefix=ADDR
7; REQUIRES: x86-registered-target
8
9target 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"
10target triple = "x86_64-unknown-linux-gnu"
11
12declare void @llvm.x86.sse.stmxcsr(i8*)
13declare void @llvm.x86.sse.ldmxcsr(i8*)
14
15define void @getcsr(i32 *%p) sanitize_memory {
16entry:
17  %0 = bitcast i32* %p to i8*
18  call void @llvm.x86.sse.stmxcsr(i8* %0)
19  ret void
20}
21
22; CHECK-LABEL: @getcsr(
23; CHECK: store i32 0, i32*
24; CHECK: call void @llvm.x86.sse.stmxcsr(
25; CHECK: ret void
26
27; ADDR-LABEL: @getcsr(
28; ADDR: %[[A:.*]] = load i64, i64* getelementptr inbounds {{.*}} @__msan_param_tls, i32 0, i32 0), align 8
29; ADDR: %[[B:.*]] = icmp ne i64 %[[A]], 0
30; ADDR: br i1 %[[B]], label {{.*}}, label
31; ADDR: call void @__msan_warning_with_origin_noreturn(i32 0)
32; ADDR: call void @llvm.x86.sse.stmxcsr(
33; ADDR: ret void
34
35; Function Attrs: nounwind uwtable
36define void @setcsr(i32 *%p) sanitize_memory {
37entry:
38  %0 = bitcast i32* %p to i8*
39  call void @llvm.x86.sse.ldmxcsr(i8* %0)
40  ret void
41}
42
43; CHECK-LABEL: @setcsr(
44; CHECK: %[[A:.*]] = load i32, i32* %{{.*}}, align 1
45; CHECK: %[[B:.*]] = icmp ne i32 %[[A]], 0
46; CHECK: br i1 %[[B]], label {{.*}}, label
47; CHECK: call void @__msan_warning_with_origin_noreturn(i32 0)
48; CHECK: call void @llvm.x86.sse.ldmxcsr(
49; CHECK: ret void
50
51; ADDR-LABEL: @setcsr(
52; ADDR: %[[A:.*]] = load i64, i64* getelementptr inbounds {{.*}} @__msan_param_tls, i32 0, i32 0), align 8
53; ADDR: %[[B:.*]] = icmp ne i64 %[[A]], 0
54; ADDR: br i1 %[[B]], label {{.*}}, label
55; ADDR: call void @__msan_warning_with_origin_noreturn(i32 0)
56; ADDR: call void @llvm.x86.sse.ldmxcsr(
57; ADDR: ret void
58