use error returns to generate detailed error messages in the IR checker

This commit is contained in:
Jaden Weiss
2019-10-18 11:58:12 -04:00
committed by Ayke
parent adff391bd2
commit 388d11eecf
2 changed files with 87 additions and 34 deletions
+9 -1
View File
@@ -25,7 +25,10 @@ func (c *Compiler) Optimize(optLevel, sizeLevel int, inlinerThreshold uint) erro
// run a check of all of our code
if c.VerifyIR {
c.checkModule()
err := c.checkModule()
if err != nil {
return err
}
}
// Run function passes for each function.
@@ -93,6 +96,11 @@ func (c *Compiler) Optimize(optLevel, sizeLevel int, inlinerThreshold uint) erro
return err
}
}
if c.VerifyIR {
if err := c.checkModule(); err != nil {
return err
}
}
if err := c.Verify(); err != nil {
return errors.New("optimizations caused a verification failure")
}