brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.5 KiB · 97f6d79 Raw
127 lines · plain
1; RUN: opt < %s -wasm-lower-em-ehsjlj -wasm-enable-eh -wasm-enable-sjlj -S | FileCheck %s2 3target triple = "wasm32-unknown-emscripten"4 5%struct.__jmp_buf_tag = type { [6 x i32], i32, [32 x i32] }6@buf = internal global [1 x %struct.__jmp_buf_tag] zeroinitializer, align 167 8; When longjmpable calls are coverted into invokes in Wasm SjLj transformation9; and their unwind destination is an existing catchpad or cleanuppad due to10; maintain the scope structure, the new pred BBs created by invokes and the11; correct incoming values should be added the existing phis in those unwind12; destinations.13 14; When longjmpable calls are within a cleanuppad.15define void @longjmpable_invoke_phi0() personality ptr @__gxx_wasm_personality_v0 {16; CHECK-LABEL: @longjmpable_invoke_phi017entry:18  %val.entry = call i32 @llvm.wasm.memory.size.i32(i32 0)19  %0 = call i32 @setjmp(ptr @buf) #220  invoke void @foo()21          to label %bb1 unwind label %ehcleanup122 23bb1:                                              ; preds = %entry24  ; We use llvm.wasm.memory.size intrinsic just to get/use an i32 value. The25  ; reason we use an intrinsic here is to make it not longjmpable. If this can26  ; longjmp, the result will be more complicated and hard to check.27  %val.bb1 = call i32 @llvm.wasm.memory.size.i32(i32 0)28  invoke void @foo()29          to label %bb2 unwind label %ehcleanup030 31bb2:                                              ; preds = %bb132  unreachable33 34ehcleanup0:                                       ; preds = %bb135  %1 = cleanuppad within none []36  call void @longjmpable() [ "funclet"(token %1) ]37; CHECK:      ehcleanup038; CHECK:        invoke void @longjmpable39; CHECK-NEXT:           to label %.noexc unwind label %ehcleanup140  invoke void @foo() [ "funclet"(token %1) ]41          to label %bb3 unwind label %ehcleanup142 43bb3:                                              ; preds = %ehcleanup044  %val.bb3 = call i32 @llvm.wasm.memory.size.i32(i32 0)45  call void @longjmpable() [ "funclet"(token %1) ]46; CHECK:      bb3:47; CHECK:        invoke void @longjmpable48; CHECK-NEXT:           to label %.noexc1 unwind label %ehcleanup149  cleanupret from %1 unwind label %ehcleanup150 51ehcleanup1:                                       ; preds = %bb3, %ehcleanup0, %entry52  %phi = phi i32 [ %val.entry, %entry ], [ %val.bb1, %ehcleanup0 ], [ %val.bb3, %bb3 ]53; CHECK:      ehcleanup1:54; CHECK-NEXT:   %phi = phi i32 [ %val.entry2, %entry.split.split ], [ %val.bb1, %.noexc ], [ %val.bb3, %.noexc1 ], [ %val.bb1, %ehcleanup0 ], [ %val.bb3, %bb3 ]55  %2 = cleanuppad within none []56  %3 = call i32 @llvm.wasm.memory.size.i32(i32 %phi)57  cleanupret from %2 unwind to caller58}59 60; When longjmpable calls are within a catchpad.61define void @longjmpable_invoke_phi1() personality ptr @__gxx_wasm_personality_v0 {62; CHECK-LABEL: @longjmpable_invoke_phi163entry:64  %val.entry = call i32 @llvm.wasm.memory.size.i32(i32 0)65  %0 = call i32 @setjmp(ptr @buf) #266  invoke void @foo()67          to label %bb1 unwind label %ehcleanup68 69bb1:                                              ; preds = %entry70  %val.bb1 = call i32 @llvm.wasm.memory.size.i32(i32 0)71  invoke void @foo()72          to label %bb2 unwind label %catch.dispatch73 74bb2:                                              ; preds = %bb175  unreachable76 77catch.dispatch:                                   ; preds = %bb178  %1 = catchswitch within none [label %catch.start] unwind label %ehcleanup79 80catch.start:                                      ; preds = %catch.dispatch81  %2 = catchpad within %1 [ptr null]82  %3 = call ptr @llvm.wasm.get.exception(token %2)83  %4 = call i32 @llvm.wasm.get.ehselector(token %2)84  call void @longjmpable() [ "funclet"(token %2) ]85; CHECK:      catch.start:86; CHECK:        invoke void @longjmpable87; CHECK-NEXT:           to label %.noexc unwind label %ehcleanup88  invoke void @foo() [ "funclet"(token %2) ]89          to label %bb3 unwind label %ehcleanup90 91bb3:                                              ; preds = %catch.start92  %val.bb3 = call i32 @llvm.wasm.memory.size.i32(i32 0)93  call void @longjmpable() [ "funclet"(token %2) ]94; CHECK:      bb3:95; CHECK:        invoke void @longjmpable96; CHECK-NEXT:           to label %.noexc1 unwind label %ehcleanup97  invoke void @foo() [ "funclet"(token %2) ]98          to label %bb4 unwind label %ehcleanup99 100bb4:                                              ; preds = %bb3101  unreachable102 103ehcleanup:                                        ; preds = %bb3, %catch.start, %catch.dispatch, %entry104  %phi = phi i32 [ %val.entry, %entry ], [ %val.bb1, %catch.dispatch ], [ %val.bb1, %catch.start ], [ %val.bb3, %bb3 ]105; CHECK:      ehcleanup:106; CHECK-NEXT:   %phi = phi i32 [ %val.entry2, %entry.split.split ], [ %val.bb1, %catch.dispatch ], [ %val.bb1, %.noexc ], [ %val.bb3, %.noexc1 ], [ %val.bb1, %catch.start ], [ %val.bb3, %bb3 ]107  %5 = cleanuppad within none []108  %6 = call i32 @llvm.wasm.memory.size.i32(i32 %phi)109  cleanupret from %5 unwind to caller110}111 112declare i32 @setjmp(ptr)113declare i32 @__gxx_wasm_personality_v0(...)114declare void @foo()115declare void @longjmpable()116declare void @use_i32(i32)117; Function Attrs: nocallback nofree nosync nounwind willreturn118declare i32 @llvm.wasm.get.ehselector(token) #0119; Function Attrs: nocallback nofree nosync nounwind willreturn120declare ptr @llvm.wasm.get.exception(token) #0121; Function Attrs: nocallback nofree nosync nounwind willreturn memory(read)122declare i32 @llvm.wasm.memory.size.i32(i32) #1123 124attributes #0 = { nocallback nofree nosync nounwind willreturn }125attributes #1 = { nocallback nofree nosync nounwind willreturn memory(read) }126attributes #2 = { returns_twice }127