Browse Source

all: fix -gc=none

This option was broken for a long time, in part because we didn't test
for it. This commit fixes that and adds a test to make sure it won't
break again unnoticed.
pull/1247/head
Ayke van Laethem 4 years ago
committed by Ron Evans
parent
commit
05495c4282
  1. 5
      Makefile
  2. 2
      interp/scan.go
  3. 2
      transform/optimizer.go

5
Makefile

@ -335,6 +335,11 @@ endif
@$(MD5SUM) test.hex @$(MD5SUM) test.hex
$(TINYGO) build -o wasm.wasm -target=wasm examples/wasm/export $(TINYGO) build -o wasm.wasm -target=wasm examples/wasm/export
$(TINYGO) build -o wasm.wasm -target=wasm examples/wasm/main $(TINYGO) build -o wasm.wasm -target=wasm examples/wasm/main
# test various compiler flags
$(TINYGO) build -size short -o test.hex -target=pca10040 -gc=none -scheduler=none examples/blinky1
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=pca10040 -opt=1 examples/blinky1
@$(MD5SUM) test.hex
wasmtest: wasmtest:
$(GO) test ./tests/wasm $(GO) test ./tests/wasm

2
interp/scan.go

@ -122,6 +122,8 @@ func (e *evalPackage) hasSideEffects(fn llvm.Value) (*sideEffectResult, *Error)
// External function call. Assume only limited side effects // External function call. Assume only limited side effects
// (no affected globals, etc.). // (no affected globals, etc.).
switch child.Name() { switch child.Name() {
case "runtime.alloc":
continue
case "runtime.typeAssert": case "runtime.typeAssert":
continue // implemented in interp continue // implemented in interp
case "runtime.interfaceImplements": case "runtime.interfaceImplements":

2
transform/optimizer.go

@ -158,7 +158,7 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i
// After TinyGo-specific transforms have finished, undo exporting these functions. // After TinyGo-specific transforms have finished, undo exporting these functions.
for _, name := range getFunctionsUsedInTransforms(config) { for _, name := range getFunctionsUsedInTransforms(config) {
fn := mod.NamedFunction(name) fn := mod.NamedFunction(name)
if fn.IsNil() { if fn.IsNil() || fn.IsDeclaration() {
continue continue
} }
fn.SetLinkage(llvm.InternalLinkage) fn.SetLinkage(llvm.InternalLinkage)

Loading…
Cancel
Save