[llvm-commits] [llvm] r121000 - in /llvm/trunk: include/llvm/MC/MCStreamer.h lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp lib/MC/MCDwarf.cpp lib/MC/MCStreamer.cpp

Rafael Espindola rafael.espindola at gmail.com
Mon Dec 6 06:53:14 PST 2010


Author: rafael
Date: Mon Dec  6 08:53:14 2010
New Revision: 121000

URL: http://llvm.org/viewvc/llvm-project?rev=121000&view=rev
Log:
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.

Modified:
    llvm/trunk/include/llvm/MC/MCStreamer.h
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
    llvm/trunk/lib/MC/MCDwarf.cpp
    llvm/trunk/lib/MC/MCStreamer.cpp

Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=121000&r1=120999&r2=121000&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Mon Dec  6 08:53:14 2010
@@ -249,6 +249,11 @@
     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;

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp?rev=121000&r1=120999&r2=121000&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinterDwarf.cpp Mon Dec  6 08:53:14 2010
@@ -156,7 +156,7 @@
   
   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{

Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=121000&r1=120999&r2=121000&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Mon Dec  6 08:53:14 2010
@@ -213,15 +213,8 @@
 
   // 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);

Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=121000&r1=120999&r2=121000&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Mon Dec  6 08:53:14 2010
@@ -72,6 +72,12 @@
   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);





More information about the llvm-commits mailing list