From 9f952dd0f6f0c0cda8ee9a15701ce28e6dd5a3bc Mon Sep 17 00:00:00 2001 From: Naomi Musgrave Date: Mon, 31 Aug 2015 18:49:31 +0000 Subject: [PATCH] Undo reversion on commit: Revert "Revert "Repress sanitization on User dtor. Modify msan macros for applying attribute"" This reverts commit 020e70a79878c96457e6882bcdfaf6628baf32b7. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246470 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/User.h | 3 +-- include/llvm/Support/Compiler.h | 2 ++ lib/IR/Metadata.cpp | 4 +++- lib/IR/User.cpp | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/include/llvm/IR/User.h b/include/llvm/IR/User.h index 93614fab575..160f32819b0 100644 --- a/include/llvm/IR/User.h +++ b/include/llvm/IR/User.h @@ -72,8 +72,7 @@ protected: void growHungoffUses(unsigned N, bool IsPhi = false); public: - ~User() override { - } + ~User() override {} /// \brief Free memory allocated for User and Use objects. void operator delete(void *Usr); /// \brief Placement delete - required by std, but never called. diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 9f98bc398fe..bd197e2308c 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -323,10 +323,12 @@ #if __has_feature(memory_sanitizer) # define LLVM_MEMORY_SANITIZER_BUILD 1 # include +# 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/lib/IR/Metadata.cpp b/lib/IR/Metadata.cpp index 7d8c3523743..51548a82576 100644 --- a/lib/IR/Metadata.cpp +++ b/lib/IR/Metadata.cpp @@ -401,7 +401,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(Mem); size_t OpSize = N->NumOperands * sizeof(MDOperand); OpSize = RoundUpToAlignment(OpSize, llvm::alignOf()); diff --git a/lib/IR/User.cpp b/lib/IR/User.cpp index 522722d701b..b64580ce043 100644 --- a/lib/IR/User.cpp +++ b/lib/IR/User.cpp @@ -118,7 +118,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(Usr); -- 2.34.1