X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FTargetLoweringObjectFile.cpp;h=dd7b532bbfbaef701376d24ce1aea43711b8ea63;hb=3bababf880bfeaf1bcda7e4f808007621b6bfac8;hp=8c12039516b590a49001f45177b17a0a7c6022e4;hpb=09d53fecfcc93377627b6ee7b4d92f8a6ff152e9;p=oota-llvm.git diff --git a/lib/Target/TargetLoweringObjectFile.cpp b/lib/Target/TargetLoweringObjectFile.cpp index 8c12039516b..dd7b532bbfb 100644 --- a/lib/Target/TargetLoweringObjectFile.cpp +++ b/lib/Target/TargetLoweringObjectFile.cpp @@ -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" @@ -100,7 +101,7 @@ static bool IsNullTerminatedString(const Constant *C) { ConstantInt *Null = dyn_cast(CVA->getOperand(ATy->getNumElements()-1)); - if (Null == 0 || Null->getZExtValue() != 0) + if (Null == 0 || !Null->isZero()) return false; // Not null terminated. // Verify that the null doesn't occur anywhere else in the string. @@ -290,45 +291,38 @@ TargetLoweringObjectFile::getSectionForConstant(SectionKind Kind) const { return DataSection; } -/// getSymbolForDwarfGlobalReference - Return an MCExpr to use for a +/// getExprForDwarfGlobalReference - Return an MCExpr to use for a /// reference to the specified global variable from exception /// handling information. const MCExpr *TargetLoweringObjectFile:: -getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, - MachineModuleInfo *MMI, unsigned Encoding) const { - // FIXME: Use GetGlobalValueSymbol. - SmallString<128> Name; - Mang->getNameWithPrefix(Name, GV, false); - const MCSymbol *Sym; - - if (GV->hasPrivateLinkage()) - Sym = getContext().GetOrCreateTemporarySymbol(Name.str()); - else - Sym = getContext().GetOrCreateSymbol(Name.str()); - - return getSymbolForDwarfReference(Sym, MMI, Encoding); +getExprForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, + MachineModuleInfo *MMI, unsigned Encoding, + MCStreamer &Streamer) const { + const MCSymbol *Sym = Mang->getSymbol(GV); + return getExprForDwarfReference(Sym, Mang, MMI, Encoding, Streamer); } const MCExpr *TargetLoweringObjectFile:: -getSymbolForDwarfReference(const MCSymbol *Sym, MachineModuleInfo *MMI, - unsigned Encoding) 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; + report_fatal_error("We do not support this DWARF encoding yet!"); 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. + MCSymbol *PCSym = getContext().CreateTempSymbol(); + Streamer.EmitLabel(PCSym); + const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, getContext()); + return MCBinaryExpr::CreateSub(Res, PC, getContext()); + } } - - return Res; } unsigned TargetLoweringObjectFile::getPersonalityEncoding() const {