1# RUN: llc -mtriple=wasm32-unknown-unknown -exception-model=wasm -mattr=+exception-handling -run-pass wasm-late-eh-prepare -run-pass wasm-cfg-stackify %s -o - | FileCheck %s 2 3# This tests 'try' and 'catch' instructions are correctly placed with respect to 4# EH_LABEL instructions. 5--- | 6 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128" 7 target triple = "wasm32-unknown-unknown" 8 9 declare i32 @__gxx_wasm_personality_v0(...) 10 declare void @foo() 11 define void @eh_label_test() personality i8* bitcast (i32 (...)* @__gxx_wasm_personality_v0 to i8*) { 12 ret void 13 } 14... 15 16--- 17# CHECK-LABEL: eh_label_test 18name: eh_label_test 19liveins: 20 - { reg: '$arguments' } 21body: | 22 bb.0: 23 ; TRY should be before EH_LABEL wrappers of throwing calls 24 ; CHECK: TRY 25 ; CHECK-NEXT: EH_LABEL 26 ; CHECK-NEXT: CALL @foo 27 ; CHECK-NEXT: EH_LABEL 28 successors: %bb.1, %bb.2 29 EH_LABEL <mcsymbol .Ltmp0> 30 CALL @foo, implicit-def dead $arguments, implicit $sp32, implicit $sp64 31 EH_LABEL <mcsymbol .Ltmp1> 32 BR %bb.2, implicit-def dead $arguments 33 34 bb.1 (landing-pad): 35 ; predecessors: %bb.0 36 successors: %bb.2 37 ; CATCH should be after an EH_LABEL at the beginning of an EH pad 38 ; CHECK: EH_LABEL 39 ; CHECK-NEXT: CATCH 40 EH_LABEL <mcsymbol .Ltmp2> 41 dead %0:i32 = EXTRACT_EXCEPTION_I32 implicit-def dead $arguments 42 CATCHRET %bb.2, %bb.0, implicit-def dead $arguments 43 44 bb.2: 45 ; predecessors: %bb.0, %bb.1 46 RETURN implicit-def dead $arguments 47... 48