Add TrapsNeverHappen to SideEffects's API#4086
Conversation
|
Thanks! Btw, I hope perhaps you can enable this by default in AssemblyScript? In Emscripten it's too risky, as users might use clang's |
__builtin_trap() will produce two sequenced unreachables in LLVM. So |
|
Yes, TNH can remove any unreachable. So it is not a good fit for LLVM, in general, yeah. When you use |
Nope. We have Basically it will be great to have mode which remove all dead loads with implicit traps (and perhaps other implicit traps) but still keep explicit |
|
Maybe we can add a flag for that. But it is not a good mode, as mentioned in the TNH PR, as we do things like turn an instruction into a combination of other instructions including an If you use something other than |
Hmm. It could be a solution, but it will be a breaking change and you have to think about the consequences |
|
Yes, all the options here have downsides, and are breaking changes. My hope is that if a compiler wants to adopt TNH mode then it could find the best of the options for it. Thinking more on the import path, I am considering something like this: (import "binaryen-intrinsics" "trap" (func $trap))When optimizing, binaryen would treat that as an |
|
I created rfc about this. Probably we could resolve this on language/runtime design. |
I think that might work. Then AssemblyScript would not be the only one who could benefit from this mode |
|
Instead of intrinsic imports, another option would be to use the code annotation framework we are designing to have a custom section to mark unreachables as intentional traps. Binaryen could represent those unreachables specially in the IR and either emit the annotation custom section or not in its output. |
No description provided.