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:
Evgeniy Stratonikov 2021-09-30 11:48:18 +03:00
parent a340e11b0b
commit 0bc81aecf4
6 changed files with 174 additions and 10 deletions

15
pkg/compiler/testdata/notify/event.go vendored Normal file
View file

@ -0,0 +1,15 @@
package notify
import "github.com/nspcc-dev/neo-go/pkg/interop/runtime"
// Value is the constant we use.
const Value = 42
// EmitEvent emits some event.
func EmitEvent() {
emitPrivate()
}
func emitPrivate() {
runtime.Notify("Event")
}