[llvm] r185790 - Revert: Fix alignment of unwind data.

Kai Nacke kai.nacke at redstar.de
Sun Jul 7 21:45:06 PDT 2013


Author: redstar
Date: Sun Jul  7 23:45:05 2013
New Revision: 185790

URL: http://llvm.org/viewvc/llvm-project?rev=185790&view=rev
Log:
Revert: Fix alignment of unwind data.

Removed:
    llvm/trunk/test/MC/COFF/seh-align1.s
    llvm/trunk/test/MC/COFF/seh-align2.s
    llvm/trunk/test/MC/COFF/seh-align3.s
Modified:
    llvm/trunk/lib/MC/MCWin64EH.cpp

Modified: llvm/trunk/lib/MC/MCWin64EH.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCWin64EH.cpp?rev=185790&r1=185789&r2=185790&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCWin64EH.cpp (original)
+++ llvm/trunk/lib/MC/MCWin64EH.cpp Sun Jul  7 23:45:05 2013
@@ -159,11 +159,11 @@ static void EmitUnwindInfo(MCStreamer &s
 
   MCContext &context = streamer.getContext();
   streamer.EmitValueToAlignment(4);
+  // Upper 3 bits are the version number (currently 1).
+  uint8_t flags = 0x01;
   info->Symbol = context.CreateTempSymbol();
   streamer.EmitLabel(info->Symbol);
 
-  // Upper 3 bits are the version number (currently 1).
-  uint8_t flags = 0x01;
   if (info->ChainedParent)
     flags |= Win64EH::UNW_ChainInfo << 3;
   else {
@@ -199,14 +199,6 @@ static void EmitUnwindInfo(MCStreamer &s
     EmitUnwindCode(streamer, info->Begin, inst);
   }
 
-  // For alignment purposes, the instruction array will always have an even
-  // number of entries, with the final entry potentially unused (in which case
-  // the array will be one longer than indicated by the count of unwind codes
-  // field).
-  if (numCodes & 1) {
-    streamer.EmitIntValue(0, 2);
-  }
-
   if (flags & (Win64EH::UNW_ChainInfo << 3))
     EmitRuntimeFunction(streamer, info->ChainedParent);
   else if (flags &
@@ -214,11 +206,14 @@ static void EmitUnwindInfo(MCStreamer &s
     streamer.EmitValue(MCSymbolRefExpr::Create(info->ExceptionHandler,
                                               MCSymbolRefExpr::VK_COFF_IMGREL32,
                                               context), 4);
-  else if (numCodes == 0) {
+  else if (numCodes < 2) {
     // The minimum size of an UNWIND_INFO struct is 8 bytes. If we're not
     // a chained unwind info, if there is no handler, and if there are fewer
     // than 2 slots used in the unwind code array, we have to pad to 8 bytes.
-    streamer.EmitIntValue(0, 4);
+    if (numCodes == 1)
+      streamer.EmitIntValue(0, 2);
+    else
+      streamer.EmitIntValue(0, 4);
   }
 }
 

Removed: llvm/trunk/test/MC/COFF/seh-align1.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/seh-align1.s?rev=185789&view=auto
==============================================================================
--- llvm/trunk/test/MC/COFF/seh-align1.s (original)
+++ llvm/trunk/test/MC/COFF/seh-align1.s (removed)
@@ -1,65 +0,0 @@
-// This test checks the alignment and padding of the unwind info.
-
-// RUN: llvm-mc -triple x86_64-pc-win32 -filetype=obj %s | llvm-readobj -s -sd -sr -u | FileCheck %s
-
-// CHECK:      Sections [
-// CHECK:        Section {
-// CHECK:          Name: .xdata
-// CHECK:          RawDataSize: 8
-// CHECK:          RelocationCount: 0
-// CHECK:          Characteristics [
-// CHECK-NEXT:       ALIGN_4BYTES
-// CHECK-NEXT:       CNT_INITIALIZED_DATA
-// CHECK-NEXT:       MEM_READ
-// CHECK-NEXT:     ]
-// CHECK:          Relocations [
-// CHECK-NEXT:     ]
-// CHECK:          SectionData (
-// CHECK-NEXT:       0000: 01000000 00000000
-// CHECK-NEXT:     )
-// CHECK-NEXT:   }
-// CHECK:        Section {
-// CHECK:          Name: .pdata
-// CHECK:          RawDataSize: 12
-// CHECK:          RelocationCount: 3
-// CHECK:          Characteristics [
-// CHECK-NEXT:       IMAGE_SCN_ALIGN_4BYTES
-// CHECK-NEXT:       IMAGE_SCN_CNT_INITIALIZED_DATA
-// CHECK-NEXT:       IMAGE_SCN_MEM_READ
-// CHECK-NEXT:     ]
-// CHECK:          Relocations [
-// CHECK-NEXT:       [[BeginDisp:0x[A-F0-9]+]] IMAGE_REL_AMD64_ADDR32NB smallFunc
-// CHECK-NEXT:       [[EndDisp:0x[A-F0-9]+]] IMAGE_REL_AMD64_ADDR32NB smallFunc
-// CHECK-NEXT:       [[UnwindDisp:0x[A-F0-9]+]] IMAGE_REL_AMD64_ADDR32NB .xdata
-// CHECK-NEXT:     ]
-// CHECK:          SectionData (
-// CHECK-NEXT:       0000: 00000000 01000000 00000000
-// CHECK-NEXT:     )
-// CHECK-NEXT:   }
-// CHECK:        UnwindInformation [
-// CHECK-NEXT:     RuntimeFunction {
-// CHECK-NEXT:     StartAddress: smallFunc {{(\+0x[A-F0-9]+ )?}}([[BeginDisp]])
-// CHECK-NEXT:     EndAddress: smallFunc {{(\+0x[A-F0-9]+ )?}}([[EndDisp]])
-// CHECK-NEXT:     UnwindInfoAddress: .xdata {{(\+0x[A-F0-9]+ )?}}([[UnwindDisp]])
-// CHECK-NEXT:     UnwindInfo {
-// CHECK-NEXT:       Version: 1
-// CHECK-NEXT:       Flags [
-// CHECK-NEXT:       ]
-// CHECK-NEXT:       PrologSize: 0
-// CHECK-NEXT:       FrameRegister: -
-// CHECK-NEXT:       FrameOffset: -
-// CHECK-NEXT:       UnwindCodeCount: 0
-// CHECK-NEXT:       UnwindCodes [
-// CHECK-NEXT:       ]
-// CHECK-NEXT:     }
-// CHECK-NEXT:   }
-// CHECK-NEXT: ]
-
-// Generate the minimal unwind info.
-// It contains only the version set to 1. All other bytes are 0.
-    .globl smallFunc
-    .def smallFunc; .scl 2; .type 32; .endef
-    .seh_proc smallFunc
-smallFunc:
-    ret
-    .seh_endproc

Removed: llvm/trunk/test/MC/COFF/seh-align2.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/seh-align2.s?rev=185789&view=auto
==============================================================================
--- llvm/trunk/test/MC/COFF/seh-align2.s (original)
+++ llvm/trunk/test/MC/COFF/seh-align2.s (removed)
@@ -1,78 +0,0 @@
-// This test checks the alignment and padding of the unwind info.
-
-// RUN: llvm-mc -triple x86_64-pc-win32 -filetype=obj %s | llvm-readobj -s -sd -sr -u | FileCheck %s
-
-// CHECK:      Sections [
-// CHECK:        Section {
-// CHECK:          Name: .xdata
-// CHECK:          RawDataSize: 16
-// CHECK:          RelocationCount: 1
-// CHECK:          Characteristics [
-// CHECK-NEXT:       ALIGN_4BYTES
-// CHECK-NEXT:       CNT_INITIALIZED_DATA
-// CHECK-NEXT:       MEM_READ
-// CHECK-NEXT:     ]
-// CHECK:          Relocations [
-// CHECK-NEXT:       [[HandlerDisp:0x[A-F0-9]+]] IMAGE_REL_AMD64_ADDR32NB __C_specific_handler
-// CHECK-NEXT:     ]
-// CHECK:          SectionData (
-// CHECK-NEXT:       0000: 09000100 04220000 00000000 BEBAFECA
-// CHECK-NEXT:     )
-// CHECK-NEXT:   }
-// CHECK-NEXT:   Section {
-// CHECK:          Name: .pdata
-// CHECK:          RawDataSize: 12
-// CHECK:          RelocationCount: 3
-// CHECK:          Characteristics [
-// CHECK-NEXT:       IMAGE_SCN_ALIGN_4BYTES
-// CHECK-NEXT:       IMAGE_SCN_CNT_INITIALIZED_DATA
-// CHECK-NEXT:       IMAGE_SCN_MEM_READ
-// CHECK-NEXT:     ]
-// CHECK:          Relocations [
-// CHECK-NEXT:       [[BeginDisp:0x[A-F0-9]+]] IMAGE_REL_AMD64_ADDR32NB func
-// CHECK-NEXT:       [[EndDisp:0x[A-F0-9]+]] IMAGE_REL_AMD64_ADDR32NB func
-// CHECK-NEXT:       [[UnwindDisp:0x[A-F0-9]+]] IMAGE_REL_AMD64_ADDR32NB .xdata
-// CHECK-NEXT:     ]
-// CHECK:          SectionData (
-// CHECK-NEXT:       0000: FCFFFFFF 05000000 00000000
-// CHECK-NEXT:     )
-// CHECK-NEXT:   }
-// CHECK-NEXT: ]
-// CHECK:      UnwindInformation [
-// CHECK-NEXT:   RuntimeFunction {
-// CHECK-NEXT:     StartAddress: func {{(\+0x[A-F0-9]+ )?}}([[BeginDisp]])
-// CHECK-NEXT:     EndAddress: func {{(\+0x[A-F0-9]+ )?}}([[EndDisp]])
-// CHECK-NEXT:     UnwindInfoAddress: .xdata {{(\+0x[A-F0-9]+ )?}}([[UnwindDisp]])
-// CHECK-NEXT:     UnwindInfo {
-// CHECK-NEXT:       Version: 1
-// CHECK-NEXT:       Flags [
-// CHECK-NEXT:         ExceptionHandler
-// CHECK-NEXT:       ]
-// CHECK-NEXT:       PrologSize: 0
-// CHECK-NEXT:       FrameRegister: -
-// CHECK-NEXT:       FrameOffset: -
-// CHECK-NEXT:       UnwindCodeCount: 1
-// CHECK-NEXT:       UnwindCodes [
-// CHECK-NEXT:         0x04: ALLOC_SMALL size=24
-// CHECK-NEXT:       ]
-// CHECK-NEXT:       Handler: __C_specific_handler ([[HandlerDisp]])
-// CHECK-NEXT:     }
-// CHECK-NEXT:   }
-// CHECK-NEXT: ]
-
-// Generates only one unwind code.
-// Requires padding of the unwind code array.
-    .globl func
-    .def func; .scl 2; .type 32; .endef
-    .seh_proc func
-    subq $24, %rsp
-    .seh_stackalloc 24
-    .seh_handler __C_specific_handler, @except
-    .seh_handlerdata
-    .long 0xcafebabe
-    .text
-    .seh_endprologue
-func:
-    addq $24, %rsp
-    ret
-    .seh_endproc

Removed: llvm/trunk/test/MC/COFF/seh-align3.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/seh-align3.s?rev=185789&view=auto
==============================================================================
--- llvm/trunk/test/MC/COFF/seh-align3.s (original)
+++ llvm/trunk/test/MC/COFF/seh-align3.s (removed)
@@ -1,83 +0,0 @@
-// This test checks the alignment and padding of the unwind info.
-
-// RUN: llvm-mc -triple x86_64-pc-win32 -filetype=obj %s | llvm-readobj -s -sd -sr -u | FileCheck %s
-
-// CHECK:      Sections [
-// CHECK:        Section {
-// CHECK:          Name: .xdata
-// CHECK:          RawDataSize: 16
-// CHECK:          RelocationCount: 1
-// CHECK:          Characteristics [
-// CHECK-NEXT:       ALIGN_4BYTES
-// CHECK-NEXT:       CNT_INITIALIZED_DATA
-// CHECK-NEXT:       MEM_READ
-// CHECK-NEXT:     ]
-// CHECK:          Relocations [
-// CHECK-NEXT:       [[HandlerDisp:0x[A-F0-9]+]] IMAGE_REL_AMD64_ADDR32NB __C_specific_handler
-// CHECK-NEXT:     ]
-// CHECK:          SectionData (
-// CHECK-NEXT:       0000: 19000200 04D002C0 00000000 BEBAFECA
-// CHECK-NEXT:     )
-// CHECK-NEXT:   }
-// CHECK-NEXT:   Section {
-// CHECK:          Name: .pdata
-// CHECK:          RawDataSize: 12
-// CHECK:          RelocationCount: 3
-// CHECK:          Characteristics [
-// CHECK-NEXT:       IMAGE_SCN_ALIGN_4BYTES
-// CHECK-NEXT:       IMAGE_SCN_CNT_INITIALIZED_DATA
-// CHECK-NEXT:       IMAGE_SCN_MEM_READ
-// CHECK-NEXT:     ]
-// CHECK:          Relocations [
-// CHECK-NEXT:       [[BeginDisp:0x[A-F0-9]+]] IMAGE_REL_AMD64_ADDR32NB func
-// CHECK-NEXT:       [[EndDisp:0x[A-F0-9]+]] IMAGE_REL_AMD64_ADDR32NB func
-// CHECK-NEXT:       [[UnwindDisp:0x[A-F0-9]+]] IMAGE_REL_AMD64_ADDR32NB .xdata
-// CHECK-NEXT:     ]
-// CHECK:          SectionData (
-// CHECK-NEXT:       0000: FCFFFFFF 05000000 00000000
-// CHECK-NEXT:     )
-// CHECK-NEXT:   }
-// CHECK-NEXT: ]
-// CHECK:      UnwindInformation [
-// CHECK-NEXT:   RuntimeFunction {
-// CHECK-NEXT:     StartAddress: func {{(\+0x[A-F0-9]+ )?}}([[BeginDisp]])
-// CHECK-NEXT:     EndAddress: func {{(\+0x[A-F0-9]+ )?}}([[EndDisp]])
-// CHECK-NEXT:     UnwindInfoAddress: .xdata {{(\+0x[A-F0-9]+ )?}}([[UnwindDisp]])
-// CHECK-NEXT:     UnwindInfo {
-// CHECK-NEXT:       Version: 1
-// CHECK-NEXT:       Flags [
-// CHECK-NEXT:         ExceptionHandler
-// CHECK-NEXT:         TerminateHandler
-// CHECK-NEXT:       ]
-// CHECK-NEXT:       PrologSize: 0
-// CHECK-NEXT:       FrameRegister: -
-// CHECK-NEXT:       FrameOffset: -
-// CHECK-NEXT:       UnwindCodeCount: 2
-// CHECK-NEXT:       UnwindCodes [
-// CHECK-NEXT:         0x04: PUSH_NONVOL reg=R13
-// CHECK-NEXT:         0x02: PUSH_NONVOL reg=R12
-// CHECK-NEXT:       ]
-// CHECK-NEXT:       Handler: __C_specific_handler ([[HandlerDisp]])
-// CHECK-NEXT:     }
-// CHECK-NEXT:   }
-// CHECK-NEXT: ]
-
-// Generates two unwind codes.
-// Requires no padding of the unwind code array.
-    .globl func
-    .def func; .scl 2; .type 32; .endef
-    .seh_proc func
-    push %r12
-    .seh_pushreg 12
-    push %r13
-    .seh_pushreg 13
-    .seh_handler __C_specific_handler, @except, @unwind
-    .seh_handlerdata
-    .long 0xcafebabe
-    .text
-    .seh_endprologue
-func:
-    pop %r13
-    pop %r12
-    ret
-    .seh_endproc





More information about the llvm-commits mailing list