[PATCH] D15607: [sanitizer] [msan] Fix origin store of array types

Adhemerval Zanella via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 11 08:28:06 PST 2016


zatrazz updated this revision to Diff 44516.
zatrazz added a comment.

Changes from previous version:

- Drop the extract array logic in favor or handling as the struct type.


http://reviews.llvm.org/D15607

Files:
  lib/Transforms/Instrumentation/MemorySanitizer.cpp
  test/Instrumentation/MemorySanitizer/origin-array.ll

Index: test/Instrumentation/MemorySanitizer/origin-array.ll
===================================================================
--- /dev/null
+++ test/Instrumentation/MemorySanitizer/origin-array.ll
@@ -0,0 +1,23 @@
+; RUN: opt < %s -msan -msan-check-access-address=0 -msan-track-origins=2 -S | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-gnu"
+
+; Check origin handling of array types.
+
+define void @foo([2 x i64] %v, [2 x i64]* %p) sanitize_memory {
+entry:
+  store [2 x i64] %v, [2 x i64]* %p, align 8
+  ret void
+}
+
+; CHECK-LABEL: @foo
+; CHECK: [[PARAM:%[01-9a-z]+]] = load {{.*}} @__msan_param_tls
+; CHECK: [[ORIGIN:%[01-9a-z]+]] = load {{.*}} @__msan_param_origin_tls
+
+; CHECK: [[TMP1:%[01-9a-z]+]] = ptrtoint
+; CHECK: [[TMP2:%[01-9a-z]+]] = xor i64 [[TMP1]]
+; CHECK: [[TMP3:%[01-9a-z]+]] = inttoptr i64 [[TMP2]] to [2 x i64]*
+; CHECK: store [2 x i64] [[PARAM]], [2 x i64]* [[TMP3]]
+
+; CHECK: {{.*}} call i32 @__msan_chain_origin(i32 {{.*}}[[ORIGIN]])
Index: lib/Transforms/Instrumentation/MemorySanitizer.cpp
===================================================================
--- lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -692,7 +692,7 @@
     const DataLayout &DL = F.getParent()->getDataLayout();
     unsigned OriginAlignment = std::max(kMinOriginAlignment, Alignment);
     unsigned StoreSize = DL.getTypeStoreSize(Shadow->getType());
-    if (isa<StructType>(Shadow->getType())) {
+    if (Shadow->getType()->isAggregateType()) {
       paintOrigin(IRB, updateOrigin(Origin, IRB),
                   getOriginPtr(Addr, IRB, Alignment), StoreSize,
                   OriginAlignment);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15607.44516.patch
Type: text/x-patch
Size: 1747 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160111/e40c55b1/attachment.bin>


More information about the llvm-commits mailing list