fix a fixme in TargetLoweringObjectFile::getExprForDwarfReference

where we used ot create an MCSymbol for ".".  Now emit an assembler
temporary label and reference it instead of "." textually.

rdar://7739457


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98292 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-03-11 21:55:20 +00:00
parent a257095ebb
commit 42263e2e40
5 changed files with 31 additions and 18 deletions

View File

@ -51,6 +51,12 @@ public:
// symbols.
Mangler(const MCAsmInfo &mai) : MAI(mai), NextAnonGlobalID(1) {}
/// getUniqueID() - Allocate and return a unique ID.
/// FIXME: Remove this.
unsigned getUniqueID() {
return NextAnonGlobalID++;
}
/// getNameWithPrefix - Fill OutName with the name of the appropriate prefix
/// and the specified global variable's name. If the global variable doesn't
/// have a name, this fills in a unique name for the global.

View File

@ -208,8 +208,8 @@ public:
///
const MCExpr *
getExprForDwarfReference(const MCSymbol *Sym, MachineModuleInfo *MMI,
unsigned Encoding,
getExprForDwarfReference(const MCSymbol *Sym, Mangler *Mang,
MachineModuleInfo *MMI, unsigned Encoding,
MCStreamer &Streamer) const;
virtual unsigned getPersonalityEncoding() const;

View File

@ -189,7 +189,8 @@ void DwarfPrinter::EmitULEB128(unsigned Value, const char *Desc,
void DwarfPrinter::EmitReference(const MCSymbol *Sym, unsigned Encoding) const {
const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
const MCExpr *Exp = TLOF.getExprForDwarfReference(Sym, Asm->MMI, Encoding,
const MCExpr *Exp = TLOF.getExprForDwarfReference(Sym, Asm->Mang,
Asm->MMI, Encoding,
Asm->OutStreamer);
Asm->OutStreamer.EmitValue(Exp, SizeOfEncodedValue(Encoding), /*addrspace*/0);
}

View File

@ -421,7 +421,7 @@ getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
}
return TargetLoweringObjectFile::
getExprForDwarfReference(Sym, MMI,
getExprForDwarfReference(Sym, Mang, MMI,
Encoding & ~dwarf::DW_EH_PE_indirect, Streamer);
}
@ -784,8 +784,8 @@ getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
}
return TargetLoweringObjectFile::
getExprForDwarfReference(Sym, MMI, Encoding & ~dwarf::DW_EH_PE_indirect,
Streamer);
getExprForDwarfReference(Sym, Mang, MMI,
Encoding & ~dwarf::DW_EH_PE_indirect, Streamer);
}
return TargetLoweringObjectFile::

View File

@ -19,6 +19,7 @@
#include "llvm/GlobalVariable.h"
#include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/Target/Mangler.h"
#include "llvm/Target/TargetData.h"
@ -307,29 +308,34 @@ getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
else
Sym = getContext().GetOrCreateSymbol(Name.str());
return getExprForDwarfReference(Sym, MMI, Encoding, Streamer);
return getExprForDwarfReference(Sym, Mang, MMI, Encoding, Streamer);
}
const MCExpr *TargetLoweringObjectFile::
getExprForDwarfReference(const MCSymbol *Sym, MachineModuleInfo *MMI,
unsigned Encoding, MCStreamer &Streamer) const {
getExprForDwarfReference(const MCSymbol *Sym, Mangler *Mang,
MachineModuleInfo *MMI, unsigned Encoding,
MCStreamer &Streamer) const {
const MCExpr *Res = MCSymbolRefExpr::Create(Sym, getContext());
switch (Encoding & 0xF0) {
default:
llvm_report_error("We do not support this DWARF encoding yet!");
break;
case dwarf::DW_EH_PE_absptr:
// Do nothing special
break;
case dwarf::DW_EH_PE_pcrel:
// FIXME: PCSymbol
const MCExpr *PC = MCSymbolRefExpr::Create(".", getContext());
Res = MCBinaryExpr::CreateSub(Res, PC, getContext());
break;
}
return Res;
case dwarf::DW_EH_PE_pcrel: {
// Emit a label to the streamer for the current position. This gives us
// .-foo addressing.
SmallString<128> Name;
Mang->getNameWithPrefix(Name, Twine("PCtemp") + Twine(Mang->getUniqueID()),
Mangler::Private);
return Res;
MCSymbol *PCSym = getContext().GetOrCreateTemporarySymbol(Name.str());
Streamer.EmitLabel(PCSym);
const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, getContext());
return MCBinaryExpr::CreateSub(Res, PC, getContext());
}
}
}
unsigned TargetLoweringObjectFile::getPersonalityEncoding() const {