mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-03 02:27:48 +00:00
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.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
if config.printIR {
|
||||
fmt.Println("Generated LLVM IR:")
|
||||
fmt.Println(c.IR())
|
||||
}
|
||||
|
||||
c.ApplyFunctionSections() // -ffunction-sections
|
||||
|
||||
if err := c.Verify(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user