diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 696d024aa85..6359ccefe63 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -191,6 +191,11 @@ namespace llvm { /// EmitIntValue - Special case of EmitValue that avoids the client having /// to pass in a MCExpr for constant integers. virtual void EmitIntValue(uint64_t Value, unsigned Size,unsigned AddrSpace); + + /// EmitSymbolValue - Special case of EmitValue that avoids the client + /// having to pass in a MCExpr for MCSymbols. + virtual void EmitSymbolValue(const MCSymbol *Sym, unsigned Size, + unsigned AddrSpace); /// EmitGPRel32Value - Emit the expression @p Value into the output as a /// gprel32 (32-bit GP relative) value. diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index 5db2b0749d5..246538b8c20 100644 --- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -914,9 +914,7 @@ void AsmPrinter::EmitLabelDifference(const MCSymbol *Hi, const MCSymbol *Lo, OutContext.GetOrCreateSymbol(Twine(MAI->getPrivateGlobalPrefix()) + "set" + Twine(SetCounter++)); OutStreamer.EmitAssignment(SetLabel, Diff); - - OutStreamer.EmitValue(MCSymbolRefExpr::Create(SetLabel, OutContext), - Size, 0/*AddrSpace*/); + OutStreamer.EmitSymbolValue(SetLabel, Size, 0/*AddrSpace*/); } diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 7ca94de980d..8272eabe845 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -10,12 +10,12 @@ // This file contains support for writing dwarf debug info into asm files. // //===----------------------------------------------------------------------===// + #define DEBUG_TYPE "dwarfdebug" #include "DwarfDebug.h" #include "llvm/Module.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineModuleInfo.h" -#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCSection.h" #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCAsmInfo.h" @@ -2970,9 +2970,7 @@ void DwarfDebug::emitDebugInlineInfo() { Asm->EmitInt32(LI->second->getOffset()); if (Asm->VerboseAsm) Asm->OutStreamer.AddComment("low_pc"); - Asm->OutStreamer.EmitValue(MCSymbolRefExpr::Create(LI->first, - Asm->OutContext), - TD->getPointerSize(), 0/*AddrSpace*/); + Asm->OutStreamer.EmitSymbolValue(LI->first, TD->getPointerSize(), 0); } } diff --git a/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp b/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp index 3eee56181e1..d0f2a60bcf2 100644 --- a/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfPrinter.cpp @@ -258,8 +258,7 @@ void DwarfPrinter::EmitSectionOffset(const MCSymbol *Label, O << SecOffDir << Label->getName(); else { unsigned Size = IsSmall ? 4 : TD->getPointerSize(); - Asm->OutStreamer.EmitValue(MCSymbolRefExpr::Create(Label, Asm->OutContext), - Size, 0/*AddrSpace*/); + Asm->OutStreamer.EmitSymbolValue(Label, Size, 0/*AddrSpace*/); } } diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp index 15b30794d91..703acc4e599 100644 --- a/lib/MC/MCStreamer.cpp +++ b/lib/MC/MCStreamer.cpp @@ -31,6 +31,11 @@ void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size, EmitValue(MCConstantExpr::Create(Value, getContext()), Size, AddrSpace); } +void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size, + unsigned AddrSpace) { + EmitValue(MCSymbolRefExpr::Create(Sym, getContext()), Size, AddrSpace); +} + /// EmitFill - Emit NumBytes bytes worth of the value specified by /// FillValue. This implements directives such as '.space'. void MCStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue,