Index: llvm/lib/CodeGen/AsmPrinter/WinException.h =================================================================== --- llvm/lib/CodeGen/AsmPrinter/WinException.h +++ llvm/lib/CodeGen/AsmPrinter/WinException.h @@ -77,6 +77,7 @@ const MCExpr *create32bitRef(const MCSymbol *Value); const MCExpr *create32bitRef(const GlobalValue *GV); const MCExpr *getLabel(const MCSymbol *Label); + const MCExpr *getLabelPlusOne(const MCSymbol *Label); const MCExpr *getOffset(const MCSymbol *OffsetOf, const MCSymbol *OffsetFrom); const MCExpr *getOffsetPlusOne(const MCSymbol *OffsetOf, const MCSymbol *OffsetFrom); Index: llvm/lib/CodeGen/AsmPrinter/WinException.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/WinException.cpp +++ llvm/lib/CodeGen/AsmPrinter/WinException.cpp @@ -330,10 +330,12 @@ } const MCExpr *WinException::getLabel(const MCSymbol *Label) { - if (isAArch64) - return MCSymbolRefExpr::create(Label, MCSymbolRefExpr::VK_COFF_IMGREL32, - Asm->OutContext); - return MCBinaryExpr::createAdd(create32bitRef(Label), + return MCSymbolRefExpr::create(Label, MCSymbolRefExpr::VK_COFF_IMGREL32, + Asm->OutContext); +} + +const MCExpr *WinException::getLabelPlusOne(const MCSymbol *Label) { + return MCBinaryExpr::createAdd(getLabel(Label), MCConstantExpr::create(1, Asm->OutContext), Asm->OutContext); } @@ -561,8 +563,8 @@ /// struct Table { /// int NumEntries; /// struct Entry { -/// imagerel32 LabelStart; -/// imagerel32 LabelEnd; +/// imagerel32 LabelStart; // Inclusive +/// imagerel32 LabelEnd; // Exclusive /// imagerel32 FilterOrFinally; // One means catch-all. /// imagerel32 LabelLPad; // Zero means __finally. /// } Entries[NumEntries]; @@ -664,7 +666,7 @@ AddComment("LabelStart"); OS.emitValue(getLabel(BeginLabel), 4); AddComment("LabelEnd"); - OS.emitValue(getLabel(EndLabel), 4); + OS.emitValue(getLabelPlusOne(EndLabel), 4); AddComment(UME.IsFinally ? "FinallyFunclet" : UME.Filter ? "FilterFunction" : "CatchAll"); OS.emitValue(FilterOrFinally, 4); @@ -950,7 +952,7 @@ ChangeLabel = StateChange.PreviousEndLabel; // Emit an entry indicating that PCs after 'Label' have this EH state. IPToStateTable.push_back( - std::make_pair(getLabel(ChangeLabel), StateChange.NewState)); + std::make_pair(getLabelPlusOne(ChangeLabel), StateChange.NewState)); // FIXME: assert that NewState is between CatchLow and CatchHigh. } } Index: llvm/test/CodeGen/WinEH/wineh-noret-cleanup.ll =================================================================== --- llvm/test/CodeGen/WinEH/wineh-noret-cleanup.ll +++ llvm/test/CodeGen/WinEH/wineh-noret-cleanup.ll @@ -61,19 +61,19 @@ ; SEH-LABEL: test: ; SEH-LABEL: .Llsda_begin0: -; SEH-NEXT: .long .Ltmp0@IMGREL+1 +; SEH-NEXT: .long .Ltmp0@IMGREL ; SEH-NEXT: .long .Ltmp1@IMGREL+1 ; SEH-NEXT: .long dummy_filter@IMGREL ; SEH-NEXT: .long .LBB0_3@IMGREL -; SEH-NEXT: .long .Ltmp0@IMGREL+1 +; SEH-NEXT: .long .Ltmp0@IMGREL ; SEH-NEXT: .long .Ltmp1@IMGREL+1 ; SEH-NEXT: .long dummy_filter@IMGREL ; SEH-NEXT: .long .LBB0_5@IMGREL -; SEH-NEXT: .long .Ltmp2@IMGREL+1 +; SEH-NEXT: .long .Ltmp2@IMGREL ; SEH-NEXT: .long .Ltmp3@IMGREL+1 ; SEH-NEXT: .long "?dtor$2@?0?test@4HA"@IMGREL ; SEH-NEXT: .long 0 -; SEH-NEXT: .long .Ltmp2@IMGREL+1 +; SEH-NEXT: .long .Ltmp2@IMGREL ; SEH-NEXT: .long .Ltmp3@IMGREL+1 ; SEH-NEXT: .long dummy_filter@IMGREL ; SEH-NEXT: .long .LBB0_5@IMGREL Index: llvm/test/CodeGen/X86/catchret-empty-fallthrough.ll =================================================================== --- llvm/test/CodeGen/X86/catchret-empty-fallthrough.ll +++ llvm/test/CodeGen/X86/catchret-empty-fallthrough.ll @@ -47,7 +47,7 @@ ; CHECK-NEXT: .set .Lfoo$parent_frame_offset, 32 ; CHECK-NEXT: .long (.Llsda_end0-.Llsda_begin0)/16 ; CHECK-NEXT: .Llsda_begin0: -; CHECK-NEXT: .long .Ltmp0@IMGREL+1 +; CHECK-NEXT: .long .Ltmp0@IMGREL ; CHECK-NEXT: .long .Ltmp1@IMGREL+1 ; CHECK-NEXT: .long 1 ; CHECK-NEXT: .long .LBB0_[[catch]]@IMGREL Index: llvm/test/CodeGen/X86/seh-catchpad.ll =================================================================== --- llvm/test/CodeGen/X86/seh-catchpad.ll +++ llvm/test/CodeGen/X86/seh-catchpad.ll @@ -120,23 +120,23 @@ ; CHECK-NEXT: .set .Lmain$parent_frame_offset, 32 ; CHECK-NEXT: .long (.Llsda_end0-.Llsda_begin0)/16 ; CHECK-NEXT: .Llsda_begin0: -; CHECK-NEXT: .long .Ltmp0@IMGREL+1 +; CHECK-NEXT: .long .Ltmp0@IMGREL ; CHECK-NEXT: .long .Ltmp1@IMGREL+1 ; CHECK-NEXT: .long 1 ; CHECK-NEXT: .long .LBB1_[[except1bb]]@IMGREL -; CHECK-NEXT: .long .Ltmp0@IMGREL+1 +; CHECK-NEXT: .long .Ltmp0@IMGREL ; CHECK-NEXT: .long .Ltmp1@IMGREL+1 ; CHECK-NEXT: .long "?filt$0@0@main@@"@IMGREL ; CHECK-NEXT: .long .LBB1_[[except2bb]]@IMGREL -; CHECK-NEXT: .long .Ltmp2@IMGREL+1 +; CHECK-NEXT: .long .Ltmp2@IMGREL ; CHECK-NEXT: .long .Ltmp3@IMGREL+1 ; CHECK-NEXT: .long "?dtor$[[finbb:[0-9]+]]@?0?main@4HA"@IMGREL ; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long .Ltmp2@IMGREL+1 +; CHECK-NEXT: .long .Ltmp2@IMGREL ; CHECK-NEXT: .long .Ltmp3@IMGREL+1 ; CHECK-NEXT: .long "?filt$0@0@main@@"@IMGREL ; CHECK-NEXT: .long .LBB1_3@IMGREL -; CHECK-NEXT: .long .Ltmp6@IMGREL+1 +; CHECK-NEXT: .long .Ltmp6@IMGREL ; CHECK-NEXT: .long .Ltmp7@IMGREL+1 ; CHECK-NEXT: .long "?filt$0@0@main@@"@IMGREL ; CHECK-NEXT: .long .LBB1_3@IMGREL Index: llvm/test/CodeGen/X86/seh-except-finally.ll =================================================================== --- llvm/test/CodeGen/X86/seh-except-finally.ll +++ llvm/test/CodeGen/X86/seh-except-finally.ll @@ -82,15 +82,15 @@ ; CHECK-NEXT: .Luse_both$parent_frame_offset ; CHECK-NEXT: .long (.Llsda_end0-.Llsda_begin0)/16 ; CHECK-NEXT: .Llsda_begin0: -; CHECK-NEXT: .long .Ltmp0@IMGREL+1 +; CHECK-NEXT: .long .Ltmp0@IMGREL ; CHECK-NEXT: .long .Ltmp1@IMGREL+1 ; CHECK-NEXT: .long "?dtor$2@?0?use_both@4HA"@IMGREL ; CHECK-NEXT: .long 0 -; CHECK-NEXT: .long .Ltmp0@IMGREL+1 +; CHECK-NEXT: .long .Ltmp0@IMGREL ; CHECK-NEXT: .long .Ltmp1@IMGREL+1 ; CHECK-NEXT: .long "?filt$0@0@use_both@@"@IMGREL ; CHECK-NEXT: .long .LBB0_{{[0-9]+}}@IMGREL -; CHECK-NEXT: .long .Ltmp4@IMGREL+1 +; CHECK-NEXT: .long .Ltmp4@IMGREL ; CHECK-NEXT: .long .Ltmp5@IMGREL+1 ; CHECK-NEXT: .long "?filt$0@0@use_both@@"@IMGREL ; CHECK-NEXT: .long .LBB0_{{[0-9]+}}@IMGREL Index: llvm/test/CodeGen/X86/seh-finally.ll =================================================================== --- llvm/test/CodeGen/X86/seh-finally.ll +++ llvm/test/CodeGen/X86/seh-finally.ll @@ -29,7 +29,7 @@ ; X64-NEXT: .set .Lmain$parent_frame_offset, 32 ; X64-NEXT: .long (.Llsda_end0-.Llsda_begin0)/16 # Number of call sites ; X64-NEXT: .Llsda_begin0: -; X64-NEXT: .long .Ltmp0@IMGREL+1 # LabelStart +; X64-NEXT: .long .Ltmp0@IMGREL # LabelStart ; X64-NEXT: .long .Ltmp1@IMGREL+1 # LabelEnd ; X64-NEXT: .long "?dtor$2@?0?main@4HA"@IMGREL # FinallyFunclet ; X64-NEXT: .long 0 # Null Index: llvm/test/CodeGen/X86/seh-safe-div.ll =================================================================== --- llvm/test/CodeGen/X86/seh-safe-div.ll +++ llvm/test/CodeGen/X86/seh-safe-div.ll @@ -81,11 +81,11 @@ ; CHECK-NEXT: .Lsafe_div$parent_frame_offset ; CHECK-NEXT: .long (.Llsda_end0-.Llsda_begin0)/16 ; CHECK-NEXT: .Llsda_begin0: -; CHECK-NEXT: .long .Ltmp0@IMGREL+1 +; CHECK-NEXT: .long .Ltmp0@IMGREL ; CHECK-NEXT: .long .Ltmp1@IMGREL+1 ; CHECK-NEXT: .long safe_div_filt0@IMGREL ; CHECK-NEXT: .long [[handler0]]@IMGREL -; CHECK-NEXT: .long .Ltmp0@IMGREL+1 +; CHECK-NEXT: .long .Ltmp0@IMGREL ; CHECK-NEXT: .long .Ltmp1@IMGREL+1 ; CHECK-NEXT: .long safe_div_filt1@IMGREL ; CHECK-NEXT: .long [[handler1]]@IMGREL