Fix #136 - return static arrays as sret parameters on non-x86.

This should eventually be done on x86 and x86_64 as well, but as
discussed in GitHub issue #110/pull request #120, the ABI there needs a
closer look: at least on x86_64, we need to treat static arrays exactly
like if they were a struct containing T.length members of the same type
to be compatible with DMD (as soon as the ABI is correctly implemented
there, that is).

While for this reason I want to avoid a ABI change which could silently
break some code only to change the x86 ABI again shortly after, this
commit only touches the "default" ABI for unknown targets and thus
should be safe (as we give absoultely no ABI guarantees there anyway).
This commit is contained in:
David Nadlinger
2012-07-07 23:53:46 +02:00
parent 279f64a08d
commit c630ab56ff

View File

@@ -36,7 +36,12 @@ struct UnknownTargetABI : TargetABI
if (tf->isref)
return false;
#endif
return (tf->next->toBasetype()->ty == Tstruct);
// Return structs and static arrays on the stack. The latter is needed
// because otherwise LLVM tries to actually return the array in a number
// of physical registers, which leads, depending on the target, to
// either horrendous codegen or backend crashes.
Type* rt = tf->next->toBasetype();
return (rt->ty == Tstruct || rt->ty == Tsarray);
}
bool passByVal(Type* t)