-
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 win abi bug causing stack dealignment for when passing struct by …
…value
- Loading branch information
Showing
3 changed files
with
74 additions
and
1 deletion.
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,19 @@ | ||
#include "test.h" | ||
|
||
struct B { | ||
int x; | ||
int y; | ||
int z; | ||
}; | ||
|
||
void f(struct B b) { | ||
ASSERT(10, b.x); | ||
ASSERT(20, b.y); | ||
ASSERT(30, b.z); | ||
} | ||
|
||
int main(void) { | ||
struct B b = {10, 20, 30}; | ||
f(b); | ||
return 0; | ||
} |
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,52 @@ | ||
from test_helpers_for_update import * | ||
|
||
HOST = '''\ | ||
#include <stdio.h> | ||
struct B { | ||
int x; | ||
int y; | ||
int z; | ||
}; | ||
void test_f(struct B b) { | ||
printf("%d %d %d\\n", b.x, b.y, b.z); | ||
} | ||
''' | ||
|
||
SRC = '''\ | ||
#include <stdio.h> | ||
struct B { | ||
int x; | ||
int y; | ||
int z; | ||
}; | ||
extern void test_f(struct B b); | ||
// This was causing stack un-alignment due to how struct copying was | ||
// implemented in codegen. | ||
int main(void) { | ||
struct B b = {10, 20, 30}; | ||
test_f(b); | ||
printf("OK\\n"); | ||
return 0; | ||
} | ||
''' | ||
|
||
# This is not really an "update" test, but because the update tests happen to | ||
# build a separate host binary rather than using the standard dyibicc.exe, it | ||
# gives us a way to have C code to call that's test-specific and compiled by | ||
# the host compiler, rather than by ours. | ||
|
||
add_to_host(HOST); | ||
add_host_helper_func("test_f") | ||
include_path("../../test") | ||
|
||
initial({'main.c': SRC}) | ||
update_ok() | ||
expect(0) | ||
|
||
done() | ||
|