[PATCH] D35160: Only check shadow memory for operands that are sized.

Matt Morehouse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 9 06:14:52 PDT 2017


morehouse created this revision.
Herald added a subscriber: hiraditya.

Fixes https://bugs.llvm.org/show_bug.cgi?id=33347.


https://reviews.llvm.org/D35160

Files:
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/test/Instrumentation/MemorySanitizer/unsized_type.ll


Index: llvm/test/Instrumentation/MemorySanitizer/unsized_type.ll
===================================================================
--- /dev/null
+++ llvm/test/Instrumentation/MemorySanitizer/unsized_type.ll
@@ -0,0 +1,21 @@
+; Check that unsized token types used by coroutine intrinsics do not get shadow
+; memory checks.
+; RUN: opt < %s -msan -S 2>&1 | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*) #1
+declare i1 @llvm.coro.alloc(token) #2
+
+define void @foo() sanitize_memory {
+entry:
+  %id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
+  %dyn.alloc.reqd = call i1  @llvm.coro.alloc(token %id)
+  ret void
+}
+
+;attributes #1 = { argmemonly nounwind readonly }
+;attributes #2 = { nounwind }
+
+; CHECK-NOT: Assertion{{.*}}failed
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2918,8 +2918,11 @@
     if (ClDumpStrictInstructions)
       dumpInst(I);
     DEBUG(dbgs() << "DEFAULT: " << I << "\n");
-    for (size_t i = 0, n = I.getNumOperands(); i < n; i++)
-      insertShadowCheck(I.getOperand(i), &I);
+    for (size_t i = 0, n = I.getNumOperands(); i < n; i++) {
+      Value *Operand = I.getOperand(i);
+      if (Operand->getType()->isSized())
+        insertShadowCheck(Operand, &I);
+    }
     setShadow(&I, getCleanShadow(&I));
     setOrigin(&I, getCleanOrigin());
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35160.105721.patch
Type: text/x-patch
Size: 1673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170709/79e32b2d/attachment-0001.bin>


More information about the llvm-commits mailing list