1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00
llvm-mirror/test/Instrumentation/MemorySanitizer/store-long-origin.ll
Philip Pfaffe 65df098609 [NewPM] Port Msan
Summary:
Keeping msan a function pass requires replacing the module level initialization:
That means, don't define a ctor function which calls __msan_init, instead just
declare the init function at the first access, and add that to the global ctors
list.

Changes:
- Pull the actual sanitizer and the wrapper pass apart.
- Add a newpm msan pass. The function pass inserts calls to runtime
  library functions, for which it inserts declarations as necessary.
- Update tests.

Caveats:
- There is one test that I dropped, because it specifically tested the
  definition of the ctor.

Reviewers: chandlerc, fedor.sergeev, leonardchan, vitalybuka

Subscribers: sdardis, nemanjai, javed.absar, hiraditya, kbarton, bollu, atanasyan, jsji

Differential Revision: https://reviews.llvm.org/D55647

llvm-svn: 350305
2019-01-03 13:42:44 +00:00

92 lines
2.7 KiB
LLVM

; RUN: opt < %s -msan-check-access-address=0 -msan-track-origins=1 -S \
; RUN: -passes=msan 2>&1 | FileCheck %s
; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=1 -S | FileCheck %s
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"
target triple = "x86_64-unknown-linux-gnu"
; Test origin for longer stores.
define void @Store8(i64* nocapture %p, i64 %x) sanitize_memory {
entry:
store i64 %x, i64* %p, align 8
ret void
}
; Single 8-byte origin store
; CHECK-LABEL: define void @Store8(
; CHECK: store i64 {{.*}}, align 8
; CHECK: store i64 {{.*}}, align 8
; CHECK: store i64 {{.*}}, align 8
; CHECK: ret void
define void @Store8_align4(i64* nocapture %p, i64 %x) sanitize_memory {
entry:
store i64 %x, i64* %p, align 4
ret void
}
; Two 4-byte origin stores
; CHECK-LABEL: define void @Store8_align4(
; CHECK: store i64 {{.*}}, align 4
; CHECK: store i32 {{.*}}, align 4
; CHECK: getelementptr i32, i32* {{.*}}, i32 1
; CHECK: store i32 {{.*}}, align 4
; CHECK: store i64 {{.*}}, align 4
; CHECK: ret void
%struct.S = type { i32, i32, i32 }
define void @StoreAgg(%struct.S* nocapture %p, %struct.S %x) sanitize_memory {
entry:
store %struct.S %x, %struct.S* %p, align 4
ret void
}
; Three 4-byte origin stores
; CHECK-LABEL: define void @StoreAgg(
; CHECK: store { i32, i32, i32 } {{.*}}, align 4
; CHECK: store i32 {{.*}}, align 4
; CHECK: getelementptr i32, i32* {{.*}}, i32 1
; CHECK: store i32 {{.*}}, align 4
; CHECK: getelementptr i32, i32* {{.*}}, i32 2
; CHECK: store i32 {{.*}}, align 4
; CHECK: store %struct.S {{.*}}, align 4
; CHECK: ret void
define void @StoreAgg8(%struct.S* nocapture %p, %struct.S %x) sanitize_memory {
entry:
store %struct.S %x, %struct.S* %p, align 8
ret void
}
; 8-byte + 4-byte origin stores
; CHECK-LABEL: define void @StoreAgg8(
; CHECK: store { i32, i32, i32 } {{.*}}, align 8
; CHECK: store i64 {{.*}}, align 8
; CHECK: getelementptr i32, i32* {{.*}}, i32 2
; CHECK: store i32 {{.*}}, align 8
; CHECK: store %struct.S {{.*}}, align 8
; CHECK: ret void
%struct.Q = type { i64, i64, i64 }
define void @StoreAgg24(%struct.Q* nocapture %p, %struct.Q %x) sanitize_memory {
entry:
store %struct.Q %x, %struct.Q* %p, align 8
ret void
}
; 3 8-byte origin stores
; CHECK-LABEL: define void @StoreAgg24(
; CHECK: store { i64, i64, i64 } {{.*}}, align 8
; CHECK: store i64 {{.*}}, align 8
; CHECK: getelementptr i64, i64* {{.*}}, i32 1
; CHECK: store i64 {{.*}}, align 8
; CHECK: getelementptr i64, i64* {{.*}}, i32 2
; CHECK: store i64 {{.*}}, align 8
; CHECK: store %struct.Q {{.*}}, align 8
; CHECK: ret void