compiler: fix escapes due to nil checks

Some tests get bigger, most get smaller. However, all tested driver
examples get smaller in size showing that this is a good change in the
real world.
This commit is contained in:
Ayke van Laethem
2019-03-30 13:14:04 +01:00
committed by Ron Evans
parent cd8471acae
commit d653088cbe
4 changed files with 46 additions and 2 deletions
+5
View File
@@ -379,6 +379,11 @@ func (c *Compiler) Compile(mainPath string) error {
c.mod.NamedFunction("runtime.alloc").AddAttributeAtIndex(0, attr)
}
// See emitNilCheck in asserts.go.
attrKind := llvm.AttributeKindID("nocapture")
attr := c.ctx.CreateEnumAttribute(attrKind, 0)
c.mod.NamedFunction("runtime.isnil").AddAttributeAtIndex(1, attr)
// see: https://reviews.llvm.org/D18355
if c.Debug {
c.mod.AddNamedMetadataOperand("llvm.module.flags",