
This matches Clang, and with that, it adds support for inlining between Go and C because LLVM only allows inlining if the "target-cpu" and "target-features" string attributes match. For example, take a look at the following code: // int add(int a, int b) { // return a + b; // } import "C" func main() { println(C.add(3, 5)) } The 'add' function is not inlined into the main function before this commit, but after it, it can be inlined and trivially be optimized to `println(8)`.
19 строки
390 Б
Go
19 строки
390 Б
Go
package transform_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/tinygo-org/tinygo/transform"
|
|
"tinygo.org/x/go-llvm"
|
|
)
|
|
|
|
func TestWasmABI(t *testing.T) {
|
|
t.Parallel()
|
|
testTransform(t, "testdata/wasm-abi", func(mod llvm.Module) {
|
|
// Run ABI change pass.
|
|
err := transform.ExternalInt64AsPtr(mod, defaultTestConfig)
|
|
if err != nil {
|
|
t.Errorf("failed to change wasm ABI: %v", err)
|
|
}
|
|
})
|
|
}
|