Index: llvm/lib/CodeGen/AsmPrinter/WinException.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/WinException.cpp +++ llvm/lib/CodeGen/AsmPrinter/WinException.cpp @@ -330,11 +330,7 @@ } const MCExpr *WinException::getLabel(const MCSymbol *Label) { - if (isAArch64) - return MCSymbolRefExpr::create(Label, MCSymbolRefExpr::VK_COFF_IMGREL32, - Asm->OutContext); - return MCBinaryExpr::createAdd(create32bitRef(Label), - MCConstantExpr::create(1, Asm->OutContext), + return MCSymbolRefExpr::create(Label, MCSymbolRefExpr::VK_COFF_IMGREL32, Asm->OutContext); } @@ -561,8 +557,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 +660,13 @@ AddComment("LabelStart"); OS.emitValue(getLabel(BeginLabel), 4); AddComment("LabelEnd"); - OS.emitValue(getLabel(EndLabel), 4); + // LabelEnd is exlusive, so add 1 to the address to include the final + // instruction. + OS.emitValue( + MCBinaryExpr::createAdd(getLabel(EndLabel), + MCConstantExpr::create(1, Asm->OutContext), + Asm->OutContext), + 4); AddComment(UME.IsFinally ? "FinallyFunclet" : UME.Filter ? "FilterFunction" : "CatchAll"); OS.emitValue(FilterOrFinally, 4); 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 @@ -46,34 +46,34 @@ ; CXX-LABEL: $ip2state$test: ; CXX-NEXT: .long .Lfunc_begin0@IMGREL ; CXX-NEXT: .long -1 -; CXX-NEXT: .long .Ltmp0@IMGREL+1 +; CXX-NEXT: .long .Ltmp0@IMGREL ; CXX-NEXT: .long 1 -; CXX-NEXT: .long .Ltmp1@IMGREL+1 +; CXX-NEXT: .long .Ltmp1@IMGREL ; CXX-NEXT: .long -1 ; CXX-NEXT: .long "?catch$3@?0?test@4HA"@IMGREL ; CXX-NEXT: .long 2 -; CXX-NEXT: .long .Ltmp2@IMGREL+1 +; CXX-NEXT: .long .Ltmp2@IMGREL ; CXX-NEXT: .long 3 -; CXX-NEXT: .long .Ltmp3@IMGREL+1 +; CXX-NEXT: .long .Ltmp3@IMGREL ; CXX-NEXT: .long 2 ; CXX-NEXT: .long "?catch$5@?0?test@4HA"@IMGREL ; CXX-NEXT: .long 4 ; 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 Index: llvm/test/CodeGen/X86/seh-unwind-inline-asm-codegen.ll =================================================================== --- llvm/test/CodeGen/X86/seh-unwind-inline-asm-codegen.ll +++ llvm/test/CodeGen/X86/seh-unwind-inline-asm-codegen.ll @@ -56,8 +56,8 @@ ; CHECK-NEXT:$ip2state$test: ; CHECK-NEXT: .long .Lfunc_begin0@IMGREL # IP ; CHECK-NEXT: .long -1 # ToState -; CHECK-NEXT: .long .Ltmp0@IMGREL+1 # IP +; CHECK-NEXT: .long .Ltmp0@IMGREL # IP ; CHECK-NEXT: .long 0 # ToState -; CHECK-NEXT: .long .Ltmp1@IMGREL+1 # IP +; CHECK-NEXT: .long .Ltmp1@IMGREL # IP ; CHECK-NEXT: .long -1 # ToState Index: llvm/test/CodeGen/X86/win-catchpad-nested-cxx.ll =================================================================== --- llvm/test/CodeGen/X86/win-catchpad-nested-cxx.ll +++ llvm/test/CodeGen/X86/win-catchpad-nested-cxx.ll @@ -103,15 +103,15 @@ ; X64: $ip2state$try_in_catch: ; X64-NEXT: .long .Lfunc_begin0@IMGREL ; X64-NEXT: .long -1 -; X64-NEXT: .long .Ltmp0@IMGREL+1 +; X64-NEXT: .long .Ltmp0@IMGREL ; X64-NEXT: .long 0 -; X64-NEXT: .long .Ltmp1@IMGREL+1 +; X64-NEXT: .long .Ltmp1@IMGREL ; X64-NEXT: .long -1 ; X64-NEXT: .long "?catch$2@?0?try_in_catch@4HA"@IMGREL ; X64-NEXT: .long 1 -; X64-NEXT: .long .Ltmp2@IMGREL+1 +; X64-NEXT: .long .Ltmp2@IMGREL ; X64-NEXT: .long 2 -; X64-NEXT: .long .Ltmp3@IMGREL+1 +; X64-NEXT: .long .Ltmp3@IMGREL ; X64-NEXT: .long 1 ; X64-NEXT: .long "?catch$4@?0?try_in_catch@4HA"@IMGREL ; X64-NEXT: .long 3 Index: llvm/test/CodeGen/X86/win-catchpad.ll =================================================================== --- llvm/test/CodeGen/X86/win-catchpad.ll +++ llvm/test/CodeGen/X86/win-catchpad.ll @@ -208,9 +208,9 @@ ; X64: $ip2state$try_catch_catch: ; X64-NEXT: .long .Lfunc_begin0@IMGREL ; X64-NEXT: .long -1 -; X64-NEXT: .long .Ltmp0@IMGREL+1 +; X64-NEXT: .long .Ltmp0@IMGREL ; X64-NEXT: .long 0 -; X64-NEXT: .long .Ltmp1@IMGREL+1 +; X64-NEXT: .long .Ltmp1@IMGREL ; X64-NEXT: .long -1 ; X64-NEXT: .long "?catch$[[catch1bb]]@?0?try_catch_catch@4HA"@IMGREL ; X64-NEXT: .long 1 @@ -347,9 +347,9 @@ ; X64-LABEL: $ip2state$branch_to_normal_dest: ; X64-NEXT: .long .Lfunc_begin1@IMGREL ; X64-NEXT: .long -1 -; X64-NEXT: .long .Ltmp[[before_call]]@IMGREL+1 +; X64-NEXT: .long .Ltmp[[before_call]]@IMGREL ; X64-NEXT: .long 0 -; X64-NEXT: .long .Ltmp[[after_call]]@IMGREL+1 +; X64-NEXT: .long .Ltmp[[after_call]]@IMGREL ; X64-NEXT: .long -1 ; X64-NEXT: .long "?catch$[[catchbb]]@?0?branch_to_normal_dest@4HA"@IMGREL ; X64-NEXT: .long 1 Index: llvm/test/CodeGen/X86/win-cleanuppad.ll =================================================================== --- llvm/test/CodeGen/X86/win-cleanuppad.ll +++ llvm/test/CodeGen/X86/win-cleanuppad.ll @@ -191,7 +191,7 @@ ; X64-NEXT: .long 1 ; X64-NEXT: .long .Ltmp6@IMGREL ; X64-NEXT: .long 0 -; X64-NEXT: .long .Ltmp7@IMGREL+1 +; X64-NEXT: .long .Ltmp7@IMGREL ; X64-NEXT: .long -1 attributes #0 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } Index: llvm/test/CodeGen/X86/win32-eh-states.ll =================================================================== --- llvm/test/CodeGen/X86/win32-eh-states.ll +++ llvm/test/CodeGen/X86/win32-eh-states.ll @@ -88,11 +88,11 @@ ; X64-LABEL: $ip2state$f: ; X64-NEXT: .long .Lfunc_begin0@IMGREL ; X64-NEXT: .long -1 -; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1 +; X64-NEXT: .long .Ltmp{{.*}}@IMGREL ; X64-NEXT: .long 0 -; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1 +; X64-NEXT: .long .Ltmp{{.*}}@IMGREL ; X64-NEXT: .long 1 -; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1 +; X64-NEXT: .long .Ltmp{{.*}}@IMGREL ; X64-NEXT: .long -1 ; X64-NEXT: .long "?catch${{.*}}@?0?f@4HA"@IMGREL ; X64-NEXT: .long 2 @@ -191,15 +191,15 @@ ; X64-LABEL: $ip2state$g: ; X64-NEXT: .long .Lfunc_begin1@IMGREL ; X64-NEXT: .long -1 -; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1 +; X64-NEXT: .long .Ltmp{{.*}}@IMGREL ; X64-NEXT: .long 1 -; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1 +; X64-NEXT: .long .Ltmp{{.*}}@IMGREL ; X64-NEXT: .long -1 ; X64-NEXT: .long "?catch${{.*}}@?0?g@4HA"@IMGREL ; X64-NEXT: .long 2 -; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1 +; X64-NEXT: .long .Ltmp{{.*}}@IMGREL ; X64-NEXT: .long 3 -; X64-NEXT: .long .Ltmp{{.*}}@IMGREL+1 +; X64-NEXT: .long .Ltmp{{.*}}@IMGREL ; X64-NEXT: .long 2