diff options
author | Ayke van Laethem <[email protected]> | 2020-03-19 20:15:03 +0100 |
---|---|---|
committer | Ron Evans <[email protected]> | 2020-03-27 07:38:16 +0100 |
commit | 85854cd58b09ee026cecaa590a23013d43ba74e5 (patch) | |
tree | c44dc593348007d0e0af899f38086efd08a3ff93 /compiler/func.go | |
parent | 980068543a1f9d720d7bb523b00c9818d383e916 (diff) | |
download | tinygo-85854cd58b09ee026cecaa590a23013d43ba74e5.tar.gz tinygo-85854cd58b09ee026cecaa590a23013d43ba74e5.zip |
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.
Diffstat (limited to 'compiler/func.go')
-rw-r--r-- | compiler/func.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/func.go b/compiler/func.go index 544f3e5fa..2d14d47a2 100644 --- a/compiler/func.go +++ b/compiler/func.go @@ -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 |