diff options
-rw-r--r-- | llvm/include/llvm/CodeGen/MachineFunction.h | 3 | ||||
-rw-r--r-- | llvm/include/llvm/Support/Compiler.h | 8 | ||||
-rw-r--r-- | llvm/include/llvm/Transforms/Utils/MemorySSA.h | 4 |
3 files changed, 14 insertions, 1 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h index 4b1b5f43ae8..640f8dbc831 100644 --- a/llvm/include/llvm/CodeGen/MachineFunction.h +++ b/llvm/include/llvm/CodeGen/MachineFunction.h @@ -24,6 +24,7 @@ #include "llvm/IR/Metadata.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/ArrayRecycler.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Recycler.h" namespace llvm { @@ -50,6 +51,8 @@ struct ilist_traits<MachineBasicBlock> : public ilist_default_traits<MachineBasicBlock> { mutable ilist_half_node<MachineBasicBlock> Sentinel; public: + // FIXME: This downcast is UB. See llvm.org/PR26753. + LLVM_NO_SANITIZE("object-size") MachineBasicBlock *createSentinel() const { return static_cast<MachineBasicBlock*>(&Sentinel); } diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h index d28151cfc15..45a70bd815b 100644 --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -415,6 +415,14 @@ void AnnotateIgnoreWritesEnd(const char *file, int line); # define TsanIgnoreWritesEnd() #endif +/// \macro LLVM_NO_SANITIZE +/// \brief Disable a particular sanitizer for a function. +#if __has_attribute(no_sanitize) +#define LLVM_NO_SANITIZE(KIND) __attribute__((no_sanitize(KIND))) +#else +#define LLVM_NO_SANITIZE(KIND) +#endif + /// \brief Mark debug helper function definitions like dump() that should not be /// stripped from debug builds. // FIXME: Move this to a private config.h as it's not usable in public headers. diff --git a/llvm/include/llvm/Transforms/Utils/MemorySSA.h b/llvm/include/llvm/Transforms/Utils/MemorySSA.h index 2881669e2b5..4ae5a7b4c21 100644 --- a/llvm/include/llvm/Transforms/Utils/MemorySSA.h +++ b/llvm/include/llvm/Transforms/Utils/MemorySSA.h @@ -86,6 +86,7 @@ #include "llvm/IR/User.h" #include "llvm/IR/Value.h" #include "llvm/Pass.h" +#include "llvm/Support/Compiler.h" namespace llvm { class BasicBlock; @@ -153,7 +154,8 @@ private: template <> struct ilist_traits<MemoryAccess> : public ilist_default_traits<MemoryAccess> { /// See details of the instruction class for why this trick works - /// FIXME: The downcast is UB. + // FIXME: This downcast is UB. See llvm.org/PR26753. + LLVM_NO_SANITIZE("object-size") MemoryAccess *createSentinel() const { return static_cast<MemoryAccess *>(&Sentinel); } |