Calling convention and not-variable overhaul: extractvalue/extractelement/insertvalue/insertelement #2796
Labels
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Proposal: pass everything as value (including user's pointers of course), and then fix it up as needed.
See #1481 tracking bug.
Current almost everything goes through the stack, including function calls, and then we rely on out calling convention code and llvm to eliminate the stack allocations. We should be doing this the other way around: we should only use stack allocations if they are necessary, and if the C ABI calls for a stack allocation we should only then convert to a stack allocation. (LLVM really should implement the C ABI for us, and it appears the PowerPC backend does this, but we have to live with it the way it is on ARM and x86 until it is fixed).
The reason it should be the other way around is that we should be using extractvalue/extractelement/insertvalue/insertelement whenever possible. (if the index into an array is not constant this is not possible, and it has to be copied to the stack). We have to do this overhaul anyways in order to be array-type accesses of vectors
my_vector[3]
, and note that while you can take an address of a vector&my_vector
, you cannot take the address of a vector element (&my_vector[3]
is a compile error).Doing this is made tricky because we do not have types resolved until the final second pass of analyze, and it is tricky do instruction switch-a-roo in a single pass.
This is blocking #2698 (see my code here shawnl@a622694 which cannot just return
bool
), it is blocking a PowerPC port (WIP shawnl@40dd53e which includes a first attempt at this bug that didn't work), and it is blocking element access of vector as mentioned above.The text was updated successfully, but these errors were encountered: