[llvm-commits] [llvm] r81424 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
Bill Wendling
isanbard at gmail.com
Wed Sep 9 19:07:37 PDT 2009
Author: void
Date: Wed Sep 9 21:07:37 2009
New Revision: 81424
URL: http://llvm.org/viewvc/llvm-project?rev=81424&view=rev
Log:
Don't hardcode the TType format size. In fact, rework the code so that it's more
like what GCC outputs. The mysterious code to insert padding wasn't in GCC at
all. I modified the TType base offset code to calculate the offset like GCC
does, though.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp?rev=81424&r1=81423&r2=81424&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Wed Sep 9 21:07:37 2009
@@ -617,53 +617,11 @@
}
// Type infos.
- // FIXME: Don't hardcode. Should be TType's format encoding size.
- unsigned TypeInfoSize = SizeOfEncodedValue(dwarf::DW_EH_PE_absptr);
- unsigned SizeTypes = TypeInfos.size() * TypeInfoSize;
-
- unsigned TypeOffset = sizeof(int8_t) + // Call site format
- MCAsmInfo::getULEB128Size(SizeSites) + // Call-site table length
- SizeSites + SizeActions + SizeTypes;
-
- unsigned TotalSize = sizeof(int8_t) + // LPStart format
- sizeof(int8_t) + // TType format
- (HaveTTData ?
- MCAsmInfo::getULEB128Size(TypeOffset) : 0) + // TType base offset
- TypeOffset;
-
- unsigned SizeAlign = (4 - TotalSize) & 3;
-
- // Begin the exception table.
const MCSection *LSDASection = Asm->getObjFileLowering().getLSDASection();
- Asm->OutStreamer.SwitchSection(LSDASection);
- Asm->EmitAlignment(2, 0, 0, false);
- O << "GCC_except_table" << SubprogramCount << ":\n";
+ unsigned TTypeFormat;
- for (unsigned i = 0; i != SizeAlign; ++i) {
- Asm->EmitInt8(0);
- Asm->EOL("Padding");
- }
-
- EmitLabel("exception", SubprogramCount);
- if (IsSJLJ) {
- SmallString<16> LSDAName;
- raw_svector_ostream(LSDAName) << MAI->getPrivateGlobalPrefix() <<
- "_LSDA_" << Asm->getFunctionNumber();
- O << LSDAName.str() << ":\n";
- }
-
- // Emit the header.
- Asm->EmitInt8(dwarf::DW_EH_PE_omit);
- Asm->EOL("@LPStart format", dwarf::DW_EH_PE_omit);
-
- // For SjLj exceptions, if there is no TypeInfo, then we just explicitly
- // say that we're omitting that bit.
- // FIXME: does this apply to Dwarf also? The above #if 0 implies yes?
if (!HaveTTData) {
- // If there are no typeinfos or filters, there is nothing to emit, optimize
- // by specifying the "omit" encoding.
- Asm->EmitInt8(dwarf::DW_EH_PE_omit);
- Asm->EOL("@TType format", dwarf::DW_EH_PE_omit);
+ TTypeFormat = dwarf::DW_EH_PE_omit;
} else {
// Okay, we have actual filters or typeinfos to emit. As such, we need to
// pick a type encoding for them. We're about to emit a list of pointers to
@@ -689,19 +647,61 @@
// somewhere. This predicate should be moved to a shared location that is
// in target-independent code.
//
- unsigned TTypeFormat;
-
if (LSDASection->getKind().isWriteable() ||
Asm->TM.getRelocationModel() == Reloc::Static)
TTypeFormat = dwarf::DW_EH_PE_absptr;
else
TTypeFormat = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
dwarf::DW_EH_PE_sdata4;
+ }
- Asm->EmitInt8(TTypeFormat);
- Asm->EOL("@TType format", TTypeFormat);
+ // Begin the exception table.
+ Asm->OutStreamer.SwitchSection(LSDASection);
+ Asm->EmitAlignment(2, 0, 0, false);
+
+ O << "GCC_except_table" << SubprogramCount << ":\n";
+ EmitLabel("exception", SubprogramCount);
+
+ if (IsSJLJ) {
+ SmallString<16> LSDAName;
+ raw_svector_ostream(LSDAName) << MAI->getPrivateGlobalPrefix() <<
+ "_LSDA_" << Asm->getFunctionNumber();
+ O << LSDAName.str() << ":\n";
+ }
+
+ // Emit the header.
+ Asm->EmitInt8(dwarf::DW_EH_PE_omit);
+ Asm->EOL("@LPStart format", dwarf::DW_EH_PE_omit);
+
+ // For SjLj exceptions, if there is no TypeInfo, then we just explicitly
+ // say that we're omitting that bit.
+ Asm->EmitInt8(TTypeFormat);
+ Asm->EOL("@TType format", TTypeFormat);
+
+ if (HaveTTData) {
+ unsigned TypeFormatSize = SizeOfEncodedValue(TTypeFormat);
+ unsigned SizeTypes = TypeInfos.size() * TypeFormatSize;
+ unsigned BeforeOffset = 2;
+ unsigned TypeOffset = sizeof(int8_t) + // Call site format
+ MCAsmInfo::getULEB128Size(SizeSites) + // Call-site table length
+ SizeSites + SizeActions + SizeTypes;
+ unsigned Offset = TypeOffset;
+ unsigned LastOffset = 0;
+
+ while (Offset != LastOffset) {
+ LastOffset = Offset;
+ unsigned Size = MCAsmInfo::getULEB128Size(Offset);
+ unsigned Pad = BeforeOffset + Size + TypeOffset;
+
+ if (Pad % TypeFormatSize)
+ Pad = TypeFormatSize - (Pad % TypeFormatSize);
+ else
+ Pad = 0;
+
+ Offset = TypeOffset + Pad;
+ }
- Asm->EmitULEB128Bytes(TypeOffset);
+ Asm->EmitULEB128Bytes(Offset);
Asm->EOL("@TType base offset");
}
More information about the llvm-commits
mailing list