all: move -panic=trap support to the compiler/runtime

Support for `-panic=trap` was previously a pass in the optimization
pipeline. This change moves it to the compiler and runtime, which in my
opinion is a much better place.

As a side effect, it also fixes
https://github.com/tinygo-org/tinygo/issues/4161 by trapping inside
runtime.runtimePanicAt and not just runtime.runtimePanic.

This change also adds a test for the list of imported functions. This is
a more generic test where it's easy to add more tests for WebAssembly
file properties, such as exported functions.
This commit is contained in:
Ayke van Laethem
2024-03-16 16:31:36 +01:00
committed by Ron Evans
parent 6384ecace0
commit ad4d722f54
10 changed files with 86 additions and 96 deletions
-4
View File
@@ -40,10 +40,6 @@ func Optimize(mod llvm.Module, config *compileopts.Config) []error {
fn.SetLinkage(llvm.ExternalLinkage)
}
if config.PanicStrategy() == "trap" {
ReplacePanicsWithTrap(mod) // -panic=trap
}
// run a check of all of our code
if config.VerifyIR() {
errs := ircheck.Module(mod)