summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCSymbol.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/MC/MCSymbol.cpp')
-rw-r--r--llvm/lib/MC/MCSymbol.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCSymbol.cpp b/llvm/lib/MC/MCSymbol.cpp
index 8d07b7605ce..7eba5e0317c 100644
--- a/llvm/lib/MC/MCSymbol.cpp
+++ b/llvm/lib/MC/MCSymbol.cpp
@@ -9,6 +9,7 @@
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/MCAsmInfo.h"
+#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
@@ -18,6 +19,20 @@ using namespace llvm;
// Sentinel value for the absolute pseudo section.
MCSection *MCSymbol::AbsolutePseudoSection = reinterpret_cast<MCSection *>(1);
+void *MCSymbol::operator new(size_t s, NameEntryTy *Name, MCContext &Ctx) {
+ size_t Size = s + (Name ? sizeof(Name) : 0);
+
+ // For safety, ensure that the alignment of a pointer is enough for an
+ // MCSymbol. This also ensures we don't need padding between the name and
+ // symbol.
+ assert(alignOf<MCSymbol>() <= alignof(NameEntryTy *) &&
+ "Bad alignment of MCSymbol");
+ void *Storage = Ctx.allocate(Size, alignof(NameEntryTy *));
+ NameEntryTy **Start = static_cast<NameEntryTy**>(Storage);
+ NameEntryTy **End = Start + (Name ? 1 : 0);
+ return End;
+}
+
void MCSymbol::setVariableValue(const MCExpr *Value) {
assert(!IsUsed && "Cannot set a variable that has already been used.");
assert(Value && "Invalid variable value!");
OpenPOWER on IntegriCloud