aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2018-10-31 10:10:49 +0100
committerAyke van Laethem <[email protected]>2018-10-31 10:10:49 +0100
commit4e4f91bea74fe51f19f81df34fe225df4c8ba61f (patch)
tree3b0d823aaab14a868ffd128ea3d69a04766aba2e /main.go
parent8a211d36aa77d252a22010985c549a98e044669c (diff)
downloadtinygo-4e4f91bea74fe51f19f81df34fe225df4c8ba61f.tar.gz
tinygo-4e4f91bea74fe51f19f81df34fe225df4c8ba61f.zip
main: cleanup printing of IR
Panics don't usually happen nowadays, instead the compiler package returns errors while compiling. If it still panics, this is usually from within LLVM from where deferred functions are not run.
Diffstat (limited to 'main.go')
-rw-r--r--main.go24
1 files changed, 11 insertions, 13 deletions
diff --git a/main.go b/main.go
index 467b3be90..239f8eea9 100644
--- a/main.go
+++ b/main.go
@@ -46,22 +46,20 @@ func Compile(pkgName, outpath string, spec *TargetSpec, config *BuildConfig, act
}
// Compile Go code to IR.
- parseErr := func() error {
- if config.printIR {
- // Run this even if c.Compile() panics.
- defer func() {
- fmt.Println("Generated LLVM IR:")
- fmt.Println(c.IR())
- }()
- }
- return c.Compile(pkgName)
- }()
- if parseErr != nil {
- return parseErr
+ err = c.Compile(pkgName)
+ if err != nil {
+ return err
+ }
+ if err := c.Verify(); err != nil {
+ return err
}
- c.ApplyFunctionSections() // -ffunction-sections
+ if config.printIR {
+ fmt.Println("Generated LLVM IR:")
+ fmt.Println(c.IR())
+ }
+ c.ApplyFunctionSections() // -ffunction-sections
if err := c.Verify(); err != nil {
return err
}