111 lines · plain
1; RUN: llc %s --mtriple=x86_64-pc-windows-msvc -o - | FileCheck %s --check-prefixes=CHECK,X642; RUN: %if aarch64-registered-target %{ llc %s --mtriple=aarch64-pc-windows-msvc -o - | FileCheck %s --check-prefixes=CHECK,ARM64 %}3 4; Tests the fixed object layouts when two catchpads re-use the same stack5; allocation for this catch objects.6 7; Generated from this C++ code, with modifications to the IR (see comments in8; IR):9; https://godbolt.org/z/9qv5Yn68j10; > clang --target=x86_64-pc-windows-msvc test.cpp11; ```12; extern "C" void boom();13; extern "C" int calls_boom();14; {15; try { boom(); }16; catch (int& i) { return i; }17; catch (long& l) { return l; }18; return 0;19; }20; ```21 22; CHECK-LABEL: calls_boom:23; Minimum stack alloc is 64 bytes, so no change there.24; X64: subq $64, %rsp25; X64: .seh_stackalloc 6426; Only need 48 bytes on the stack, not 64.27; ARM64: sub sp, sp, #4828; ARM64: .seh_stackalloc 4829 30; Both the catch blocks load from the same address.31; CHECK-LABEL: "?catch$3@?0?calls_boom@4HA":32; X64: movq -8(%rbp), %rax33; ARM64: ldr x8, [x29, #24]34; CHECK-LABEL: "?catch$4@?0?calls_boom@4HA":35; X64: movq -8(%rbp), %rax36; ARM64: ldr x8, [x29, #24]37 38; CHECK-LABEL: $cppxdata$calls_boom:39; There's enough space for the UnwindHelp to be at 48 instead of 4040; X64: .long 48 # UnwindHelp41; There's enough space for the UnwindHelp to be at -16 instead of -3242; ARM64: .word -16 // UnwindHelp43 44; Both catches have the same object offset.45; CHECK-LABEL: $handlerMap$0$calls_boom:46; X64: .long 56 # CatchObjOffset47; ARM64: .word -8 // CatchObjOffset48; CHECK-NEXT: "?catch$3@?0?calls_boom@4HA"@IMGREL49; X64: .long 56 # CatchObjOffset50; ARM64: .word -8 // CatchObjOffset51; CHECK-NEXT: "?catch$4@?0?calls_boom@4HA"@IMGREL52 53%rtti.TypeDescriptor2 = type { ptr, ptr, [3 x i8] }54 55$"??_R0H@8" = comdat any56 57$"??_R0J@8" = comdat any58 59@"??_7type_info@@6B@" = external constant ptr60@"??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { ptr @"??_7type_info@@6B@", ptr null, [3 x i8] c".H\00" }, comdat61@"??_R0J@8" = linkonce_odr global %rtti.TypeDescriptor2 { ptr @"??_7type_info@@6B@", ptr null, [3 x i8] c".J\00" }, comdat62 63define dso_local i32 @calls_boom() personality ptr @__CxxFrameHandler3 {64entry:65 %retval = alloca i32, align 466; MODIFICATION: Remove unusued alloca67; %l = alloca ptr, align 868 %i = alloca ptr, align 869 invoke void @boom()70 to label %invoke.cont unwind label %catch.dispatch71 72catch.dispatch:73 %0 = catchswitch within none [label %catch1, label %catch] unwind to caller74 75catch1:76 %1 = catchpad within %0 [ptr @"??_R0H@8", i32 8, ptr %i]77 %2 = load ptr, ptr %i, align 878 %3 = load i32, ptr %2, align 479 store i32 %3, ptr %retval, align 480 catchret from %1 to label %catchret.dest281 82catch:83; MODIFICATION: Use %i instead of %l84 %4 = catchpad within %0 [ptr @"??_R0J@8", i32 8, ptr %i]85 %5 = load ptr, ptr %i, align 886 %6 = load i32, ptr %5, align 487 store i32 %6, ptr %retval, align 488 catchret from %4 to label %catchret.dest89 90invoke.cont:91 br label %try.cont92 93catchret.dest:94 br label %return95 96catchret.dest2:97 br label %return98 99try.cont:100 store i32 0, ptr %retval, align 4101 br label %return102 103return:104 %7 = load i32, ptr %retval, align 4105 ret i32 %7106}107 108declare dso_local void @boom() #1109 110declare dso_local i32 @__CxxFrameHandler3(...)111