TaoPan updated this revision to Diff 356864.
TaoPan added a comment.

Update dependent D99487 <https://reviews.llvm.org/D99487>


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99487/new/

https://reviews.llvm.org/D99487

Files:
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/BasicBlockSections.cpp
  llvm/test/MC/COFF/seh-bbs.ll

Index: llvm/test/MC/COFF/seh-bbs.ll
===================================================================
--- /dev/null
+++ llvm/test/MC/COFF/seh-bbs.ll
@@ -0,0 +1,446 @@
+; RUN: llc -simplifycfg-require-and-preserve-domtree=1 < %s -mtriple=x86_64-windows-msvc -function-sections | llvm-mc -triple=x86_64-windows-msvc -filetype=obj - | llvm-readobj -S --sd --sr -u - | FileCheck --check-prefix=COMMON --check-prefix=BASELINE %s
+; RUN: llc -simplifycfg-require-and-preserve-domtree=1 < %s -mtriple=x86_64-windows-msvc -function-sections -basic-block-sections=all -unique-basic-block-section-names | llvm-mc -triple=x86_64-windows-msvc -filetype=obj - | llvm-readobj -S --sd --sr -u - | FileCheck --check-prefix=COMMON --check-prefix=BBS %s
+
+; COMMON:        Sections [
+; COMMON:          Section {
+; COMMON:            Name: .xdata
+; COMMON:            RawDataSize: 36
+; COMMON:            RelocationCount: 4
+; COMMON:            Characteristics [
+; COMMON-NEXT:         IMAGE_SCN_ALIGN_4BYTES
+; COMMON-NEXT:         IMAGE_SCN_CNT_INITIALIZED_DATA
+; COMMON-NEXT:         IMAGE_SCN_LNK_COMDAT
+; COMMON-NEXT:         IMAGE_SCN_MEM_READ
+; COMMON-NEXT:       ]
+; COMMON:            Relocations [
+; COMMON-NEXT:         0xC IMAGE_REL_AMD64_ADDR32NB __C_specific_handler
+; COMMON-NEXT:         0x14 IMAGE_REL_AMD64_ADDR32NB .text
+; COMMON-NEXT:         0x18 IMAGE_REL_AMD64_ADDR32NB .text
+; BASELINE:            0x20 IMAGE_REL_AMD64_ADDR32NB .text
+; BBS:                 0x20 IMAGE_REL_AMD64_ADDR32NB main.__part.2
+; COMMON:            ]
+; COMMON:            SectionData (
+; COMMON-NEXT:         0000: 190A0345 0A030572 01500000 00000000
+; BASELINE-NEXT:       0010: 01000000 12000000 34000000 01000000
+; BASELINE-NEXT:       0020: 35000000
+; BBS-NEXT:            0010: 01000000 12000000 11000000 01000000
+; BBS-NEXT:            0020: 00000000
+; COMMON-NEXT:       )
+; COMMON-NEXT:     }
+; COMMON:          Section {
+; COMMON:            Name: .pdata
+; COMMON:            RawDataSize: 12
+; COMMON:            RelocationCount: 3
+; COMMON:            Characteristics [
+; COMMON-NEXT:         IMAGE_SCN_ALIGN_4BYTES
+; COMMON-NEXT:         IMAGE_SCN_CNT_INITIALIZED_DATA
+; COMMON-NEXT:         IMAGE_SCN_LNK_COMDAT
+; COMMON-NEXT:         IMAGE_SCN_MEM_READ
+; COMMON-NEXT:       ]
+; COMMON:            Relocations [
+; COMMON-NEXT:         0x0 IMAGE_REL_AMD64_ADDR32NB main
+; COMMON-NEXT:         0x4 IMAGE_REL_AMD64_ADDR32NB main
+; COMMON-NEXT:         0x8 IMAGE_REL_AMD64_ADDR32NB .xdata
+; COMMON-NEXT:       ]
+; COMMON:            SectionData (
+; BASELINE-NEXT:       0000: 00000000 4F000000 00000000
+; BBS-NEXT:            0000: 00000000 2B000000 00000000
+; COMMON-NEXT:       )
+; COMMON-NEXT:     }
+; 15 BB Sections and 3 more .xdata and .pdata pairs for function "??0exception@std@@QEAA@QEBD@Z",
+; "??0exception@std@@QEAA@AEBV01@@Z" and "??1exception@std@@UEAA@XZ" in BBS, 21 more sections
+; in Section table of BBS
+; BASELINE:          Number: 45
+; BASELINE-NOT:      Number: 46
+; BBS:               Number: 66
+; BBS-NOT:           Number: 67
+; COMMON:        ]
+; COMMON:        UnwindInformation [
+; COMMON:          RuntimeFunction {
+; COMMON-NEXT:       StartAddress: main (0x0)
+; BASELINE-NEXT:     EndAddress: main +0x4F (0x4)
+; BBS-NEXT:          EndAddress: main +0x2B (0x4)
+; COMMON-NEXT:       UnwindInfoAddress: .xdata (0x8)
+; COMMON-NEXT:       UnwindInfo {
+; COMMON-NEXT:         Version: 1
+; COMMON-NEXT:         Flags [ (0x3)
+; COMMON-NEXT:           ExceptionHandler (0x1)
+; COMMON-NEXT:           TerminateHandler (0x2)
+; COMMON-NEXT:         ]
+; COMMON-NEXT:         PrologSize: 10
+; COMMON-NEXT:         FrameRegister: RBP (0x5)
+; COMMON-NEXT:         FrameOffset: 0x4
+; COMMON-NEXT:         UnwindCodeCount: 3
+; COMMON-NEXT:         UnwindCodes [
+; COMMON-NEXT:           0x0A: SET_FPREG reg=RBP, offset=0x40
+; COMMON-NEXT:           0x05: ALLOC_SMALL size=64
+; COMMON-NEXT:           0x01: PUSH_NONVOL reg=RBP
+; COMMON-NEXT:         ]
+; COMMON-NEXT:         Handler: __C_specific_handler (0xC)
+; COMMON-NEXT:       }
+; COMMON-NEXT:     }
+; COMMON:        ]
+
+; Generated with this C++ source:
+; #include <stdio.h>
+; #include <Windows.h>
+; #include <exception>
+;
+; int main()
+; {
+;     __try
+;     {
+;         throw std::exception("");
+;     }
+;     __except(EXCEPTION_EXECUTE_HANDLER)
+;     {
+;         printf("Executing SEH __except block\r\n");
+;     }
+;     return 0;
+; }
+
+; ModuleID = 'winseh.cpp'
+source_filename = "winseh.cpp"
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.29.30037"
+
+%rtti.TypeDescriptor19 = type { i8**, i8*, [20 x i8] }
+%eh.CatchableType = type { i32, i32, i32, i32, i32, i32, i32 }
+%eh.CatchableTypeArray.1 = type { i32, [1 x i32] }
+%eh.ThrowInfo = type { i32, i32, i32, i32 }
+%rtti.CompleteObjectLocator = type { i32, i32, i32, i32, i32, i32 }
+%rtti.ClassHierarchyDescriptor = type { i32, i32, i32, i32 }
+%rtti.BaseClassDescriptor = type { i32, i32, i32, i32, i32, i32, i32 }
+%"class.std::exception" = type { i32 (...)**, %struct.__std_exception_data }
+%struct.__std_exception_data = type { i8*, i8 }
+%struct._iobuf = type { i8* }
+%struct.__crt_locale_pointers = type { %struct.__crt_locale_data*, %struct.__crt_multibyte_data* }
+%struct.__crt_locale_data = type opaque
+%struct.__crt_multibyte_data = type opaque
+
+$"??0exception@std@@QEAA@QEBD@Z" = comdat any
+
+$"??0exception@std@@QEAA@AEBV01@@Z" = comdat any
+
+$"??1exception@std@@UEAA@XZ" = comdat any
+
+$printf = comdat any
+
+$"??_Gexception@std@@UEAAPEAXI@Z" = comdat any
+
+$"?what@exception@std@@UEBAPEBDXZ" = comdat any
+
+$_vfprintf_l = comdat any
+
+$__local_stdio_printf_options = comdat any
+
+$"??_C@_00CNPNBAHC@?$AA@" = comdat any
+
+$"??_R0?AVexception@std@@@8" = comdat any
+
+$"_CT??_R0?AVexception@std@@@8??0exception@std@@QEAA@AEBV01@@Z24" = comdat any
+
+$"_CTA1?AVexception@std@@" = comdat any
+
+$"_TI1?AVexception@std@@" = comdat any
+
+$"??_C@_0BP@FDNHNJIN@Executing?5SEH?5__except?5block?$AN?6?$AA@" = comdat any
+
+$"??_7exception@std@@6B@" = comdat largest
+
+$"??_R4exception@std@@6B@" = comdat any
+
+$"??_R3exception@std@@8" = comdat any
+
+$"??_R2exception@std@@8" = comdat any
+
+$"??_R1A@?0A@EA@exception@std@@8" = comdat any
+
+$"??_C@_0BC@EOODALEL@Unknown?5exception?$AA@" = comdat any
+
+$"?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA" = comdat any
+
+@"??_C@_00CNPNBAHC@?$AA@" = linkonce_odr dso_local unnamed_addr constant [1 x i8] zeroinitializer, comdat, align 1
+@"??_7type_info@@6B@" = external constant i8*
+@"??_R0?AVexception@std@@@8" = linkonce_odr global %rtti.TypeDescriptor19 { i8** @"??_7type_info@@6B@", i8* null, [20 x i8] c".?AVexception@std@@\00" }, comdat
+@__ImageBase = external dso_local constant i8
+@"_CT??_R0?AVexception@std@@@8??0exception@std@@QEAA@AEBV01@@Z24" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor19* @"??_R0?AVexception@std@@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 24, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%"class.std::exception"* (%"class.std::exception"*, %"class.std::exception"*)* @"??0exception@std@@QEAA@AEBV01@@Z" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, section ".xdata", comdat
+@"_CTA1?AVexception@std@@" = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%eh.CatchableType* @"_CT??_R0?AVexception@std@@@8??0exception@std@@QEAA@AEBV01@@Z24" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32)] }, section ".xdata", comdat
+@"_TI1?AVexception@std@@" = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (void (%"class.std::exception"*)* @"??1exception@std@@UEAA@XZ" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%eh.CatchableTypeArray.1* @"_CTA1?AVexception@std@@" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, section ".xdata", comdat
+@"??_C@_0BP@FDNHNJIN@Executing?5SEH?5__except?5block?$AN?6?$AA@" = linkonce_odr dso_local unnamed_addr constant [31 x i8] c"Executing SEH __except block\0D\0A\00", comdat, align 1
+@0 = private unnamed_addr constant { [3 x i8*] } { [3 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator* @"??_R4exception@std@@6B@" to i8*), i8* bitcast (i8* (%"class.std::exception"*, i32)* @"??_Gexception@std@@UEAAPEAXI@Z" to i8*), i8* bitcast (i8* (%"class.std::exception"*)* @"?what@exception@std@@UEBAPEBDXZ" to i8*)] }, comdat($"??_7exception@std@@6B@")
+@"??_R4exception@std@@6B@" = linkonce_odr constant %rtti.CompleteObjectLocator { i32 1, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor19* @"??_R0?AVexception@std@@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.ClassHierarchyDescriptor* @"??_R3exception@std@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.CompleteObjectLocator* @"??_R4exception@std@@6B@" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, comdat
+@"??_R3exception@std@@8" = linkonce_odr constant %rtti.ClassHierarchyDescriptor { i32 0, i32 0, i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint ([2 x i32]* @"??_R2exception@std@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, comdat
+@"??_R2exception@std@@8" = linkonce_odr constant [2 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.BaseClassDescriptor* @"??_R1A@?0A@EA@exception@std@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0], comdat
+@"??_R1A@?0A@EA@exception@std@@8" = linkonce_odr constant %rtti.BaseClassDescriptor { i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.TypeDescriptor19* @"??_R0?AVexception@std@@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32), i32 0, i32 0, i32 -1, i32 0, i32 64, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (%rtti.ClassHierarchyDescriptor* @"??_R3exception@std@@8" to i64), i64 ptrtoint (i8* @__ImageBase to i64)) to i32) }, comdat
+@"??_C@_0BC@EOODALEL@Unknown?5exception?$AA@" = linkonce_odr dso_local unnamed_addr constant [18 x i8] c"Unknown exception\00", comdat, align 1
+@"?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA" = linkonce_odr dso_local global i64 0, comdat, align 8
+
+@"??_7exception@std@@6B@" = unnamed_addr alias i8*, getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @0, i32 0, i32 0, i32 1)
+
+; Function Attrs: noinline norecurse optnone uwtable mustprogress
+define dso_local i32 @main() #0 personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
+  %1 = alloca i32, align 4
+  %2 = alloca i32, align 4
+  %3 = alloca %"class.std::exception", align 8
+  store i32 0, i32* %1, align 4
+  %4 = invoke %"class.std::exception"* @"??0exception@std@@QEAA@QEBD@Z"(%"class.std::exception"* nonnull dereferenceable(24) %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @"??_C@_00CNPNBAHC@?$AA@", i64 0, i64 0)) #10
+          to label %5 unwind label %7
+
+5:                                                ; preds = %0
+  %6 = bitcast %"class.std::exception"* %3 to i8*
+  invoke void @_CxxThrowException(i8* %6, %eh.ThrowInfo* @"_TI1?AVexception@std@@") #11
+          to label %15 unwind label %7
+
+7:                                                ; preds = %5, %0
+  %8 = catchswitch within none [label %9] unwind to caller
+
+9:                                                ; preds = %7
+  %10 = catchpad within %8 [i8* null]
+  catchret from %10 to label %11
+
+11:                                               ; preds = %9
+  %12 = call i32 @llvm.eh.exceptioncode(token %10)
+  store i32 %12, i32* %2, align 4
+  %13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @"??_C@_0BP@FDNHNJIN@Executing?5SEH?5__except?5block?$AN?6?$AA@", i64 0, i64 0))
+  br label %14
+
+14:                                               ; preds = %11
+  ret i32 0
+
+15:                                               ; preds = %5
+  unreachable
+}
+
+; Function Attrs: noinline nounwind optnone uwtable
+define linkonce_odr dso_local %"class.std::exception"* @"??0exception@std@@QEAA@QEBD@Z"(%"class.std::exception"* nonnull returned dereferenceable(24) %0, i8* %1) unnamed_addr #1 comdat align 2 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
+  %3 = alloca i8*, align 8
+  %4 = alloca %"class.std::exception"*, align 8
+  %5 = alloca %struct.__std_exception_data, align 8
+  store i8* %1, i8** %3, align 8
+  store %"class.std::exception"* %0, %"class.std::exception"** %4, align 8
+  %6 = load %"class.std::exception"*, %"class.std::exception"** %4, align 8
+  %7 = bitcast %"class.std::exception"* %6 to i32 (...)***
+  store i32 (...)** bitcast (i8** @"??_7exception@std@@6B@" to i32 (...)**), i32 (...)*** %7, align 8
+  %8 = getelementptr inbounds %"class.std::exception", %"class.std::exception"* %6, i32 0, i32 1
+  %9 = bitcast %struct.__std_exception_data* %8 to i8*
+  call void @llvm.memset.p0i8.i64(i8* align 8 %9, i8 0, i64 16, i1 false)
+  %10 = getelementptr inbounds %struct.__std_exception_data, %struct.__std_exception_data* %5, i32 0, i32 0
+  %11 = load i8*, i8** %3, align 8
+  store i8* %11, i8** %10, align 8
+  %12 = getelementptr inbounds %struct.__std_exception_data, %struct.__std_exception_data* %5, i32 0, i32 1
+  store i8 1, i8* %12, align 8
+  %13 = getelementptr inbounds %"class.std::exception", %"class.std::exception"* %6, i32 0, i32 1
+  invoke void @__std_exception_copy(%struct.__std_exception_data* %5, %struct.__std_exception_data* %13)
+          to label %14 unwind label %15
+
+14:                                               ; preds = %2
+  ret %"class.std::exception"* %6
+
+15:                                               ; preds = %2
+  %16 = cleanuppad within none []
+  call void @__std_terminate() #12 [ "funclet"(token %16) ]
+  unreachable
+}
+
+declare dso_local i32 @__C_specific_handler(...)
+
+; Function Attrs: noinline nounwind optnone uwtable
+define linkonce_odr dso_local %"class.std::exception"* @"??0exception@std@@QEAA@AEBV01@@Z"(%"class.std::exception"* nonnull returned dereferenceable(24) %0, %"class.std::exception"* nonnull align 8 dereferenceable(24) %1) unnamed_addr #1 comdat align 2 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
+  %3 = alloca %"class.std::exception"*, align 8
+  %4 = alloca %"class.std::exception"*, align 8
+  store %"class.std::exception"* %1, %"class.std::exception"** %3, align 8
+  store %"class.std::exception"* %0, %"class.std::exception"** %4, align 8
+  %5 = load %"class.std::exception"*, %"class.std::exception"** %4, align 8
+  %6 = bitcast %"class.std::exception"* %5 to i32 (...)***
+  store i32 (...)** bitcast (i8** @"??_7exception@std@@6B@" to i32 (...)**), i32 (...)*** %6, align 8
+  %7 = getelementptr inbounds %"class.std::exception", %"class.std::exception"* %5, i32 0, i32 1
+  %8 = bitcast %struct.__std_exception_data* %7 to i8*
+  call void @llvm.memset.p0i8.i64(i8* align 8 %8, i8 0, i64 16, i1 false)
+  %9 = getelementptr inbounds %"class.std::exception", %"class.std::exception"* %5, i32 0, i32 1
+  %10 = load %"class.std::exception"*, %"class.std::exception"** %3, align 8
+  %11 = getelementptr inbounds %"class.std::exception", %"class.std::exception"* %10, i32 0, i32 1
+  invoke void @__std_exception_copy(%struct.__std_exception_data* %11, %struct.__std_exception_data* %9)
+          to label %12 unwind label %13
+
+12:                                               ; preds = %2
+  ret %"class.std::exception"* %5
+
+13:                                               ; preds = %2
+  %14 = cleanuppad within none []
+  call void @__std_terminate() #12 [ "funclet"(token %14) ]
+  unreachable
+}
+
+; Function Attrs: noinline nounwind optnone uwtable
+define linkonce_odr dso_local void @"??1exception@std@@UEAA@XZ"(%"class.std::exception"* nonnull dereferenceable(24) %0) unnamed_addr #1 comdat align 2 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) {
+  %2 = alloca %"class.std::exception"*, align 8
+  store %"class.std::exception"* %0, %"class.std::exception"** %2, align 8
+  %3 = load %"class.std::exception"*, %"class.std::exception"** %2, align 8
+  %4 = bitcast %"class.std::exception"* %3 to i32 (...)***
+  store i32 (...)** bitcast (i8** @"??_7exception@std@@6B@" to i32 (...)**), i32 (...)*** %4, align 8
+  %5 = getelementptr inbounds %"class.std::exception", %"class.std::exception"* %3, i32 0, i32 1
+  invoke void @__std_exception_destroy(%struct.__std_exception_data* %5)
+          to label %6 unwind label %7
+
+6:                                                ; preds = %1
+  ret void
+
+7:                                                ; preds = %1
+  %8 = cleanuppad within none []
+  call void @__std_terminate() #12 [ "funclet"(token %8) ]
+  unreachable
+}
+
+declare dso_local void @_CxxThrowException(i8*, %eh.ThrowInfo*)
+
+; Function Attrs: nounwind readnone
+declare i32 @llvm.eh.exceptioncode(token) #2
+
+; Function Attrs: nobuiltin noinline optnone uwtable mustprogress
+define linkonce_odr dso_local i32 @printf(i8* %0, ...) #3 comdat {
+  %2 = alloca i8*, align 8
+  %3 = alloca i32, align 4
+  %4 = alloca i8*, align 8
+  store i8* %0, i8** %2, align 8
+  %5 = bitcast i8** %4 to i8*
+  call void @llvm.va_start(i8* %5)
+  %6 = load i8*, i8** %4, align 8
+  %7 = load i8*, i8** %2, align 8
+  %8 = call %struct._iobuf* @__acrt_iob_func(i32 1)
+  %9 = call i32 @_vfprintf_l(%struct._iobuf* %8, i8* %7, %struct.__crt_locale_pointers* null, i8* %6)
+  store i32 %9, i32* %3, align 4
+  %10 = bitcast i8** %4 to i8*
+  call void @llvm.va_end(i8* %10)
+  %11 = load i32, i32* %3, align 4
+  ret i32 %11
+}
+
+; Function Attrs: argmemonly nofree nosync nounwind willreturn writeonly
+declare void @llvm.memset.p0i8.i64(i8* nocapture writeonly, i8, i64, i1 immarg) #4
+
+declare dso_local void @__std_exception_copy(%struct.__std_exception_data*, %struct.__std_exception_data*) #5
+
+declare dso_local i32 @__CxxFrameHandler3(...)
+
+declare dso_local void @__std_terminate()
+
+; Function Attrs: noinline nounwind optnone uwtable
+define linkonce_odr dso_local i8* @"??_Gexception@std@@UEAAPEAXI@Z"(%"class.std::exception"* nonnull dereferenceable(24) %0, i32 %1) unnamed_addr #1 comdat align 2 {
+  %3 = alloca i8*, align 8
+  %4 = alloca i32, align 4
+  %5 = alloca %"class.std::exception"*, align 8
+  store i32 %1, i32* %4, align 4
+  store %"class.std::exception"* %0, %"class.std::exception"** %5, align 8
+  %6 = load %"class.std::exception"*, %"class.std::exception"** %5, align 8
+  %7 = bitcast %"class.std::exception"* %6 to i8*
+  store i8* %7, i8** %3, align 8
+  %8 = load i32, i32* %4, align 4
+  call void @"??1exception@std@@UEAA@XZ"(%"class.std::exception"* nonnull dereferenceable(24) %6) #13
+  %9 = icmp eq i32 %8, 0
+  br i1 %9, label %12, label %10
+
+10:                                               ; preds = %2
+  %11 = bitcast %"class.std::exception"* %6 to i8*
+  call void @"??3@YAXPEAX@Z"(i8* %11) #14
+  br label %12
+
+12:                                               ; preds = %10, %2
+  %13 = load i8*, i8** %3, align 8
+  ret i8* %13
+}
+
+; Function Attrs: noinline nounwind optnone uwtable mustprogress
+define linkonce_odr dso_local i8* @"?what@exception@std@@UEBAPEBDXZ"(%"class.std::exception"* nonnull dereferenceable(24) %0) unnamed_addr #6 comdat align 2 {
+  %2 = alloca %"class.std::exception"*, align 8
+  store %"class.std::exception"* %0, %"class.std::exception"** %2, align 8
+  %3 = load %"class.std::exception"*, %"class.std::exception"** %2, align 8
+  %4 = getelementptr inbounds %"class.std::exception", %"class.std::exception"* %3, i32 0, i32 1
+  %5 = getelementptr inbounds %struct.__std_exception_data, %struct.__std_exception_data* %4, i32 0, i32 0
+  %6 = load i8*, i8** %5, align 8
+  %7 = icmp ne i8* %6, null
+  br i1 %7, label %8, label %12
+
+8:                                                ; preds = %1
+  %9 = getelementptr inbounds %"class.std::exception", %"class.std::exception"* %3, i32 0, i32 1
+  %10 = getelementptr inbounds %struct.__std_exception_data, %struct.__std_exception_data* %9, i32 0, i32 0
+  %11 = load i8*, i8** %10, align 8
+  br label %13
+
+12:                                               ; preds = %1
+  br label %13
+
+13:                                               ; preds = %12, %8
+  %14 = phi i8* [ %11, %8 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @"??_C@_0BC@EOODALEL@Unknown?5exception?$AA@", i64 0, i64 0), %12 ]
+  ret i8* %14
+}
+
+; Function Attrs: nobuiltin nounwind
+declare dso_local void @"??3@YAXPEAX@Z"(i8*) #7
+
+declare dso_local void @__std_exception_destroy(%struct.__std_exception_data*) #5
+
+; Function Attrs: nofree nosync nounwind willreturn
+declare void @llvm.va_start(i8*) #8
+
+; Function Attrs: noinline optnone uwtable mustprogress
+define linkonce_odr dso_local i32 @_vfprintf_l(%struct._iobuf* %0, i8* %1, %struct.__crt_locale_pointers* %2, i8* %3) #9 comdat {
+  %5 = alloca i8*, align 8
+  %6 = alloca %struct.__crt_locale_pointers*, align 8
+  %7 = alloca i8*, align 8
+  %8 = alloca %struct._iobuf*, align 8
+  store i8* %3, i8** %5, align 8
+  store %struct.__crt_locale_pointers* %2, %struct.__crt_locale_pointers** %6, align 8
+  store i8* %1, i8** %7, align 8
+  store %struct._iobuf* %0, %struct._iobuf** %8, align 8
+  %9 = load i8*, i8** %5, align 8
+  %10 = load %struct.__crt_locale_pointers*, %struct.__crt_locale_pointers** %6, align 8
+  %11 = load i8*, i8** %7, align 8
+  %12 = load %struct._iobuf*, %struct._iobuf** %8, align 8
+  %13 = call i64* @__local_stdio_printf_options()
+  %14 = load i64, i64* %13, align 8
+  %15 = call i32 @__stdio_common_vfprintf(i64 %14, %struct._iobuf* %12, i8* %11, %struct.__crt_locale_pointers* %10, i8* %9)
+  ret i32 %15
+}
+
+declare dso_local %struct._iobuf* @__acrt_iob_func(i32) #5
+
+; Function Attrs: nofree nosync nounwind willreturn
+declare void @llvm.va_end(i8*) #8
+
+declare dso_local i32 @__stdio_common_vfprintf(i64, %struct._iobuf*, i8*, %struct.__crt_locale_pointers*, i8*) #5
+
+; Function Attrs: noinline nounwind optnone uwtable mustprogress
+define linkonce_odr dso_local i64* @__local_stdio_printf_options() #6 comdat {
+  ret i64* @"?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA"
+}
+
+attributes #0 = { noinline norecurse optnone uwtable mustprogress "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #1 = { noinline nounwind optnone uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #2 = { nounwind readnone }
+attributes #3 = { nobuiltin noinline optnone uwtable mustprogress "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #4 = { argmemonly nofree nosync nounwind willreturn writeonly }
+attributes #5 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #6 = { noinline nounwind optnone uwtable mustprogress "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #7 = { nobuiltin nounwind "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #8 = { nofree nosync nounwind willreturn }
+attributes #9 = { noinline optnone uwtable mustprogress "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+attributes #10 = { noinline nounwind }
+attributes #11 = { noreturn }
+attributes #12 = { noreturn nounwind }
+attributes #13 = { nounwind }
+attributes #14 = { builtin nounwind }
+
+!llvm.linker.options = !{!0, !1, !1, !2, !3, !4, !5}
+!llvm.module.flags = !{!6, !7}
+!llvm.ident = !{!8}
+
+!0 = !{!"/FAILIFMISMATCH:\22_CRT_STDIO_ISO_WIDE_SPECIFIERS=0\22"}
+!1 = !{!"/DEFAULTLIB:uuid.lib"}
+!2 = !{!"/FAILIFMISMATCH:\22_MSC_VER=1900\22"}
+!3 = !{!"/FAILIFMISMATCH:\22_ITERATOR_DEBUG_LEVEL=0\22"}
+!4 = !{!"/FAILIFMISMATCH:\22RuntimeLibrary=MT_StaticRelease\22"}
+!5 = !{!"/DEFAULTLIB:libcpmt.lib"}
+!6 = !{i32 1, !"wchar_size", i32 2}
+!7 = !{i32 7, !"PIC Level", i32 2}
+!8 = !{!"clang version 13.0.0 (https://github.com/llvm/llvm-project.git 30f591c3869f3bbe6eca1249dcef1b8337312de6)"}
Index: llvm/lib/CodeGen/BasicBlockSections.cpp
===================================================================
--- llvm/lib/CodeGen/BasicBlockSections.cpp
+++ llvm/lib/CodeGen/BasicBlockSections.cpp
@@ -304,15 +304,19 @@
 // zero implies "no landing pad." This function inserts a NOP just before the EH
 // pad label to ensure a nonzero offset. Returns true if padding is not needed.
 static bool avoidZeroOffsetLandingPad(MachineFunction &MF) {
-  for (auto &MBB : MF) {
-    if (MBB.isBeginSection() && MBB.isEHPad()) {
-      MachineBasicBlock::iterator MI = MBB.begin();
-      while (!MI->isEHLabel())
-        ++MI;
-      MCInst Nop = MF.getSubtarget().getInstrInfo()->getNop();
-      BuildMI(MBB, MI, DebugLoc(),
-              MF.getSubtarget().getInstrInfo()->get(Nop.getOpcode()));
-      return false;
+  if (!MF.getTarget().getTargetTriple().isOSWindows()) {
+    for (auto &MBB : MF) {
+      if (MBB.isBeginSection() && MBB.isEHPad()) {
+        MachineBasicBlock::iterator MI = MBB.begin();
+        while (MI != MBB.end() && !MI->isEHLabel())
+          ++MI;
+        if (MI != MBB.end()) {
+          MCInst Nop = MF.getSubtarget().getInstrInfo()->getNop();
+          BuildMI(MBB, MI, DebugLoc(),
+                  MF.getSubtarget().getInstrInfo()->get(Nop.getOpcode()));
+          return false;
+        }
+      }
     }
   }
   return true;
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -3224,13 +3224,10 @@
 /// MachineBasicBlock, an alignment (if present) and a comment describing
 /// it if appropriate.
 void AsmPrinter::emitBasicBlockStart(const MachineBasicBlock &MBB) {
-  // End the previous funclet and start a new one.
-  if (MBB.isEHFuncletEntry()) {
-    for (const HandlerInfo &HI : Handlers) {
+  // End the previous funclet.
+  if (MBB.isEHFuncletEntry())
+    for (const HandlerInfo &HI : Handlers)
       HI.Handler->endFunclet();
-      HI.Handler->beginFunclet(MBB);
-    }
-  }
 
   // Emit an alignment directive for this block, if needed.
   const Align Alignment = MBB.getAlignment();
@@ -3247,6 +3244,13 @@
     CurrentSectionBeginSym = MBB.getSymbol();
   }
 
+  // WinException::beginFunclet() set CurrentFuncletTextSection as
+  // Asm->OutStreamer->getCurrentSectionOnly(), start new funclet after
+  // switching to new created BB section.
+  if (MBB.isEHFuncletEntry())
+    for (const HandlerInfo &HI : Handlers)
+      HI.Handler->beginFunclet(MBB);
+
   // If the block has its address taken, emit any labels that were used to
   // reference the block.  It is possible that there is more than one label
   // here, because multiple LLVM BB's may have been RAUW'd to this block after
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to