[llvm-commits] [llvm] r97277 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp

Bill Wendling isanbard at gmail.com
Fri Feb 26 14:17:52 PST 2010


Author: void
Date: Fri Feb 26 16:17:52 2010
New Revision: 97277

URL: http://llvm.org/viewvc/llvm-project?rev=97277&view=rev
Log:
A much cleaner (and less code!) way of inserting the correct amount of padding
for alignment into the LSDA. If the TType base offset is emitted, then put the
padding there. Otherwise, put it in the call site table length. There will be no
conflict between the two sites when placing the padding in one place.

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=97277&r1=97276&r2=97277&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfException.cpp Fri Feb 26 16:17:52 2010
@@ -748,61 +748,15 @@
   if (HaveTTData) {
     // Account for any extra padding that will be added to the call site table
     // length.
-    unsigned Offset = TTypeBaseOffset + SizeAlign;
-    unsigned OffsetSize = MCAsmInfo::getULEB128Size(Offset);
-    unsigned TTypeBaseOverflow = 0;
-
-    // If adding the extra alignment to the TType base offset makes the new
-    // value of TTypeBaseOffset overflow (i.e., go from encoded as 1 byte to 2
-    // bytes), then the padding needs to be smaller by that amount.
-    if (OffsetSize != TTypeBaseOffsetSize) {
-      assert((int)OffsetSize - (int)TTypeBaseOffsetSize);
-      TTypeBaseOverflow = OffsetSize - TTypeBaseOffsetSize;
-      assert(SizeAlign >= TTypeBaseOverflow);
-      SizeAlign -= TTypeBaseOverflow;
-    }
-
-    if (!TTypeBaseOverflow) {
-      EmitULEB128(TTypeBaseOffset + SizeAlign, "@TType base offset");
-    } else if (SizeAlign != 0) {
-      // If the new "offset + alignment" size doesn't require the same extra
-      // padding that the original one did, then we need to insert that padding
-      // ourselves.
-      EmitULEB128(TTypeBaseOffset + SizeAlign, "@TType base offset",
-                  MCAsmInfo::getULEB128Size(TTypeBaseOffset + SizeAlign) !=
-                  OffsetSize ? TTypeBaseOverflow : 0);
-    } else {
-      // If adding the extra padding to this offset causes it to buffer to the
-      // size of the padding needed, then we should perform the padding here and
-      // not at the call site table below. E.g. if we have this:
-      //
-      //    GCC_except_table1:
-      //    Lexception1:
-      //        .byte   0xff  ## @LPStart Encoding = omit
-      //        .byte   0x9b  ## @TType Encoding = indirect pcrel sdata4
-      //        .byte   0x7f  ## @TType base offset
-      //        .byte   0x03  ## Call site Encoding = udata4
-      //        .byte   0x89  ## Call site table length
-      //
-      // with padding of 1. We want to emit the padding like this:
-      // 
-      //    GCC_except_table1:
-      //    Lexception1:
-      //        .byte   0xff  ## @LPStart Encoding = omit
-      //        .byte   0x9b  ## @TType Encoding = indirect pcrel sdata4
-      //        .byte   0xff  ## @TType base offset
-      //        .space  1,0   ## Padding
-      //        .byte   0x03  ## Call site Encoding = udata4
-      //        .byte   0x89  ## Call site table length
-      //
-      // and not with padding on the "Call site table length" entry.
-      EmitULEB128(TTypeBaseOffset, "@TType base offset", TTypeBaseOverflow);
-    }
+    EmitULEB128(TTypeBaseOffset, "@TType base offset", SizeAlign);
+    SizeAlign = 0;
   }
 
   // SjLj Exception handling
   if (IsSJLJ) {
     EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
+
+    // Add extra padding if it wasn't added to the TType base offset.
     EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign);
 
     // Emit the landing pad site information.
@@ -844,6 +798,8 @@
 
     // Emit the landing pad call site table.
     EmitEncodingByte(dwarf::DW_EH_PE_udata4, "Call site");
+
+    // Add extra padding if it wasn't added to the TType base offset.
     EmitULEB128(CallSiteTableLength, "Call site table length", SizeAlign);
 
     for (SmallVectorImpl<CallSiteEntry>::const_iterator





More information about the llvm-commits mailing list