-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix referencing passed-by-ref structs in win abi
The double-dereference necessary to go from the function argument to the actual location (in the case of a large structure pass) was incorrectly happening in the field codegen. This worked if the structure was only ever referenced as `obj.xyz`, but if `obj` is directly used (for example, but assignment) then the address wasn't correctly calculated.
- Loading branch information
Showing
2 changed files
with
33 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <stdio.h> | ||
static void printint(int x) { | ||
printf("%d\n", x); | ||
} | ||
|
||
struct B { | ||
int b; | ||
int c; | ||
int x; | ||
}; | ||
|
||
struct A { | ||
struct B b; | ||
}; | ||
|
||
void A(struct B b) { | ||
struct A a; | ||
a.b = b; | ||
printint(a.b.b); | ||
printint(a.b.c); | ||
printint(a.b.x); | ||
} | ||
|
||
int main(void) { | ||
struct B b = (struct B){3, 2, 1}; | ||
A(b); | ||
} |