brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.4 KiB · ed633ce Raw
146 lines · plain
1; RUN: llc %s --mtriple=aarch64-pc-windows-msvc -o - | FileCheck %s2 3; Regression test for handling MSVC C++ exceptions when there's an aligned4; object on the stack.5 6; Generated from this C++ code:7; https://godbolt.org/z/cGzGfqq348; > clang --target=aarch64-pc-windows-msvc test.cpp9; ```10; // Large object: alignment seems to be important?11; struct alignas(128) BigObj {12;     int value;13;     // Destructor so it's kept alive.14;     ~BigObj() { }15; };16;17; // Exception type need to be large enough to not fit in a register.18; struct Error {19;     int value;20;     int padding[3];21; };22;23; int main() {24;     BigObj bo{};25;26;     try {27;         throw Error { 42, {0, 0, 0} };28;     } catch (const Error& e) {29;         return e.value;30;     }31;     return 0;32; }33; ```34 35; CHECK-LABEL:  main:36; CHECK:        sub x[[SPTMP:[0-9]+]], sp, #33637; CHECK:        and sp, x[[SPTMP]], #0xffffffffffffff8038; CHECK:        mov x[[FP:[0-9]+]], sp39; CHECK:        str wzr, [x[[FP]], #332]40 41; CHECK-LABEL:  "?catch$3@?0?main@4HA":42; CHECK:        str	w8, [x[[FP]], #332]43; CHECK-NEXT:   .seh_startepilogue44; CHECK:        ret45 46; CHECK-LABEL:  $cppxdata$main:47; CHECK:        .word   -16                             // UnwindHelp48; CHECK-LABEL:  $handlerMap$0$main:49; CHECK-NEXT:   .word   8                               // Adjectives50; CHECK-NEXT:   .word   "??_R0?AUError@@@8"@IMGREL      // Type51; CHECK-NEXT:   .word   -8                              // CatchObjOffset52; CHECK-NEXT:   .word   "?catch$3@?0?main@4HA"@IMGREL   // Handler53 54%rtti.TypeDescriptor11 = type { ptr, ptr, [12 x i8] }55%eh.CatchableType = type { i32, i32, i32, i32, i32, i32, i32 }56%eh.CatchableTypeArray.1 = type { i32, [1 x i32] }57%eh.ThrowInfo = type { i32, i32, i32, i32 }58%struct.BigObj = type { i32, [124 x i8] }59%struct.Error = type { i32, [3 x i32] }60 61$"??1BigObj@@QEAA@XZ" = comdat any62 63$"??_R0?AUError@@@8" = comdat any64 65$"_CT??_R0?AUError@@@816" = comdat any66 67$"_CTA1?AUError@@" = comdat any68 69$"_TI1?AUError@@" = comdat any70 71@"??_7type_info@@6B@" = external constant ptr72@"??_R0?AUError@@@8" = linkonce_odr global %rtti.TypeDescriptor11 { ptr @"??_7type_info@@6B@", ptr null, [12 x i8] c".?AUError@@\00" }, comdat73@__ImageBase = external dso_local constant i874@"_CT??_R0?AUError@@@816" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"??_R0?AUError@@@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 16, i32 0 }, section ".xdata", comdat75@"_CTA1?AUError@@" = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"_CT??_R0?AUError@@@816" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32)] }, section ".xdata", comdat76@"_TI1?AUError@@" = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"_CTA1?AUError@@" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32) }, section ".xdata", comdat77 78define dso_local noundef i32 @main() personality ptr @__CxxFrameHandler3 {79entry:80  %retval = alloca i32, align 481  %bo = alloca %struct.BigObj, align 12882  %tmp = alloca %struct.Error, align 483  %e = alloca ptr, align 884  %cleanup.dest.slot = alloca i32, align 485  store i32 0, ptr %retval, align 486  call void @llvm.memset.p0.i64(ptr align 128 %bo, i8 0, i64 128, i1 false)87  %value = getelementptr inbounds nuw %struct.BigObj, ptr %bo, i32 0, i32 088  %value1 = getelementptr inbounds nuw %struct.Error, ptr %tmp, i32 0, i32 089  store i32 42, ptr %value1, align 490  %padding = getelementptr inbounds nuw %struct.Error, ptr %tmp, i32 0, i32 191  store i32 0, ptr %padding, align 492  %arrayinit.element = getelementptr inbounds i32, ptr %padding, i64 193  store i32 0, ptr %arrayinit.element, align 494  %arrayinit.element2 = getelementptr inbounds i32, ptr %padding, i64 295  store i32 0, ptr %arrayinit.element2, align 496  invoke void @_CxxThrowException(ptr %tmp, ptr @"_TI1?AUError@@") #397          to label %unreachable unwind label %catch.dispatch98 99catch.dispatch:100  %0 = catchswitch within none [label %catch] unwind label %ehcleanup101 102catch:103  %1 = catchpad within %0 [ptr @"??_R0?AUError@@@8", i32 8, ptr %e]104  %2 = load ptr, ptr %e, align 8105  %value3 = getelementptr inbounds nuw %struct.Error, ptr %2, i32 0, i32 0106  %3 = load i32, ptr %value3, align 4107  store i32 %3, ptr %retval, align 4108  store i32 1, ptr %cleanup.dest.slot, align 4109  catchret from %1 to label %catchret.dest110 111catchret.dest:112  br label %cleanup113 114try.cont:115  store i32 0, ptr %retval, align 4116  store i32 1, ptr %cleanup.dest.slot, align 4117  br label %cleanup118 119cleanup:120  call void @"??1BigObj@@QEAA@XZ"(ptr noundef nonnull align 128 dereferenceable(4) %bo) #4121  %4 = load i32, ptr %retval, align 4122  ret i32 %4123 124ehcleanup:125  %5 = cleanuppad within none []126  call void @"??1BigObj@@QEAA@XZ"(ptr noundef nonnull align 128 dereferenceable(4) %bo) [ "funclet"(token %5) ]127  cleanupret from %5 unwind to caller128 129unreachable:130  unreachable131}132 133declare void @llvm.memset.p0.i64(ptr writeonly captures(none), i8, i64, i1 immarg) #1134 135declare dso_local void @_CxxThrowException(ptr, ptr)136 137declare dso_local i32 @__CxxFrameHandler3(...)138 139define linkonce_odr dso_local void @"??1BigObj@@QEAA@XZ"(ptr noundef nonnull align 128 dereferenceable(4) %this) unnamed_addr comdat {140entry:141  %this.addr = alloca ptr, align 8142  store ptr %this, ptr %this.addr, align 8143  %this1 = load ptr, ptr %this.addr, align 8144  ret void145}146