mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-11 06:23:39 +00:00
compiler: simplify code around getZeroValue
The LLVM library we use does not (yet) provide a llvm.Zero (like it provides a llvm.Undef) so we have implemented our own. However, in theory it might return an error in some cases. No real-world errors have been seen in a while and errors would likely indicate a serious compiler bug anyway (not an external error), so make it panic instead of returning an error.
This commit is contained in:
committed by
Ron Evans
parent
024eceb476
commit
6d23809218
+1
-4
@@ -123,10 +123,7 @@ func (c *Compiler) collapseFormalParamInternal(t llvm.Type, fields []llvm.Value)
|
||||
switch t.TypeKind() {
|
||||
case llvm.StructTypeKind:
|
||||
if len(c.flattenAggregateType(t)) <= MaxFieldsPerParam {
|
||||
value, err := c.getZeroValue(t)
|
||||
if err != nil {
|
||||
panic("could not get zero value of struct: " + err.Error())
|
||||
}
|
||||
value := c.getZeroValue(t)
|
||||
for i, subtyp := range t.StructElementTypes() {
|
||||
structField, remaining := c.collapseFormalParamInternal(subtyp, fields)
|
||||
fields = remaining
|
||||
|
||||
Reference in New Issue
Block a user