compiler: add dereferenceable_or_null attribute where possible

This gives a hint to the compiler that such parameters are either NULL
or point to a valid object that can be dereferenced. This is not
directly very useful, but is very useful when combined with
https://reviews.llvm.org/D60047 to remove the runtime.isnil hack without
regressing escape analysis.
This commit is contained in:
Ayke van Laethem
2020-03-19 20:15:03 +01:00
committed by Ron Evans
parent 980068543a
commit 85854cd58b
4 changed files with 98 additions and 17 deletions
+1 -1
View File
@@ -437,7 +437,7 @@ func (c *compilerContext) getInterfaceInvokeWrapper(f *ir.Function) llvm.Value {
// Get the expanded receiver type.
receiverType := c.getLLVMType(f.Params[0].Type())
expandedReceiverType := expandFormalParamType(receiverType)
expandedReceiverType, _ := expandFormalParamType(receiverType, nil)
// Does this method even need any wrapping?
if len(expandedReceiverType) == 1 && receiverType.TypeKind() == llvm.PointerTypeKind {