compiler: do not emit code for unused imported functions
Our current algorithm marks function as used if it is called at least ones, even if the callee function is itself unused. This commit implements more clever traversal to collect usage information more precisely. Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
a340e11b0b
commit
0bc81aecf4
6 changed files with 174 additions and 10 deletions
30
pkg/compiler/testdata/nestedcall/call.go
vendored
Normal file
30
pkg/compiler/testdata/nestedcall/call.go
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
package nestedcall
|
||||
|
||||
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/nestedcall/inner"
|
||||
|
||||
// X is what we use.
|
||||
const X = 42
|
||||
|
||||
// N returns inner.A().
|
||||
func N() int {
|
||||
return inner.Return65()
|
||||
}
|
||||
|
||||
// F calls G.
|
||||
func F() int {
|
||||
a := 1
|
||||
return G() + a
|
||||
}
|
||||
|
||||
// G calls x and returns y().
|
||||
func G() int {
|
||||
x()
|
||||
z := 3
|
||||
return y() + z
|
||||
}
|
||||
|
||||
func x() {}
|
||||
func y() int {
|
||||
tmp := 10
|
||||
return tmp
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue