summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCSymbol.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2015-12-29 09:32:18 +0000
committerChandler Carruth <chandlerc@gmail.com>2015-12-29 09:32:18 +0000
commit5bd31b37ca5226ac42eb52e79745e9f4d651ec57 (patch)
tree945bdb82a6f6b31d2022a17e6b8e4f15449f9582 /llvm/lib/MC/MCSymbol.cpp
parent6dd8f06db2a6dfcb56eded6d9ff8359b90105191 (diff)
downloadbcm5719-llvm-5bd31b37ca5226ac42eb52e79745e9f4d651ec57.tar.gz
bcm5719-llvm-5bd31b37ca5226ac42eb52e79745e9f4d651ec57.zip
[ptr-traits] Provide a real MCFragment address for the sentinel instead
of casting the integer '4' to such a pointer. There is no reason to expect '4' to be a portable or reliable pointer of this form. The only reason this ever worked is because the PointerIntPair that this actually gets used with has an artificially *low* presumed alignment that allowed it to work. When the alignment of PointerIntPair is derived from the actual type's alignment, the asserts start firing on this pointer. I'm amazed we never managed to do anything that triggered the alignment sanitizer with it, as this is just flat out UB. If folks dislike this approach to providing a sentinel fragment address, there are a myriad of other alternatives, suggestions welcome. But this one has the distinct advantage of not requiring the friend dance of ilist's sentinel (which I'll point out is *also* in play for MCFragment!) and seems to be using a nicely provided facility in MCFragment to establish just such dummy nodes. This is part of a series of patches to allow LLVM to check for complete pointee types when computing its pointer traits. This is absolutely necessary to get correct (or reproducible) results for things like how many low bits are guaranteed to be zero. llvm-svn: 256552
Diffstat (limited to 'llvm/lib/MC/MCSymbol.cpp')
-rw-r--r--llvm/lib/MC/MCSymbol.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCSymbol.cpp b/llvm/lib/MC/MCSymbol.cpp
index c7d6213bc19..ab3b8eb6832 100644
--- a/llvm/lib/MC/MCSymbol.cpp
+++ b/llvm/lib/MC/MCSymbol.cpp
@@ -16,9 +16,11 @@
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
+// Only the address of this fragment is ever actually used.
+static MCDummyFragment SentinelFragment(nullptr);
+
// Sentinel value for the absolute pseudo fragment.
-MCFragment *MCSymbol::AbsolutePseudoFragment =
- reinterpret_cast<MCFragment *>(4);
+MCFragment *MCSymbol::AbsolutePseudoFragment = &SentinelFragment;
void *MCSymbol::operator new(size_t s, const StringMapEntry<bool> *Name,
MCContext &Ctx) {
OpenPOWER on IntegriCloud