[clang] [llvm] [WebAssembly] Implement an alternative translation for -wasm-enable-sjlj (PR #84137)

Heejin Ahn via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 11 12:09:07 PDT 2024


aheejin wrote:

> > > Given that we don't need `setjmpTableSize` anymore and `setjmpTable` doesn't change, we don't need the whole block here from line 1463 ~ line 1503 doing SSA updates anymore:
> > 
> > 
> > i get errors like the following if i simply put the SSA update things in `!EnableWasmAltSjLj` block. i need to investigate.
> > ```
> > spacetanuki% /Volumes/PortableSSD/llvm/build/bin/clang --sysroot /opt/wasi-sdk-21.0/share/wasi-sysroot -resource-dir /Volumes/PortableSSD/llvm/llvm/lib/clang/17 --target=wasm32-wasi -Os -c -mllvm -wasm-enable-sjlj -mllvm -experimental-wasm-enable-alt-sjlj a.c  
> > Instruction does not dominate all uses!
> >   %val = load i32, ptr %val_gep, align 4
> >   %setjmp.ret = phi i32 [ 0, %entry.split ], [ %val, %setjmp.dispatch ]
> > in function f
> > fatal error: error in backend: Broken function found, compilation aborted!
> > PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
> > Stack dump:
> > 0.      Program arguments: /Volumes/PortableSSD/llvm/build/bin/clang --sysroot /opt/wasi-sdk-21.0/share/wasi-sysroot -resource-dir /Volumes/PortableSSD/llvm/llvm/lib/clang/17 --target=wasm32-wasi -Os -c -mllvm -wasm-enable-sjlj -mllvm -experimental-wasm-enable-alt-sjlj a.c
> > 1.      <eof> parser at end of file
> > 2.      Code generation
> > 3.      Running pass 'Function Pass Manager' on module 'a.c'.
> > 4.      Running pass 'Module Verifier' on function '@f'
> > ```
> 
> i think i found the cause. rebuildSSA is still necessary to propagate "val".

Oh, I'm sorry, I was incorrect. We should include this part, because SSA rewriting is necessary for other variables (other than `setjmpTable` and `setjmpTableSize`: https://github.com/llvm/llvm-project/blob/578e66ac45dfcc5c739f3525bfb82d71282d925c/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp#L1439-L1449

What we can exclude is this part: https://github.com/llvm/llvm-project/blob/578e66ac45dfcc5c739f3525bfb82d71282d925c/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp#L1409-L1437

I'm sorry for the incorrect comment and unnecessary debugging.. 😢

https://github.com/llvm/llvm-project/pull/84137


More information about the cfe-commits mailing list