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
+8
View File
@@ -27,6 +27,14 @@ func _recover() interface{} {
return nil
}
// See emitNilCheck in compiler/asserts.go.
// This function is a dummy function that has its first and only parameter
// marked 'nocapture' to work around a limitation in LLVM: a regular pointer
// comparison captures the pointer.
func isnil(ptr *uint8) bool {
return ptr == nil
}
// Panic when trying to dereference a nil pointer.
func nilpanic() {
runtimePanic("nil pointer dereference")