Skip to content

[WebAssembly] Implement an alternative translation for -wasm-enable-sjlj #84137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 28 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
caf4c18
[WebAssembly] Implement an alternative translation for -wasm-enable-sjlj
yamt Feb 9, 2024
e03effd
WebAssemblyLowerEmscriptenEHSjLj.cpp: move a comment to appropriate p…
yamt Mar 8, 2024
f8dfddd
WebAssemblyLowerEmscriptenEHSjLj.cpp: comment
yamt Mar 8, 2024
df806bc
clang/lib/Driver/ToolChains/WebAssembly.cpp: fix whitespace in a comment
yamt Mar 11, 2024
32e0227
WebAssemblyMCTargetDesc.cpp: fix a typo in a description
yamt Mar 11, 2024
a77188f
move some SSAUpdate stuff in !EnableWasmAltSjLj block
yamt Mar 11, 2024
6ce14ec
WebAssemblyLowerEmscriptenEHSjLj: move some code to !EnableWasmAltSjL…
yamt Mar 11, 2024
15f8fda
remove -mllvm -experimental-wasm-enable-alt-sjlj
yamt Mar 13, 2024
2b1f35f
remove -mllvm -experimental-wasm-enable-alt-sjlj
yamt Mar 13, 2024
13a142a
handleLongjmpableCallsForWasmSjLj: simplify a bit
yamt Mar 13, 2024
3151476
rename abi functions
yamt Mar 13, 2024
7deaee4
llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp: com…
yamt Mar 13, 2024
df16649
handleLongjmpableCallsForWasmSjLj: simplify a bit
yamt Mar 13, 2024
7cdd8e0
WebAssemblyLowerEmscriptenEHSjLj.cpp: fix a botch in FunctionIvocatio…
yamt Mar 13, 2024
35a1099
give an IR level name to function invocation id
yamt Mar 13, 2024
68833b0
llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll: update
yamt Mar 13, 2024
ccfd3ed
llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj.ll: update
yamt Mar 13, 2024
a28f85b
WebAssemblyLowerEmscriptenEHSjLj.cpp: comment
yamt Mar 13, 2024
0c1acd8
format
yamt Mar 13, 2024
ae2b1f2
WebAssemblyLowerEmscriptenEHSjLj.cpp: comment
yamt Mar 13, 2024
68cceec
WebAssemblyLowerEmscriptenEHSjLj.cpp: adapt emscripten sjlj as well
yamt Mar 15, 2024
e6b37dc
fix __wasm_setjmp_test invocation
yamt Mar 15, 2024
a89b0d8
rename variables
yamt Mar 15, 2024
d14eeca
comment
yamt Mar 15, 2024
6f54497
comment
yamt Mar 15, 2024
db00c9b
update llvm/test/CodeGen/WebAssembly/lower-em-*.ll
yamt Mar 15, 2024
a007209
comment
yamt Mar 16, 2024
a060778
simplify a bit
yamt Mar 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
314 changes: 99 additions & 215 deletions llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj-options.ll
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,12 @@ entry:
%call = call i32 @setjmp(ptr %buf) #0
call void @longjmp(ptr %buf, i32 1) #1
unreachable
; SJLJ: call saveSetjmp
; SJLJ: call __wasm_setjmp
; SJLJ: i32.const emscripten_longjmp
; SJLJ-NOT: i32.const emscripten_longjmp_jmpbuf
; SJLJ: call invoke_vii
; SJLJ-NOT: call "__invoke_void_ptr_i32"
; SJLJ: call testSetjmp
; SJLJ: call __wasm_setjmp_test

; NONE: call setjmp
; NONE: call longjmp
Expand Down
5 changes: 1 addition & 4 deletions llvm/test/CodeGen/WebAssembly/lower-em-ehsjlj.ll
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ try.cont: ; preds = %lpad, %entry

; longjmp checking part
; CHECK: if.then1:
; CHECK: call i32 @testSetjmp
; CHECK: call i32 @__wasm_setjmp_test
}

; @foo can either throw an exception or longjmp. Because this function doesn't
Expand Down Expand Up @@ -117,7 +117,6 @@ if.end: ; preds = %entry

; CHECK: rethrow.exn:
; CHECK-NEXT: %exn = call ptr @__cxa_find_matching_catch_2()
; CHECK-NEXT: call void @free(ptr %setjmpTable{{.*}})
; CHECK-NEXT: call void @__resumeException(ptr %exn)
; CHECK-NEXT: unreachable

Expand Down Expand Up @@ -147,7 +146,6 @@ throw: ; preds = %if.end, %entry
unreachable

; CHECK: throw:
; CHECK-NEXT: call void @free(ptr %setjmpTable{{.*}})
; CHECK-NEXT: call void @__cxa_throw(ptr null, ptr null, ptr null)
; CHECK-NEXT: unreachable
}
Expand Down Expand Up @@ -208,7 +206,6 @@ return: ; preds = %entry, %if.end

; CHECK: rethrow.exn:
; CHECK-NEXT: %exn = call ptr @__cxa_find_matching_catch_2()
; CHECK-NEXT: tail call void @free(ptr %setjmpTable{{.*}})
; CHECK-NEXT: call void @__resumeException(ptr %exn)
; CHECK-NEXT: unreachable
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/WebAssembly/lower-em-sjlj-alias.ll
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ target triple = "wasm32-unknown-emscripten"
; CHECK-LABEL: @malloc_test
define void @malloc_test() {
entry:
; CHECK: call ptr @malloc
; CHECK: alloca i32
%retval = alloca i32, align 4
%jmp = alloca [1 x %struct.__jmp_buf_tag], align 16
store i32 0, ptr %retval, align 4
Expand Down
35 changes: 3 additions & 32 deletions llvm/test/CodeGen/WebAssembly/lower-em-sjlj-debuginfo.ll
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,22 @@ entry:
call void @foo(), !dbg !7
ret void, !dbg !8
; CHECK: entry:
; CHECK-NEXT: call ptr @malloc(i32 40), !dbg ![[DL0:.*]]
; CHECK-NEXT: %functionInvocationId = alloca i32, align 4, !dbg ![[DL0:.*]]

; CHECK: entry.split:
; CHECK: alloca {{.*}}, !dbg ![[DL0]]
; CHECK: call ptr @saveSetjmp{{.*}}, !dbg ![[DL1:.*]]
; CHECK-NEXT: call i32 @getTempRet0{{.*}}, !dbg ![[DL1]]
; CHECK: call void @__wasm_setjmp{{.*}}, !dbg ![[DL1:.*]]
; CHECK-NEXT: br {{.*}}, !dbg ![[DL2:.*]]

; CHECK: entry.split.split:
; CHECK: call {{.*}} void @__invoke_void{{.*}}, !dbg ![[DL2]]

; CHECK: entry.split.split.split:
; CHECK-NEXT: call void @free{{.*}}, !dbg ![[DL3:.*]]

; CHECK: if.then1:
; CHECK: call i32 @testSetjmp{{.*}}, !dbg ![[DL2]]
; CHECK: call i32 @__wasm_setjmp_test{{.*}}, !dbg ![[DL2]]

; CHECK: if.end:
; CHECK: call i32 @getTempRet0{{.*}}, !dbg ![[DL2]]

; CHECK: call.em.longjmp:
; CHECK: call void @emscripten_longjmp{{.*}}, !dbg ![[DL2]]
Expand All @@ -43,26 +40,6 @@ entry:
; CHECK: call void @setTempRet0{{.*}}, !dbg ![[DL2]]
}

; No instruction has debug info but the current function (setjmp_debug_info2)
; and the called function (malloc / free) have DISubprograms, so the newly
; generated calls should have debug info attached. We don't have an instruction
; to take debug info from, so we create dummy debug info.
define void @setjmp_debug_info1() !dbg !9 {
; CHECK-LABEL: @setjmp_debug_info1
entry:
%buf = alloca [1 x %struct.__jmp_buf_tag], align 16
%arraydecay = getelementptr inbounds [1 x %struct.__jmp_buf_tag], ptr %buf, i32 0, i32 0
%call = call i32 @setjmp(ptr %arraydecay) #0
call void @foo()
ret void
; CHECK: call ptr @malloc(i32 40), !dbg ![[DL_DUMMY:.*]]
; CHECK: call void @free{{.*}}, !dbg ![[DL_DUMMY]]
}

; Note that these functions have DISubprograms.
declare !dbg !10 ptr @malloc(i32)
declare !dbg !11 void @free(ptr)

declare void @foo()
; Function Attrs: returns_twice
declare i32 @setjmp(ptr) #0
Expand All @@ -79,9 +56,3 @@ declare i32 @setjmp(ptr) #0
!6 = !DILocation(line:4, scope: !3)
!7 = !DILocation(line:5, scope: !3)
!8 = !DILocation(line:6, scope: !3)
!9 = distinct !DISubprogram(name: "setjmp_debug_info1", unit:!2, file: !1, line: 50)
!10 = !DISubprogram(name: "malloc", file: !1, line: 10, isDefinition: false)
!11 = !DISubprogram(name: "free", file: !1, line: 20, isDefinition: false)

; Dummy debug info generated
; CHECK: ![[DL_DUMMY]] = !DILocation(line: 50, column: 1, scope: !9)
37 changes: 12 additions & 25 deletions llvm/test/CodeGen/WebAssembly/lower-em-sjlj.ll
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ entry:
call void @longjmp(ptr %buf, i32 1) #1
unreachable
; CHECK: entry:
; CHECK-NEXT: %[[MALLOCCALL:.*]] = tail call ptr @malloc([[PTR]] 40)
; CHECK-NEXT: store i32 0, ptr %[[MALLOCCALL]]
; CHECK-NEXT: %[[SETJMP_TABLE_SIZE:.*]] = add i32 4, 0
; CHECK-NEXT: %functionInvocationId = alloca i32, align 4
; CHECK-NEXT: br label %entry.split

; CHECK: entry.split
; CHECK-NEXT: %[[BUF:.*]] = alloca [1 x %struct.__jmp_buf_tag]
; CHECK-NEXT: %[[SETJMP_TABLE1:.*]] = call ptr @saveSetjmp(ptr %[[BUF]], i32 1, ptr %[[MALLOCCALL]], i32 %[[SETJMP_TABLE_SIZE]])
; CHECK-NEXT: %[[SETJMP_TABLE_SIZE1:.*]] = call i32 @getTempRet0()
; CHECK-NEXT: call void @__wasm_setjmp(ptr %[[BUF]], i32 1, ptr %functionInvocationId)
; CHECK-NEXT: br label %entry.split.split

; CHECK: entry.split.split:
Expand All @@ -51,8 +48,7 @@ entry:

; CHECK: if.then1:
; CHECK-NEXT: %[[__THREW__VAL_P:.*]] = inttoptr [[PTR]] %[[__THREW__VAL]] to ptr
; CHECK-NEXT: %[[__THREW__VAL_P_LOADED:.*]] = load [[PTR]], ptr %[[__THREW__VAL_P]]
; CHECK-NEXT: %[[LABEL:.*]] = call i32 @testSetjmp([[PTR]] %[[__THREW__VAL_P_LOADED]], ptr %[[SETJMP_TABLE1]], i32 %[[SETJMP_TABLE_SIZE1]])
; CHECK-NEXT: %[[LABEL:.*]] = call i32 @__wasm_setjmp_test(ptr %[[__THREW__VAL_P]], ptr %functionInvocationId)
; CHECK-NEXT: %[[CMP:.*]] = icmp eq i32 %[[LABEL]], 0
; CHECK-NEXT: br i1 %[[CMP]], label %call.em.longjmp, label %if.end2

Expand All @@ -69,7 +65,6 @@ entry:
; CHECK: call.em.longjmp:
; CHECK-NEXT: %threw.phi = phi [[PTR]] [ %[[__THREW__VAL]], %if.then1 ]
; CHECK-NEXT: %threwvalue.phi = phi i32 [ %[[THREWVALUE_VAL]], %if.then1 ]
; CHECK-NEXT: tail call void @free(ptr %[[SETJMP_TABLE1]])
; CHECK-NEXT: call void @emscripten_longjmp([[PTR]] %threw.phi, i32 %threwvalue.phi)
; CHECK-NEXT: unreachable

Expand All @@ -87,13 +82,12 @@ entry:
call void @foo()
ret void
; CHECK: entry:
; CHECK: %[[SETJMP_TABLE:.*]] = call ptr @saveSetjmp(
; CHECK: call void @__wasm_setjmp(

; CHECK: entry.split.split:
; CHECK: @__invoke_void(ptr @foo)

; CHECK: entry.split.split.split:
; CHECK-NEXT: tail call void @free(ptr %[[SETJMP_TABLE]])
; CHECK-NEXT: ret void
}

Expand All @@ -110,9 +104,8 @@ entry:
call void @foo()
ret void
; CHECK: call.em.longjmp:
; CHECK-NEXT: %threw.phi = phi [[PTR]] [ %__THREW__.val, %if.then1 ], [ %__THREW__.val4, %if.then15 ]
; CHECK-NEXT: %threwvalue.phi = phi i32 [ %__threwValue.val, %if.then1 ], [ %__threwValue.val8, %if.then15 ]
; CHECK-NEXT: tail call void @free(ptr %[[SETJMP_TABLE1]])
; CHECK-NEXT: %threw.phi = phi [[PTR]] [ %__THREW__.val, %if.then1 ], [ %__THREW__.val2, %if.then13 ]
; CHECK-NEXT: %threwvalue.phi = phi i32 [ %__threwValue.val, %if.then1 ], [ %__threwValue.val6, %if.then13 ]
; CHECK-NEXT: call void @emscripten_longjmp([[PTR]] %threw.phi, i32 %threwvalue.phi)
; CHECK-NEXT: unreachable
}
Expand Down Expand Up @@ -145,7 +138,6 @@ entry:
%cmp = icmp sgt i32 %n, 5
br i1 %cmp, label %if.then, label %if.end
; CHECK: entry:
; CHECK: %[[SETJMP_TABLE_SIZE0:.*]] = add i32 4, 0

if.then: ; preds = %entry
%0 = load i32, ptr @global_var, align 4
Expand All @@ -154,22 +146,17 @@ if.then: ; preds = %entry
br label %if.end
; CHECK: if.then:
; CHECK: %[[VAR0:.*]] = load i32, ptr @global_var, align 4
; CHECK: %[[SETJMP_TABLE1:.*]] = call ptr @saveSetjmp(
; CHECK-NEXT: %[[SETJMP_TABLE_SIZE1:.*]] = call i32 @getTempRet0()
; CHECK: call void @__wasm_setjmp(

; CHECK: if.then.split:
; CHECK: %[[VAR1:.*]] = phi i32 [ %[[VAR2:.*]], %if.end3 ], [ %[[VAR0]], %if.then ]
; CHECK: %[[SETJMP_TABLE_SIZE2:.*]] = phi i32 [ %[[SETJMP_TABLE_SIZE1]], %if.then ], [ %[[SETJMP_TABLE_SIZE3:.*]], %if.end3 ]
; CHECK: %[[SETJMP_TABLE2:.*]] = phi ptr [ %[[SETJMP_TABLE1]], %if.then ], [ %[[SETJMP_TABLE3:.*]], %if.end3 ]
; CHECK: %[[VAR1:.*]] = phi i32 [ %[[VAR2:.*]], %if.end1 ], [ %[[VAR0]], %if.then ]
; CHECK: store i32 %[[VAR1]], ptr @global_var, align 4

if.end: ; preds = %if.then, %entry
call void @longjmp(ptr %buf, i32 5) #1
unreachable
; CHECK: if.end:
; CHECK: %[[VAR2]] = phi i32 [ %[[VAR1]], %if.then.split ], [ undef, %entry.split ]
; CHECK: %[[SETJMP_TABLE_SIZE3]] = phi i32 [ %[[SETJMP_TABLE_SIZE2]], %if.then.split ], [ %[[SETJMP_TABLE_SIZE0]], %entry.split ]
; CHECK: %[[SETJMP_TABLE3]] = phi ptr [ %[[SETJMP_TABLE2]], %if.then.split ], [ %setjmpTable, %entry.split ]
}

; Test a case when a function only calls other functions that are neither setjmp nor longjmp
Expand Down Expand Up @@ -296,8 +283,8 @@ declare void @free(ptr)
; JS glue functions and invoke wrappers declaration
; CHECK-DAG: declare i32 @getTempRet0()
; CHECK-DAG: declare void @setTempRet0(i32)
; CHECK-DAG: declare ptr @saveSetjmp(ptr, i32, ptr, i32)
; CHECK-DAG: declare i32 @testSetjmp([[PTR]], ptr, i32)
; CHECK-DAG: declare void @__wasm_setjmp(ptr, i32, ptr)
; CHECK-DAG: declare i32 @__wasm_setjmp_test(ptr, ptr)
; CHECK-DAG: declare void @emscripten_longjmp([[PTR]], i32)
; CHECK-DAG: declare void @__invoke_void(ptr)

Expand All @@ -308,8 +295,8 @@ attributes #3 = { allocsize(0) }
; CHECK-DAG: attributes #{{[0-9]+}} = { nounwind "wasm-import-module"="env" "wasm-import-name"="getTempRet0" }
; CHECK-DAG: attributes #{{[0-9]+}} = { nounwind "wasm-import-module"="env" "wasm-import-name"="setTempRet0" }
; CHECK-DAG: attributes #{{[0-9]+}} = { "wasm-import-module"="env" "wasm-import-name"="__invoke_void" }
; CHECK-DAG: attributes #{{[0-9]+}} = { "wasm-import-module"="env" "wasm-import-name"="saveSetjmp" }
; CHECK-DAG: attributes #{{[0-9]+}} = { "wasm-import-module"="env" "wasm-import-name"="testSetjmp" }
; CHECK-DAG: attributes #{{[0-9]+}} = { "wasm-import-module"="env" "wasm-import-name"="__wasm_setjmp" }
; CHECK-DAG: attributes #{{[0-9]+}} = { "wasm-import-module"="env" "wasm-import-name"="__wasm_setjmp_test" }
; CHECK-DAG: attributes #{{[0-9]+}} = { noreturn "wasm-import-module"="env" "wasm-import-name"="emscripten_longjmp" }
; CHECK-DAG: attributes #{{[0-9]+}} = { "wasm-import-module"="env" "wasm-import-name"="__invoke_ptr_i32_ptr" }
; CHECK-DAG: attributes #[[ALLOCSIZE_ATTR]] = { allocsize(1) }
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/CodeGen/WebAssembly/lower-wasm-ehsjlj.ll
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ catch: ; preds = %catch.start
call void @__cxa_end_catch() [ "funclet"(token %2) ]
catchret from %2 to label %catchret.dest
; CHECK: catch: ; preds = %catch.start
; CHECK-NEXT: %exn = load ptr, ptr %exn.slot15, align 4
; CHECK-NEXT: %5 = call ptr @__cxa_begin_catch(ptr %exn) #7 [ "funclet"(token %2) ]
; CHECK-NEXT: %exn = load ptr, ptr %exn.slot6, align 4
; CHECK-NEXT: %5 = call ptr @__cxa_begin_catch(ptr %exn) #6 [ "funclet"(token %2) ]
; CHECK-NEXT: invoke void @__cxa_end_catch() [ "funclet"(token %2) ]
; CHECK-NEXT: to label %.noexc unwind label %catch.dispatch.longjmp

Expand Down Expand Up @@ -265,7 +265,7 @@ ehcleanup: ; preds = %entry
; (cleanuppad), whose parent is 'none', so we should unwind directly to
; %catch.dispatch.longjmp.
%call2 = call noundef ptr @_ZN4TempD2Ev(ptr noundef %t) #2 [ "funclet"(token %0) ]
; CHECK: %call13 = invoke {{.*}} ptr @_ZN4TempD2Ev(ptr
; CHECK: %call11 = invoke {{.*}} ptr @_ZN4TempD2Ev(ptr
; CHECK-NEXT: to label {{.*}} unwind label %catch.dispatch.longjmp
cleanupret from %0 unwind to caller
}
Expand Down
22 changes: 6 additions & 16 deletions llvm/test/CodeGen/WebAssembly/lower-wasm-sjlj.ll
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,24 @@ entry:
unreachable

; CHECK: entry:
; CHECK-NEXT: %setjmpTable = tail call ptr @malloc([[PTR]] 40)
; CHECK-NEXT: store i32 0, ptr %setjmpTable, align 4
; CHECK-NEXT: %setjmpTableSize = add i32 4, 0
; CHECK-NEXT: %functionInvocationId = alloca i32, align 4
; CHECK-NEXT: br label %setjmp.dispatch

; CHECK: setjmp.dispatch:
; CHECK-NEXT: %[[VAL2:.*]] = phi i32 [ %val, %if.end ], [ undef, %entry ]
; CHECK-NEXT: %[[BUF:.*]] = phi ptr [ %[[BUF2:.*]], %if.end ], [ undef, %entry ]
; CHECK-NEXT: %[[SETJMPTABLESIZE2:.*]] = phi i32 [ %[[SETJMPTABLESIZE3:.*]], %if.end ], [ %setjmpTableSize, %entry ]
; CHECK-NEXT: %[[SETJMPTABLE2:.*]] = phi ptr [ %[[SETJMPTABLE3:.*]], %if.end ], [ %setjmpTable, %entry ]
; CHECK-NEXT: %label.phi = phi i32 [ %label, %if.end ], [ -1, %entry ]
; CHECK-NEXT: switch i32 %label.phi, label %entry.split [
; CHECK-NEXT: i32 1, label %entry.split.split
; CHECK-NEXT: ]

; CHECK: entry.split:
; CHECK-NEXT: %buf = alloca [1 x %struct.__jmp_buf_tag], align 16
; CHECK-NEXT: %[[SETJMPTABLE4:.*]] = call ptr @saveSetjmp(ptr %buf, i32 1, ptr %[[SETJMPTABLE2]], i32 %[[SETJMPTABLESIZE2]])
; CHECK-NEXT: %[[SETJMPTABLESIZE4:.*]] = call i32 @getTempRet0()
; CHECK-NEXT: call void @__wasm_setjmp(ptr %buf, i32 1, ptr %functionInvocationId)
; CHECK-NEXT: br label %entry.split.split

; CHECK: entry.split.split:
; CHECK-NEXT: %[[BUF2]] = phi ptr [ %[[BUF]], %setjmp.dispatch ], [ %buf, %entry.split ]
; CHECK-NEXT: %[[SETJMPTABLESIZE3]] = phi i32 [ %[[SETJMPTABLESIZE4]], %entry.split ], [ %[[SETJMPTABLESIZE2]], %setjmp.dispatch ]
; CHECK-NEXT: %[[SETJMPTABLE3]] = phi ptr [ %[[SETJMPTABLE4]], %entry.split ], [ %[[SETJMPTABLE2]], %setjmp.dispatch ]
; CHECK-NEXT: %setjmp.ret = phi i32 [ 0, %entry.split ], [ %[[VAL2]], %setjmp.dispatch ]
; CHECK-NEXT: invoke void @__wasm_longjmp(ptr %[[BUF2]], i32 1)
; CHECK-NEXT: to label %.noexc unwind label %catch.dispatch.longjmp
Expand All @@ -67,13 +60,11 @@ entry:
; CHECK-NEXT: %val_gep = getelementptr { ptr, i32 }, ptr %thrown, i32 0, i32 1
; CHECK-NEXT: %env = load ptr, ptr %env_gep, align {{.*}}
; CHECK-NEXT: %val = load i32, ptr %val_gep, align 4
; CHECK-NEXT: %setjmp.id = load [[PTR]], ptr %env, align {{.*}}
; CHECK-NEXT: %label = call i32 @testSetjmp([[PTR]] %setjmp.id, ptr %[[SETJMPTABLE3]], i32 %[[SETJMPTABLESIZE3]]) [ "funclet"(token %1) ]
; CHECK-NEXT: %label = call i32 @__wasm_setjmp_test(ptr %env, ptr %functionInvocationId) [ "funclet"(token %1) ]
; CHECK-NEXT: %2 = icmp eq i32 %label, 0
; CHECK-NEXT: br i1 %2, label %if.then, label %if.end

; CHECK: if.then:
; CHECK-NEXT: tail call void @free(ptr %[[SETJMPTABLE3]]) [ "funclet"(token %1) ]
; CHECK-NEXT: call void @__wasm_longjmp(ptr %env, i32 %val) [ "funclet"(token %1) ]
; CHECK-NEXT: unreachable

Expand Down Expand Up @@ -142,10 +133,9 @@ declare ptr @__cxa_begin_catch(ptr)
declare void @__cxa_end_catch()
declare void @free(ptr)

; JS glue function declarations
; CHECK-DAG: declare i32 @getTempRet0()
; CHECK-DAG: declare ptr @saveSetjmp(ptr, i32, ptr, i32)
; CHECK-DAG: declare i32 @testSetjmp([[PTR]], ptr, i32)
; Runtime glue function declarations
; CHECK-DAG: declare void @__wasm_setjmp(ptr, i32, ptr)
; CHECK-DAG: declare i32 @__wasm_setjmp_test(ptr, ptr)
; CHECK-DAG: declare void @__wasm_longjmp(ptr, i32)

attributes #0 = { returns_twice }
Expand Down