Skip to content

Commit 8ca7871

Browse files
committed
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 21c1bc4. Reviewers: vitalybuka Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70611
1 parent 97e0fd2 commit 8ca7871

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

llvm/include/llvm/Support/Compiler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,10 +406,12 @@
406406
#if __has_feature(memory_sanitizer)
407407
# define LLVM_MEMORY_SANITIZER_BUILD 1
408408
# include <sanitizer/msan_interface.h>
409+
# define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE __attribute__((no_sanitize_memory))
409410
#else
410411
# define LLVM_MEMORY_SANITIZER_BUILD 0
411412
# define __msan_allocated_memory(p, size)
412413
# define __msan_unpoison(p, size)
414+
# define LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE
413415
#endif
414416

415417
/// \macro LLVM_ADDRESS_SANITIZER_BUILD

llvm/lib/IR/Metadata.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,9 @@ void *MDNode::operator new(size_t Size, unsigned NumOps) {
489489
return Ptr;
490490
}
491491

492-
void MDNode::operator delete(void *Mem) {
492+
// Repress memory sanitization, due to use-after-destroy by operator
493+
// delete. Bug report 24578 identifies this issue.
494+
LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE void MDNode::operator delete(void *Mem) {
493495
MDNode *N = static_cast<MDNode *>(Mem);
494496
size_t OpSize = N->NumOperands * sizeof(MDOperand);
495497
OpSize = alignTo(OpSize, alignof(uint64_t));

llvm/lib/IR/User.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,9 @@ void *User::operator new(size_t Size) {
162162
// User operator delete Implementation
163163
//===----------------------------------------------------------------------===//
164164

165-
void User::operator delete(void *Usr) {
165+
// Repress memory sanitization, due to use-after-destroy by operator
166+
// delete. Bug report 24578 identifies this issue.
167+
LLVM_NO_SANITIZE_MEMORY_ATTRIBUTE void User::operator delete(void *Usr) {
166168
// Hung off uses use a single Use* before the User, while other subclasses
167169
// use a Use[] allocated prior to the user.
168170
User *Obj = static_cast<User *>(Usr);

0 commit comments

Comments
 (0)