[WinEH] _except_handlerN uses 0 instead of 1 to indicate catch-all
authorReid Kleckner <reid@kleckner.net>
Wed, 10 Jun 2015 18:14:07 +0000 (18:14 +0000)
committerReid Kleckner <reid@kleckner.net>
Wed, 10 Jun 2015 18:14:07 +0000 (18:14 +0000)
Our usage of 1 was a holdover from __C_specific_handler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239482 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/AsmPrinter/WinException.cpp
test/CodeGen/X86/seh-catch-all.ll
test/CodeGen/X86/win32-eh.ll

index 2bd9af55c30f50b2ee9c2a96f588f51672709f1b..40d6bab8b6d3806493110bfafd839666bbbe4962 100644 (file)
@@ -612,12 +612,10 @@ void WinException::emitExceptHandlerTable(const MachineFunction *MF) {
            "gaps in the SEH scope table");
     for (const SEHHandler &Handler : LPInfo->SEHHandlers) {
       // Emit the filter or finally function pointer, if present. Otherwise,
-      // emit '1' to indicate a catch-all.
-      const MCExpr *FilterOrFinally;
-      if (const Function *F = Handler.FilterOrFinally)
-        FilterOrFinally = create32bitRef(Asm->getSymbol(F));
-      else
-        FilterOrFinally = MCConstantExpr::create(1, Asm->OutContext);
+      // emit '0' to indicate a catch-all.
+      const Function *F = Handler.FilterOrFinally;
+      const MCExpr *FilterOrFinally =
+          create32bitRef(F ? Asm->getSymbol(F) : nullptr);
 
       // Compute the recovery address, which is a block address or null.
       const BlockAddress *BA = Handler.RecoverBA;
index d02584a26d4deba00650194cd394956be8d0dbb9..5586f95dba02dc23c76c63e2365d606d4546c7c8 100644 (file)
@@ -67,5 +67,5 @@ eh.resume:
 ; X86: .section .xdata,"dr"
 ; X86-NEXT: L__ehtable$main
 ; X86-NEXT: .long -1
-; X86-NEXT: .long 1
+; X86-NEXT: .long 0
 ; X86-NEXT: .long Ltmp{{[0-9]+}}
index 3abaa49653bd5b6c7b264f5735d11a0e5d4e63d3..6d816d7770c2539b1b96bb65701a784934fb5740 100644 (file)
@@ -37,7 +37,7 @@ catchall:
 ; CHECK: .section .xdata,"dr"
 ; CHECK-LABEL: L__ehtable$use_except_handler3:
 ; CHECK-NEXT:  .long   -1
-; CHECK-NEXT:  .long   1
+; CHECK-NEXT:  .long   0
 ; CHECK-NEXT:  .long   Ltmp{{[0-9]+}}
 
 define void @use_except_handler4() {
@@ -77,7 +77,7 @@ catchall:
 ; CHECK-NEXT:  .long   9999
 ; CHECK-NEXT:  .long   0
 ; CHECK-NEXT:  .long   -2
-; CHECK-NEXT:  .long   1
+; CHECK-NEXT:  .long   0
 ; CHECK-NEXT:  .long   Ltmp{{[0-9]+}}
 
 define void @use_CxxFrameHandler3() {