mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-09 13:33:39 +00:00
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:
committed by
Ron Evans
parent
980068543a
commit
85854cd58b
+4
-2
@@ -125,11 +125,13 @@ func (c *compilerContext) getRawFuncType(typ *types.Signature) llvm.Type {
|
||||
// The receiver is not an interface, but a i8* type.
|
||||
recv = c.i8ptrType
|
||||
}
|
||||
paramTypes = append(paramTypes, expandFormalParamType(recv)...)
|
||||
recvFragments, _ := expandFormalParamType(recv, nil)
|
||||
paramTypes = append(paramTypes, recvFragments...)
|
||||
}
|
||||
for i := 0; i < typ.Params().Len(); i++ {
|
||||
subType := c.getLLVMType(typ.Params().At(i).Type())
|
||||
paramTypes = append(paramTypes, expandFormalParamType(subType)...)
|
||||
paramTypeFragments, _ := expandFormalParamType(subType, nil)
|
||||
paramTypes = append(paramTypes, paramTypeFragments...)
|
||||
}
|
||||
// All functions take these parameters at the end.
|
||||
paramTypes = append(paramTypes, c.i8ptrType) // context
|
||||
|
||||
Reference in New Issue
Block a user