brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.8 KiB · 6bb22fc Raw
192 lines · plain
1; RUN: llc -o - %s -mtriple=aarch64-windows -verify-machineinstrs | FileCheck %s2; RUN: llc -o %t -filetype=obj %s -mtriple=aarch64-windows3; RUN: llvm-readobj --unwind %t | FileCheck %s -check-prefix=UNWIND4 5; We test the following6; 1) That the unwind help object is created and that its offset from the stack7;    pointer on entry is patched into the table fed to __CxxFrameHandler38; 2) That the stack update for the catch funclet only includes the callee saved9;    registers10; 3) That the locals are accessed using the frame pointer in both the funclet11;    and the parent function.12 13; The following checks that the unwind help object has -2 stored into it at14; fp + 16, which is on-entry sp - 16.15; We check this offset in the table later on.16 17; CHECK-LABEL: "?func@@YAHXZ":18; CHECK:       stp     x19, x20, [sp, #-64]!19; CHECK:       str     x21, [sp, #16]20; CHECK:       str     x28, [sp, #24]21; CHECK:       stp     x29, x30, [sp, #32]22; CHECK:       add     x29, sp, #3223; CHECK:       sub     sp, sp, #60824; CHECK:       mov     x19, sp25; CHECK:       mov     x0, #-226; CHECK:       stur    x0, [x29, #16]27 28; Now check that x is stored at fp - 20.  We check that this is the same29; location accessed from the funclet to retrieve x.30; CHECK:       mov     w8, #131; CHECK:       stur    w8, [x29, [[X_OFFSET:#-[1-9][0-9]+]]32 33; Check the offset off the frame pointer at which B is located.34; Check the same offset is used to pass the address of B to init2 in the35; funclet.36; CHECK:       sub     x0, x29, [[B_OFFSET:#[1-9][0-9]+]]37; CHECK:       bl      "?init@@YAXPEAH@Z"38 39; This is the label for the throw that is encoded in the ip2state.40; We are inside the try block, where we make a call to func241; CHECK-LABEL: .Ltmp0:42; CHECK:       bl      "?func2@@YAHXZ43 44; CHECK:        [[CATCHRETDEST:.LBB0_[0-9]+]]:      // Block address taken45 46; Check the catch funclet.47; CHECK-LABEL: "?catch$4@?0??func@@YAHXZ@4HA":48 49; Check that the stack space is allocated only for the callee saved registers.50; CHECK:       stp     x19, x20, [sp, #-48]!51; CHECK:       str     x21, [sp, #16]52; CHECK:       str     x28, [sp, #24]53; CHECK:       stp     x29, x30, [sp, #32]54; CHECK:       add     x20, x19, #055 56; Check that there are no further stack updates.57; CHECK-NOT:   sub     sp, sp58 59; Check that the stack address passed to init2 is off the frame pointer, and60; that it matches the address of B in the parent function.61; CHECK:       sub     x0, x29, [[B_OFFSET]]62; CHECK:       bl      "?init2@@YAXPEAH@Z"63 64; Check that are storing x back to the same location off the frame pointer as in65; the parent function.66; CHECK:       stur    w8, [x29, [[X_OFFSET]]]67 68; Check that the funclet branches back to the catchret destination69; CHECK:       adrp    x0, .LBB0_270; CHECK-NEXT:  add     x0, x0, [[CATCHRETDEST]]71 72 73; Now check that the offset of the unwind help object from the stack pointer on74; entry to func is encoded in cppxdata that is passed to __CxxFrameHandler3.  As75; computed above, this comes to -16.76; CHECK-LABEL:        "$cppxdata$?func@@YAHXZ":77; CHECK-NEXT:         .word   429065506               // MagicNumber78; CHECK-NEXT:         .word   2                       // MaxState79; CHECK-NEXT:         .word   "$stateUnwindMap$?func@@YAHXZ"@IMGREL // UnwindMap80; CHECK-NEXT:         .word   1                       // NumTryBlocks81; CHECK-NEXT:         .word   "$tryMap$?func@@YAHXZ"@IMGREL // TryBlockMap82; CHECK-NEXT:         .word   4                       // IPMapEntries83; CHECK-NEXT:         .word   "$ip2state$?func@@YAHXZ"@IMGREL // IPToStateXData84; CHECK-NEXT:         .word   -16                     // UnwindHelp85 86; UNWIND: Function: ?func@@YAHXZ (0x0)87; UNWIND: Prologue [88; UNWIND-NEXT: ; add fp, sp, #3289; UNWIND-NEXT: ; stp x29, x30, [sp, #32]90; UNWIND-NEXT: ; str x28, [sp, #24]91; UNWIND-NEXT: ; str x21, [sp, #16]92; UNWIND-NEXT: ; stp x19, x20, [sp, #-64]!93; UNWIND-NEXT: ; end94; UNWIND: Function: ?catch$4@?0??func@@YAHXZ@4HA95; UNWIND: Prologue [96; UNWIND-NEXT: ; stp x29, x30, [sp, #32]97; UNWIND-NEXT: ; str x28, [sp, #24]98; UNWIND-NEXT: ; str x21, [sp, #16]99; UNWIND-NEXT: ; stp x19, x20, [sp, #-48]!100; UNWIND-NEXT: ; end101 102target datalayout = "e-m:w-p:64:64-i32:32-i64:64-i128:128-n32:64-S128"103target triple = "aarch64-unknown-windows-msvc19.11.0"104 105%rtti.TypeDescriptor2 = type { ptr, ptr, [3 x i8] }106%eh.CatchableType = type { i32, i32, i32, i32, i32, i32, i32 }107%eh.CatchableTypeArray.1 = type { i32, [1 x i32] }108%eh.ThrowInfo = type { i32, i32, i32, i32 }109 110$"??_R0H@8" = comdat any111 112$"_CT??_R0H@84" = comdat any113 114$_CTA1H = comdat any115 116$_TI1H = comdat any117 118@"??_7type_info@@6B@" = external constant ptr119@"??_R0H@8" = linkonce_odr global %rtti.TypeDescriptor2 { ptr @"??_7type_info@@6B@", ptr null, [3 x i8] c".H\00" }, comdat120@__ImageBase = external dso_local constant i8121@"_CT??_R0H@84" = linkonce_odr unnamed_addr constant %eh.CatchableType { i32 1, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"??_R0H@8" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32), i32 0, i32 -1, i32 0, i32 4, i32 0 }, section ".xdata", comdat122@_CTA1H = linkonce_odr unnamed_addr constant %eh.CatchableTypeArray.1 { i32 1, [1 x i32] [i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @"_CT??_R0H@84" to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32)] }, section ".xdata", comdat123@_TI1H = linkonce_odr unnamed_addr constant %eh.ThrowInfo { i32 0, i32 0, i32 0, i32 trunc (i64 sub nuw nsw (i64 ptrtoint (ptr @_CTA1H to i64), i64 ptrtoint (ptr @__ImageBase to i64)) to i32) }, section ".xdata", comdat124 125; Function Attrs: noinline optnone126define dso_local i32 @"?func@@YAHXZ"() #0 personality ptr @__CxxFrameHandler3 {127entry:128  %B = alloca [50 x i32], align 4129  %x = alloca i32, align 4130  %tmp = alloca i32, align 4131  %i = alloca i32, align 4132  %C = alloca [100 x i32], align 4133  store i32 1, ptr %x, align 4134  call void @"?init@@YAXPEAH@Z"(ptr %B)135  %call = invoke i32 @"?func2@@YAHXZ"()136          to label %invoke.cont unwind label %catch.dispatch137 138invoke.cont:                                      ; preds = %entry139  store i32 %call, ptr %tmp, align 4140  invoke void @_CxxThrowException(ptr %tmp, ptr @_TI1H) #2141          to label %unreachable unwind label %catch.dispatch142 143catch.dispatch:                                   ; preds = %invoke.cont, %entry144  %0 = catchswitch within none [label %catch] unwind to caller145 146catch:                                            ; preds = %catch.dispatch147  %1 = catchpad within %0 [ptr @"??_R0H@8", i32 0, ptr %i]148  call void @"?init@@YAXPEAH@Z"(ptr %C) [ "funclet"(token %1) ]149  call void @"?init2@@YAXPEAH@Z"(ptr %B) [ "funclet"(token %1) ]150  %2 = load i32, ptr %i, align 4151  %idxprom = sext i32 %2 to i64152  %arrayidx = getelementptr inbounds [50 x i32], ptr %B, i64 0, i64 %idxprom153  %3 = load i32, ptr %arrayidx, align 4154  %4 = load i32, ptr %i, align 4155  %idxprom3 = sext i32 %4 to i64156  %arrayidx4 = getelementptr inbounds [100 x i32], ptr %C, i64 0, i64 %idxprom3157  %5 = load i32, ptr %arrayidx4, align 4158  %add = add nsw i32 %3, %5159  %6 = load i32, ptr %i, align 4160  %7 = load i32, ptr %i, align 4161  %mul = mul nsw i32 %6, %7162  %add5 = add nsw i32 %add, %mul163  store i32 %add5, ptr %x, align 4164  catchret from %1 to label %catchret.dest165 166catchret.dest:                                    ; preds = %catch167  br label %try.cont168 169try.cont:                                         ; preds = %catchret.dest170  %arrayidx6 = getelementptr inbounds [50 x i32], ptr %B, i64 0, i64 2171  %8 = load i32, ptr %arrayidx6, align 4172  %9 = load i32, ptr %x, align 4173  %add7 = add nsw i32 %8, %9174  ret i32 %add7175 176unreachable:                                      ; preds = %invoke.cont177  unreachable178}179 180declare dso_local void @"?init@@YAXPEAH@Z"(ptr)181 182declare dso_local i32 @"?func2@@YAHXZ"()183 184declare dso_local i32 @__CxxFrameHandler3(...)185 186declare dllimport void @_CxxThrowException(ptr, ptr)187 188declare dso_local void @"?init2@@YAXPEAH@Z"(ptr)189 190attributes #0 = { noinline optnone }191attributes #2 = { noreturn }192