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.
Этот коммит содержится в:
родитель
8a211d36aa
коммит
4e4f91bea7
1 изменённых файлов: 11 добавлений и 13 удалений
24
main.go
24
main.go
|
@ -46,22 +46,20 @@ func Compile(pkgName, outpath string, spec *TargetSpec, config *BuildConfig, act
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile Go code to IR.
|
// Compile Go code to IR.
|
||||||
parseErr := func() error {
|
err = c.Compile(pkgName)
|
||||||
if config.printIR {
|
if err != nil {
|
||||||
// Run this even if c.Compile() panics.
|
return err
|
||||||
defer func() {
|
}
|
||||||
fmt.Println("Generated LLVM IR:")
|
if err := c.Verify(); err != nil {
|
||||||
fmt.Println(c.IR())
|
return err
|
||||||
}()
|
}
|
||||||
}
|
|
||||||
return c.Compile(pkgName)
|
if config.printIR {
|
||||||
}()
|
fmt.Println("Generated LLVM IR:")
|
||||||
if parseErr != nil {
|
fmt.Println(c.IR())
|
||||||
return parseErr
|
|
||||||
}
|
}
|
||||||
|
|
||||||
c.ApplyFunctionSections() // -ffunction-sections
|
c.ApplyFunctionSections() // -ffunction-sections
|
||||||
|
|
||||||
if err := c.Verify(); err != nil {
|
if err := c.Verify(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче