Repository navigation
Copy an object passed by value a word at a time on i386 - #3710
Merged
Merged
Conversation
A call that passes a large structure by value on i386 copied it with memcpy into the outgoing area. The copy's own three arguments go on the stack there too, at the bottom of the area the call is being written into, so they overwrote the arguments already stored. 00204 of c-testsuite passed two large structures and printed garbage for the first. A convention with fewer than three argument registers now copies a word at a time however large the object is, which is what GCC does too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
On i386 a call that passed a large structure by value copied it into the outgoing area with memcpy. The copy's own three arguments go on the stack too, at the bottom of the area the call is being written into, so they overwrote the arguments already stored there. 00204 of c-testsuite passes two large structures and printed garbage for the first, which is why both i686 rung 0 jobs fail on main.
A convention with fewer than three argument registers, which is every i386 one, now copies a word at a time however large the object is. GCC makes no library call while it sets up a call's arguments either. This also takes away the nested memcpy call that ld.lld refused to link as "cannot be preempted" when the callee was a local function.
On the Linux box 00204 now matches the expected output at -O0 and -O2, with and without PIE, rung 0 passes 440 of 440 on both i686-linux-gnu and x86_64-linux-gnu, and the rucc-codegen tests and clippy pass. A new test checks that a 4096 byte object passed on i386 is copied with no call to memcpy.