From d9ca5f97fb014ae8805fa8efa235d277539b8a30 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Mon, 20 Aug 2018 04:31:01 +0200 Subject: [PATCH] Move coroutine passes from Makefile to compiler itself This is much more convenient. --- Makefile | 10 +++++----- compiler.go | 4 ++++ main.go | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ced7634b..b5e8992d 100644 --- a/Makefile +++ b/Makefile @@ -90,13 +90,13 @@ build/tgo: *.go go build -o build/tgo -i . # Build IR with the Go compiler. -build/%.bc: src/examples/% src/examples/%/*.go build/tgo src/runtime/*.go build/runtime-$(TARGET)-combined.bc - ./build/tgo $(TGOFLAGS) -printir -runtime build/runtime-$(TARGET)-combined.bc -o $@ $(subst src/,,$<) +build/%.o: src/examples/% src/examples/%/*.go build/tgo src/runtime/*.go build/runtime-$(TARGET)-combined.bc + ./build/tgo $(TGOFLAGS) -runtime build/runtime-$(TARGET)-combined.bc -o $@ $(subst src/,,$<) # Compile and optimize bitcode file. -build/%.o: build/%.bc - $(OPT) -coro-early -coro-split -coro-elide -Os -coro-cleanup -o $< $< - $(LLC) -filetype=obj -o $@ $< +#build/%.o: build/%.bc +# $(OPT) -coro-early -coro-split -coro-elide -Os -coro-cleanup -o $< $< +# $(LLC) -filetype=obj -o $@ $< # Compile C sources for the runtime. build/%.bc: src/runtime/%.c src/runtime/*.h diff --git a/compiler.go b/compiler.go index 297fb454..dbb9b3c9 100644 --- a/compiler.go +++ b/compiler.go @@ -1746,8 +1746,12 @@ func (c *Compiler) Optimize(optLevel, sizeLevel int) { builder.PopulateFunc(funcPasses) modPasses := llvm.NewPassManager() + modPasses.AddCoroEarlyPass() + modPasses.AddCoroSplitPass() + modPasses.AddCoroElidePass() defer modPasses.Dispose() builder.Populate(modPasses) + modPasses.AddCoroCleanupPass() modPasses.Run(c.mod) } diff --git a/main.go b/main.go index 0e0ad398..8d44f6a3 100644 --- a/main.go +++ b/main.go @@ -55,7 +55,7 @@ func Compile(pkgName, runtimePath, outpath, target string, printIR, dumpSSA bool if err := c.Verify(); err != nil { return err } - //c.Optimize(2, 1) // -O2 -Os + c.Optimize(2, 1) // -O2 -Os if err := c.Verify(); err != nil { return err }