brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · d5fbf41 Raw
120 lines · plain
1# RUN: llc -mtriple=wasm32-unknown-unknown -wasm-use-legacy-eh -wasm-enable-eh -exception-model=wasm -mattr=+exception-handling -run-pass wasm-cfg-stackify %s -o - | FileCheck %s2 3--- |4  target triple = "wasm32-unknown-unknown"5 6  declare i32 @__gxx_wasm_personality_v0(...)7  declare void @foo()8  define void @rethrow_arg_test() personality ptr @__gxx_wasm_personality_v0 {9    ret void10  }11  define i32 @fix_end_function_test() personality ptr @__gxx_wasm_personality_v0 {12    ret i32 013  }14...15 16---17# CHECK-LABEL: name: rethrow_arg_test18name: rethrow_arg_test19liveins:20  - { reg: '$arguments' }21body: |22  bb.0:23    successors: %bb.1, %bb.324    ; CHECK: bb.0:25    ; CHECK: TRY26    EH_LABEL <mcsymbol .Ltmp0>27    CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp6428    EH_LABEL <mcsymbol .Ltmp1>29    BR %bb.3, implicit-def dead $arguments30 31  bb.1 (landing-pad):32    successors: %bb.233    ; CHECK: bb.1 (landing-pad):34    ; CHECK: CATCH_LEGACY35    ; CHECK: TRY36    ; This RETHROW rethrows the exception caught by this BB's CATCH_LEGACY, but37    ; after CFGStackify a TRY is placed between the CATCH_LEGACY and this38    ; RETHROW, so after CFGStackify its immediate argument should become not 0,39    ; but 1.40    ; CHECK: RETHROW 141    EH_LABEL <mcsymbol .Ltmp2>42    %0:i32 = CATCH_LEGACY &__cpp_exception, implicit-def dead $arguments43    RETHROW %bb.1, implicit-def dead $arguments44 45  bb.2 (landing-pad):46    successors: %bb.347    ; CHECK: bb.2 (landing-pad):48    ; CHECK: CATCH_LEGACY49    ; CHECK: RETHROW 050    EH_LABEL <mcsymbol .Ltmp3>51    %1:i32 = CATCH_LEGACY &__cpp_exception, implicit-def dead $arguments52    RETHROW %bb.2, implicit-def dead $arguments53 54  bb.3:55    ; CHECK: bb.3:56    ; CHECK: END_TRY57    ; CHECK: END_TRY58    RETURN implicit-def dead $arguments59...60 61---62# This function has i32 return type and the end of the function is unreachable,63# so CFGStackify's fixEndsAtEndOfFunction() propagates the return type while64# they encounter 'end' or 'delegate'. This is a regression test for a bug that65# we only handled 'end' but not 'delegate'.66# CHECK-LABEL: name: fix_end_function_test67name: fix_end_function_test68liveins:69  - { reg: '$arguments' }70machineFunctionInfo:71  params:          [  ]72  results:         [ i32 ]73  wasmEHFuncInfo:74    3:               475body: |76  ; CHECK: TRY 12777  ; CHECK:   TRY 12778  ; CHECK:     CALL @foo79  ; CHECK:     TRY 6480  ; CHECK:       CALL @foo81  ; CHECK:     DELEGATE82  ; CHECK:     RETURN83  ; CHECK:   CATCH_LEGACY84  ;; This TRY should have the return type i32 (127)85  ; CHECK:     TRY 12786  ; CHECK:       RETHROW87  ; CHECK:     DELEGATE88  ; CHECK:   END_TRY89  ; CHECK: CATCH_LEGACY90  ; CHECK:   RETHROW91  ; CHECK: END_TRY92  bb.0:93    successors: %bb.1, %bb.394    EH_LABEL <mcsymbol .Ltmp0>95    CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp6496    EH_LABEL <mcsymbol .Ltmp1>97 98  bb.1:99    successors: %bb.2, %bb.4100    EH_LABEL <mcsymbol .Ltmp2>101    CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64102    EH_LABEL <mcsymbol .Ltmp3>103 104  bb.2:105    %0:i32 = CONST_I32 3, implicit-def dead $arguments106    RETURN %0:i32, implicit-def dead $arguments107 108  bb.3 (landing-pad):109    successors:110    EH_LABEL <mcsymbol .Ltmp4>111    %0:i32 = CATCH_LEGACY &__cpp_exception, implicit-def dead $arguments112    RETHROW %bb.3, implicit-def dead $arguments113 114  bb.4 (landing-pad):115    successors:116    EH_LABEL <mcsymbol .Ltmp5>117    %1:i32 = CATCH_LEGACY &__cpp_exception, implicit-def dead $arguments118    RETHROW %bb.4, implicit-def dead $arguments119...120