Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The bug is related to parameter ordering and endianness. (See avr-rust rust-lang#129.)
When a large type can't be legalised, it's broken into smaller types, those are passed as parameters in order based on the endianness of the platform, which is wrong in the case of AVR (at least).
I came up with the rather too radical idea of adding an extra variable to the data layout to reflect this so parameter order is done right. This seems too much because i) as far as I know only AVR is affected by this issue and ii) as far as I know, only one call is known to need this distinction, although we might find more later.
The problem is the legalising is in shared code, without any platform specific hooks that I can work out, but it might be possible to use another one that I don't know about?
To make this fail-safe, the ABI big endian flag defaults to false, just like the main endianness flag, plus by default, if an architecture is marked as big endian in the data layout string ('E'), it will set the ABI endianness flag to big endian too. Then for AVR (and any other platform that needs it), you can add 'K' to the data layout string to specify a big endian ABI.
One other serious problem with this patch is it doesn't work. :) The ABI endian flag is false when the expand node in the legaliser runs. I've tried to debug it and can't figure out why right now. Anyway, it's complete enough for discussion, which is the main thing right now.