summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-12-06 14:53:14 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-12-06 14:53:14 +0000
commit34a06a0802a2c0d73660ab866da657db01b92cae (patch)
tree38ff2ef9ceb22523658b6095c0374a457ec6f047
parentaa0060085d69040bcb0d0b78e443609a32ee0f89 (diff)
downloadbcm5719-llvm-34a06a0802a2c0d73660ab866da657db01b92cae.tar.gz
bcm5719-llvm-34a06a0802a2c0d73660ab866da657db01b92cae.zip
Add an EmitAbsValue helper method and use it in cases where we want to be sure
that no relocations are used (on MochO). Fixes llc producing different output from llc + llvm-mc. llvm-svn: 121000
-rw-r--r--llvm/include/llvm/MC/MCStreamer.h5
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp2
-rw-r--r--llvm/lib/MC/MCDwarf.cpp11
-rw-r--r--llvm/lib/MC/MCStreamer.cpp6
4 files changed, 14 insertions, 10 deletions
diff --git a/llvm/include/llvm/MC/MCStreamer.h b/llvm/include/llvm/MC/MCStreamer.h
index d89ee9ae126..fce076a57eb 100644
--- a/llvm/include/llvm/MC/MCStreamer.h
+++ b/llvm/include/llvm/MC/MCStreamer.h
@@ -249,6 +249,11 @@ namespace llvm {
virtual void EmitIntValue(uint64_t Value, unsigned Size,
unsigned AddrSpace = 0);
+ /// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO
+ /// this is done by producing
+ /// foo = value
+ /// .long foo
+ void EmitAbsValue(const MCExpr *Value, unsigned Size);
virtual void EmitULEB128Value(const MCExpr *Value,
unsigned AddrSpace = 0) = 0;
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
index f737e90b155..1f7ac95f7b3 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
@@ -156,7 +156,7 @@ void AsmPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const {
const MCExpr *Exp =
TLOF.getExprForDwarfReference(Sym, Mang, MMI, Encoding, OutStreamer);
- OutStreamer.EmitValue(Exp, GetSizeOfEncodedValue(Encoding), /*addrspace*/0);
+ OutStreamer.EmitAbsValue(Exp, GetSizeOfEncodedValue(Encoding));
}
void AsmPrinter::EmitReference(const GlobalValue *GV, unsigned Encoding)const{
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 53731dca7eb..5d36ee3e626 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -213,15 +213,8 @@ void MCDwarfFileTable::Emit(MCStreamer *MCOS,
// The first 4 bytes is the total length of the information for this
// compilation unit (not including these 4 bytes for the length).
- // FIXME: We create the dummy TotalLength variable because LineEndSym points
- // to the end of the section and the darwin assembler doesn't consider that
- // difference an assembly time constant. It might be better for this to be
- // proected by a flag.
- MCSymbol *TotalLength = MCOS->getContext().CreateTempSymbol();
- MCOS->EmitAssignment(TotalLength,
- MakeStartMinusEndExpr(MCOS, LineStartSym, LineEndSym,
- 4));
- MCOS->EmitSymbolValue(TotalLength, 4, 0);
+ MCOS->EmitAbsValue(MakeStartMinusEndExpr(MCOS, LineStartSym, LineEndSym,4),
+ 4);
// Next 2 bytes is the Version, which is Dwarf 2.
MCOS->EmitIntValue(2, 2);
diff --git a/llvm/lib/MC/MCStreamer.cpp b/llvm/lib/MC/MCStreamer.cpp
index 6df4ae44e40..b9d59056f3b 100644
--- a/llvm/lib/MC/MCStreamer.cpp
+++ b/llvm/lib/MC/MCStreamer.cpp
@@ -72,6 +72,12 @@ void MCStreamer::EmitSLEB128IntValue(int64_t Value, unsigned AddrSpace) {
EmitBytes(OSE.str(), AddrSpace);
}
+void MCStreamer::EmitAbsValue(const MCExpr *Value, unsigned Size) {
+ MCSymbol *ABS = getContext().CreateTempSymbol();
+ EmitAssignment(ABS, Value);
+ EmitSymbolValue(ABS, Size, 0);
+}
+
void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
unsigned AddrSpace) {
EmitValue(MCSymbolRefExpr::Create(Sym, getContext()), Size, AddrSpace);
OpenPOWER on IntegriCloud