[llvm-commits] [llvm] r129959 - in /llvm/trunk: include/llvm/Target/TargetAsmInfo.h lib/MC/MCDwarf.cpp lib/Target/X86/X86TargetObjectFile.cpp
Rafael Espindola
rafael.espindola at gmail.com
Thu Apr 21 17:08:43 PDT 2011
Author: rafael
Date: Thu Apr 21 19:08:43 2011
New Revision: 129959
URL: http://llvm.org/viewvc/llvm-project?rev=129959&view=rev
Log:
Compute the size of the FDE encoding instead of hard coding it. Update
X8664_ELFTargetObjectFile::getFDEEncoding to match reality.
Modified:
llvm/trunk/include/llvm/Target/TargetAsmInfo.h
llvm/trunk/lib/MC/MCDwarf.cpp
llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp
Modified: llvm/trunk/include/llvm/Target/TargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmInfo.h?rev=129959&r1=129958&r2=129959&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Target/TargetAsmInfo.h (original)
+++ llvm/trunk/include/llvm/Target/TargetAsmInfo.h Thu Apr 21 19:08:43 2011
@@ -58,6 +58,10 @@
return TLOF->getEHFrameSection();
}
+ const unsigned getFDEEncoding() const {
+ return TLOF->getFDEEncoding();
+ }
+
unsigned getDwarfRARegNum(bool isEH) const {
return TRI->getDwarfRegNum(TRI->getRARegister(), isEH);
}
Modified: llvm/trunk/lib/MC/MCDwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=129959&r1=129958&r2=129959&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)
+++ llvm/trunk/lib/MC/MCDwarf.cpp Thu Apr 21 19:08:43 2011
@@ -439,33 +439,35 @@
return -size;
}
-static void EmitSymbol(MCStreamer &streamer, const MCSymbol &symbol,
- unsigned symbolEncoding) {
+static unsigned getSizeForEncoding(MCStreamer &streamer,
+ unsigned symbolEncoding) {
MCContext &context = streamer.getContext();
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
unsigned format = symbolEncoding & 0x0f;
- unsigned application = symbolEncoding & 0x70;
- unsigned size;
switch (format) {
default:
assert(0 && "Unknown Encoding");
case dwarf::DW_EH_PE_absptr:
case dwarf::DW_EH_PE_signed:
- size = asmInfo.getPointerSize();
- break;
+ return asmInfo.getPointerSize();
case dwarf::DW_EH_PE_udata2:
case dwarf::DW_EH_PE_sdata2:
- size = 2;
- break;
+ return 2;
case dwarf::DW_EH_PE_udata4:
case dwarf::DW_EH_PE_sdata4:
- size = 4;
- break;
+ return 4;
case dwarf::DW_EH_PE_udata8:
case dwarf::DW_EH_PE_sdata8:
- size = 8;
- break;
+ return 8;
}
+}
+
+static void EmitSymbol(MCStreamer &streamer, const MCSymbol &symbol,
+ unsigned symbolEncoding) {
+ MCContext &context = streamer.getContext();
+ const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
+ unsigned size = getSizeForEncoding(streamer, symbolEncoding);
+ unsigned application = symbolEncoding & 0x70;
switch (application) {
default:
assert(0 && "Unknown Encoding");
@@ -678,7 +680,7 @@
streamer.EmitIntValue(lsdaEncoding, 1);
}
// Encoding of the FDE pointers
- streamer.EmitIntValue(dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4, 1);
+ streamer.EmitIntValue(asmInfo.getFDEEncoding(), 1);
streamer.EmitLabel(augmentationEnd);
// Initial Instructions
@@ -711,6 +713,7 @@
MCContext &context = streamer.getContext();
MCSymbol *fdeStart = context.CreateTempSymbol();
MCSymbol *fdeEnd = context.CreateTempSymbol();
+ const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
// Length
const MCExpr *Length = MakeStartMinusEndExpr(streamer, *fdeStart, *fdeEnd, 0);
@@ -721,14 +724,16 @@
const MCExpr *offset = MakeStartMinusEndExpr(streamer, cieStart, *fdeStart,
0);
streamer.EmitValue(offset, 4);
+ unsigned fdeEncoding = asmInfo.getFDEEncoding();
+ unsigned size = getSizeForEncoding(streamer, fdeEncoding);
// PC Begin
- streamer.EmitPCRelSymbolValue(frame.Begin, 4);
+ streamer.EmitPCRelSymbolValue(frame.Begin, size);
// PC Range
const MCExpr *Range = MakeStartMinusEndExpr(streamer, *frame.Begin,
*frame.End, 0);
- streamer.EmitValue(Range, 4);
+ streamer.EmitValue(Range, size);
// Augmentation Data Length
MCSymbol *augmentationStart = streamer.getContext().CreateTempSymbol();
Modified: llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp?rev=129959&r1=129958&r2=129959&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86TargetObjectFile.cpp Thu Apr 21 19:08:43 2011
@@ -92,16 +92,7 @@
}
unsigned X8664_ELFTargetObjectFile::getFDEEncoding() const {
- CodeModel::Model Model = TM.getCodeModel();
- if (TM.getRelocationModel() == Reloc::PIC_)
- return DW_EH_PE_pcrel | (Model == CodeModel::Small ||
- Model == CodeModel::Medium ?
- DW_EH_PE_sdata4 : DW_EH_PE_sdata8);
-
- if (Model == CodeModel::Small || Model == CodeModel::Medium)
- return DW_EH_PE_udata4;
-
- return DW_EH_PE_absptr;
+ return DW_EH_PE_pcrel | DW_EH_PE_sdata4;
}
unsigned X8664_ELFTargetObjectFile::getTTypeEncoding() const {
More information about the llvm-commits
mailing list