diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-09-24 11:20:27 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-09-24 11:20:27 +0000 |
commit | ecf0fcd2b17ccc71b2a7b5849c1416aeb48a9390 (patch) | |
tree | 0a20c8f3b5ca6d8421ec9622e57489372a6d7385 /test/Instrumentation | |
parent | ae1fb8fc19dcfd2f0e33a36f40d687b08dcc9a6b (diff) | |
download | external_llvm-ecf0fcd2b17ccc71b2a7b5849c1416aeb48a9390.zip external_llvm-ecf0fcd2b17ccc71b2a7b5849c1416aeb48a9390.tar.gz external_llvm-ecf0fcd2b17ccc71b2a7b5849c1416aeb48a9390.tar.bz2 |
[msan] Handling of atomic load/store, atomic rmw, cmpxchg.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191287 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Instrumentation')
-rw-r--r-- | test/Instrumentation/MemorySanitizer/atomics.ll | 189 | ||||
-rw-r--r-- | test/Instrumentation/MemorySanitizer/msan_basic.ll | 8 |
2 files changed, 193 insertions, 4 deletions
diff --git a/test/Instrumentation/MemorySanitizer/atomics.ll b/test/Instrumentation/MemorySanitizer/atomics.ll new file mode 100644 index 0000000..ff02452 --- /dev/null +++ b/test/Instrumentation/MemorySanitizer/atomics.ll @@ -0,0 +1,189 @@ +; RUN: opt < %s -msan -msan-check-access-address=0 -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" + +; atomicrmw xchg: store clean shadow, return clean shadow + +define i32 @AtomicRmwXchg(i32* %p, i32 %x) sanitize_memory { +entry: + %0 = atomicrmw xchg i32* %p, i32 %x seq_cst + ret i32 %0 +} + +; CHECK: @AtomicRmwXchg +; CHECK: store i32 0, +; CHECK: atomicrmw xchg {{.*}} seq_cst +; CHECK: store i32 0, {{.*}} @__msan_retval_tls +; CHECK: ret i32 + + +; atomicrmw max: exactly the same as above + +define i32 @AtomicRmwMax(i32* %p, i32 %x) sanitize_memory { +entry: + %0 = atomicrmw max i32* %p, i32 %x seq_cst + ret i32 %0 +} + +; CHECK: @AtomicRmwMax +; CHECK: store i32 0, +; CHECK: atomicrmw max {{.*}} seq_cst +; CHECK: store i32 0, {{.*}} @__msan_retval_tls +; CHECK: ret i32 + + +; cmpxchg: the same as above, but also check %a shadow + +define i32 @Cmpxchg(i32* %p, i32 %a, i32 %b) sanitize_memory { +entry: + %0 = cmpxchg i32* %p, i32 %a, i32 %b seq_cst + ret i32 %0 +} + +; CHECK: @Cmpxchg +; CHECK: store i32 0, +; CHECK: icmp +; CHECK: br +; CHECK: @__msan_warning +; CHECK: cmpxchg {{.*}} seq_cst +; CHECK: store i32 0, {{.*}} @__msan_retval_tls +; CHECK: ret i32 + + +; relaxed cmpxchg: bump up to "release" + +define i32 @CmpxchgMonotonic(i32* %p, i32 %a, i32 %b) sanitize_memory { +entry: + %0 = cmpxchg i32* %p, i32 %a, i32 %b monotonic + ret i32 %0 +} + +; CHECK: @CmpxchgMonotonic +; CHECK: store i32 0, +; CHECK: icmp +; CHECK: br +; CHECK: @__msan_warning +; CHECK: cmpxchg {{.*}} release +; CHECK: store i32 0, {{.*}} @__msan_retval_tls +; CHECK: ret i32 + + +; atomic load: preserve alignment, load shadow value after app value + +define i32 @AtomicLoad(i32* %p) sanitize_memory { +entry: + %0 = load atomic i32* %p seq_cst, align 16 + ret i32 %0 +} + +; CHECK: @AtomicLoad +; CHECK: load atomic i32* {{.*}} seq_cst, align 16 +; CHECK: [[SHADOW:%[01-9a-z_]+]] = load i32* {{.*}}, align 16 +; CHECK: store i32 {{.*}}[[SHADOW]], {{.*}} @__msan_retval_tls +; CHECK: ret i32 + + +; atomic load: preserve alignment, load shadow value after app value + +define i32 @AtomicLoadAcquire(i32* %p) sanitize_memory { +entry: + %0 = load atomic i32* %p acquire, align 16 + ret i32 %0 +} + +; CHECK: @AtomicLoadAcquire +; CHECK: load atomic i32* {{.*}} acquire, align 16 +; CHECK: [[SHADOW:%[01-9a-z_]+]] = load i32* {{.*}}, align 16 +; CHECK: store i32 {{.*}}[[SHADOW]], {{.*}} @__msan_retval_tls +; CHECK: ret i32 + + +; atomic load monotonic: bump up to load acquire + +define i32 @AtomicLoadMonotonic(i32* %p) sanitize_memory { +entry: + %0 = load atomic i32* %p monotonic, align 16 + ret i32 %0 +} + +; CHECK: @AtomicLoadMonotonic +; CHECK: load atomic i32* {{.*}} acquire, align 16 +; CHECK: [[SHADOW:%[01-9a-z_]+]] = load i32* {{.*}}, align 16 +; CHECK: store i32 {{.*}}[[SHADOW]], {{.*}} @__msan_retval_tls +; CHECK: ret i32 + + +; atomic load unordered: bump up to load acquire + +define i32 @AtomicLoadUnordered(i32* %p) sanitize_memory { +entry: + %0 = load atomic i32* %p unordered, align 16 + ret i32 %0 +} + +; CHECK: @AtomicLoadUnordered +; CHECK: load atomic i32* {{.*}} acquire, align 16 +; CHECK: [[SHADOW:%[01-9a-z_]+]] = load i32* {{.*}}, align 16 +; CHECK: store i32 {{.*}}[[SHADOW]], {{.*}} @__msan_retval_tls +; CHECK: ret i32 + + +; atomic store: preserve alignment, store clean shadow value before app value + +define void @AtomicStore(i32* %p, i32 %x) sanitize_memory { +entry: + store atomic i32 %x, i32* %p seq_cst, align 16 + ret void +} + +; CHECK: @AtomicStore +; CHECK-NOT: @__msan_param_tls +; CHECK: store i32 0, i32* {{.*}}, align 16 +; CHECK: store atomic i32 %x, i32* %p seq_cst, align 16 +; CHECK: ret void + + +; atomic store: preserve alignment, store clean shadow value before app value + +define void @AtomicStoreRelease(i32* %p, i32 %x) sanitize_memory { +entry: + store atomic i32 %x, i32* %p release, align 16 + ret void +} + +; CHECK: @AtomicStoreRelease +; CHECK-NOT: @__msan_param_tls +; CHECK: store i32 0, i32* {{.*}}, align 16 +; CHECK: store atomic i32 %x, i32* %p release, align 16 +; CHECK: ret void + + +; atomic store monotonic: bumped up to store release + +define void @AtomicStoreMonotonic(i32* %p, i32 %x) sanitize_memory { +entry: + store atomic i32 %x, i32* %p monotonic, align 16 + ret void +} + +; CHECK: @AtomicStoreMonotonic +; CHECK-NOT: @__msan_param_tls +; CHECK: store i32 0, i32* {{.*}}, align 16 +; CHECK: store atomic i32 %x, i32* %p release, align 16 +; CHECK: ret void + + +; atomic store unordered: bumped up to store release + +define void @AtomicStoreUnordered(i32* %p, i32 %x) sanitize_memory { +entry: + store atomic i32 %x, i32* %p unordered, align 16 + ret void +} + +; CHECK: @AtomicStoreUnordered +; CHECK-NOT: @__msan_param_tls +; CHECK: store i32 0, i32* {{.*}}, align 16 +; CHECK: store atomic i32 %x, i32* %p release, align 16 +; CHECK: ret void diff --git a/test/Instrumentation/MemorySanitizer/msan_basic.ll b/test/Instrumentation/MemorySanitizer/msan_basic.ll index e87bf53..02c03ef 100644 --- a/test/Instrumentation/MemorySanitizer/msan_basic.ll +++ b/test/Instrumentation/MemorySanitizer/msan_basic.ll @@ -442,8 +442,8 @@ define i32 @ShadowLoadAlignmentLarge() nounwind uwtable sanitize_memory { } ; CHECK: @ShadowLoadAlignmentLarge -; CHECK: load i32* {{.*}} align 64 ; CHECK: load volatile i32* {{.*}} align 64 +; CHECK: load i32* {{.*}} align 64 ; CHECK: ret i32 define i32 @ShadowLoadAlignmentSmall() nounwind uwtable sanitize_memory { @@ -453,14 +453,14 @@ define i32 @ShadowLoadAlignmentSmall() nounwind uwtable sanitize_memory { } ; CHECK: @ShadowLoadAlignmentSmall -; CHECK: load i32* {{.*}} align 2 ; CHECK: load volatile i32* {{.*}} align 2 +; CHECK: load i32* {{.*}} align 2 ; CHECK: ret i32 ; CHECK-ORIGINS: @ShadowLoadAlignmentSmall +; CHECK-ORIGINS: load volatile i32* {{.*}} align 2 ; CHECK-ORIGINS: load i32* {{.*}} align 2 ; CHECK-ORIGINS: load i32* {{.*}} align 4 -; CHECK-ORIGINS: load volatile i32* {{.*}} align 2 ; CHECK-ORIGINS: ret i32 @@ -600,8 +600,8 @@ define <8 x i8*> @VectorOfPointers(<8 x i8*>* %p) nounwind uwtable sanitize_memo } ; CHECK: @VectorOfPointers -; CHECK: load <8 x i64>* ; CHECK: load <8 x i8*>* +; CHECK: load <8 x i64>* ; CHECK: store <8 x i64> {{.*}} @__msan_retval_tls ; CHECK: ret <8 x i8*> |