mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 06:53:40 +00:00
compiler: add "target-cpu" and "target-features" attributes
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)`.
This commit is contained in:
committed by
Ron Evans
parent
78fec3719f
commit
cf640290a3
@@ -21,6 +21,11 @@ import (
|
||||
|
||||
var update = flag.Bool("update", false, "update transform package tests")
|
||||
|
||||
var defaultTestConfig = &compileopts.Config{
|
||||
Target: &compileopts.TargetSpec{},
|
||||
Options: &compileopts.Options{Opt: "2"},
|
||||
}
|
||||
|
||||
// testTransform runs a transformation pass on an input file (pathPrefix+".ll")
|
||||
// and checks whether it matches the expected output (pathPrefix+".out.ll"). The
|
||||
// output is compared with a fuzzy match that ignores some irrelevant lines such
|
||||
|
||||
Reference in New Issue
Block a user