[llvm] 8ca7871 - Reinstate MSan suppression of PR24578.

Evgenii Stepanov via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 22 11:25:37 PST 2019


Author: Evgenii Stepanov
Date: 2019-11-22T11:25:24-08:00
New Revision: 8ca7871addc53a8ddb356ae8b99fa6f7e0e8dd15

URL: https://github.com/llvm/llvm-project/commit/8ca7871addc53a8ddb356ae8b99fa6f7e0e8dd15
DIFF: https://github.com/llvm/llvm-project/commit/8ca7871addc53a8ddb356ae8b99fa6f7e0e8dd15.diff

LOG: Reinstate MSan suppression of PR24578.

Summary:
Revert "Rollback of commit "Repress sanitization on User dtor.""

There is no point in keeping an active MSan error in the codebase.
PR24578 tracks the actual UB in LLVM code; this change enables testing
of LLVM with MSAN + -fsanitize-memory-use-after-dtor.

This reverts commit 21c1bc46aee2b69c2c48db8e961f0ce8394f21e1.

Reviewers: vitalybuka

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

Added: 
    

Modified: 
    llvm/include/llvm/Support/Compiler.h
    llvm/lib/IR/Metadata.cpp
    llvm/lib/IR/User.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h
index cb7e57d4cd21..051e0e5da9c4 100644
--- a/llvm/include/llvm/Support/Compiler.h
+++ b/llvm/include/llvm/Support/Compiler.h
@@ -406,10 +406,12 @@
 #if __has_feature(memory_sanitizer)
 # define LLVM_MEMORY_SANITIZER_BUILD 1
 # include <sanitizer/msan_interface.h>
+# define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE __attribute__((no_sanitize_memory))
 #else
 # define LLVM_MEMORY_SANITIZER_BUILD 0
 # define __msan_allocated_memory(p, size)
 # define __msan_unpoison(p, size)
+# define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE
 #endif
 
 /// \macro LLVM_ADDRESS_SANITIZER_BUILD

diff  --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp
index 62c2aa86f3b0..708a7daa09bc 100644
--- a/llvm/lib/IR/Metadata.cpp
+++ b/llvm/lib/IR/Metadata.cpp
@@ -489,7 +489,9 @@ void *MDNode::operator new(size_t Size, unsigned NumOps) {
   return Ptr;
 }
 
-void MDNode::operator delete(void *Mem) {
+// Repress memory sanitization, due to use-after-destroy by operator
+// delete. Bug report 24578 identifies this issue.
+LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE void MDNode::operator delete(void *Mem) {
   MDNode *N = static_cast<MDNode *>(Mem);
   size_t OpSize = N->NumOperands * sizeof(MDOperand);
   OpSize = alignTo(OpSize, alignof(uint64_t));

diff  --git a/llvm/lib/IR/User.cpp b/llvm/lib/IR/User.cpp
index 33a3686c94a1..4a3eba9e8cf7 100644
--- a/llvm/lib/IR/User.cpp
+++ b/llvm/lib/IR/User.cpp
@@ -162,7 +162,9 @@ void *User::operator new(size_t Size) {
 //                         User operator delete Implementation
 //===----------------------------------------------------------------------===//
 
-void User::operator delete(void *Usr) {
+// Repress memory sanitization, due to use-after-destroy by operator
+// delete. Bug report 24578 identifies this issue.
+LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE void User::operator delete(void *Usr) {
   // Hung off uses use a single Use* before the User, while other subclasses
   // use a Use[] allocated prior to the user.
   User *Obj = static_cast<User *>(Usr);


        


More information about the llvm-commits mailing list