[Bug target/50818] va_list is filled incorrectly in functions with ms_abi attribute on amd64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50818 Steven Shi changed: What|Removed |Added CC||steven.shi at intel dot com --- Comment #5 from Steven Shi --- Hi Bizjak, Your Executable testcase cannot really work with -mabi=ms on the command line. If add a printf() in the while loop to output the sum value as below example, the testcase will fail again with Segmentation fault even building with with -mabi=ms. $ gcc -O2 -mabi=ms pr50818.c $ ./a.out Segmentation fault (core dumped) #include int __attribute__((ms_abi)) foo (int n, ...) { __builtin_va_list ap; int sum = 0; __builtin_va_start (ap, n); while (n--) { sum += __builtin_va_arg (ap, int); printf("sum = %d\n", sum); } __builtin_va_end (ap); return sum; } int main () { int res = foo (10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); if (res != 55) __builtin_abort (); return 0; }
[Bug target/50818] va_list is filled incorrectly in functions with ms_abi attribute on amd64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50818 --- Comment #6 from Steven Shi --- BTW, latest LLVM/Clang 3.8 release has fixed this va_list ms_abi issue, please see below email thread. Does GCC really cannot fix it as LLVM/Clang? This issue really impact Uefi firmware building with GCC. http://lists.llvm.org/pipermail/llvm-dev/2016-January/093778.html
[Bug target/50818] va_list is filled incorrectly in functions with ms_abi attribute on amd64
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50818 --- Comment #9 from Steven Shi --- GCC6.10 lto fails to support below MS ABI buildin of va list, but GCC5 works. This is a regression bug for GCC6. I suspect current GCC trunk also has this regression bug. __builtin_ms_va_list ap; __builtin_ms_va_start (ap, n); __builtin_ms_va_end (ap); Below is my testcase: $cat test2.c #include int __attribute__((ms_abi)) foo (int n, ...) { __builtin_ms_va_list ap; int sum = 0; __builtin_ms_va_start (ap, n); while (n--) { sum += __builtin_va_arg (ap, int); printf("sum = %d\n", sum); } __builtin_ms_va_end (ap); return sum; } int main () { int res = foo (10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); if (res != 55) __builtin_abort (); return 0; } $ gcc --version gcc (GCC) 6.1.0 $ gcc -flto -Os test2.c $ ./a.out Segmentation fault (core dumped) $ gcc-5 -flto -Os test2.c $ ./a.out sum = 1 sum = 3 sum = 6 sum = 10 sum = 15 sum = 21 sum = 28 sum = 36 sum = 45 sum = 55
[Bug c/77341] New: GCC6 va_list MS ABI buildin regression bug
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77341 Bug ID: 77341 Summary: GCC6 va_list MS ABI buildin regression bug Product: gcc Version: 6.1.0 Status: UNCONFIRMED Severity: critical Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: steven.shi at intel dot com Target Milestone: --- GCC6.10 lto fails to support below MS ABI buildin of va list, but GCC5 works. This is a regression bug for GCC6. I suspect current GCC trunk also has this regression bug. __builtin_ms_va_list ap; __builtin_ms_va_start (ap, n); __builtin_ms_va_end (ap); Below is my testcase: $cat test2.c #include int __attribute__((ms_abi)) foo (int n, ...) { __builtin_ms_va_list ap; int sum = 0; __builtin_ms_va_start (ap, n); while (n--) { sum += __builtin_va_arg (ap, int); printf("sum = %d\n", sum); } __builtin_ms_va_end (ap); return sum; } int main () { int res = foo (10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); if (res != 55) __builtin_abort (); return 0; } $ gcc --version gcc (GCC) 6.1.0 $ gcc -flto -Os test2.c $ ./a.out Segmentation fault (core dumped) $ gcc-5 -flto -Os test2.c $ ./a.out sum = 1 sum = 3 sum = 6 sum = 10 sum = 15 sum = 21 sum = 28 sum = 36 sum = 45 sum = 55 BTW, I've raised this issue in below bug comments: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50818
[Bug lto/70955] [6/7 Regression] Wrong code generation for __builtin_ms_va_list with -flto
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70955 --- Comment #16 from Steven Shi --- How to checkout the 6.3 code from GCC trunk? I hope to verify this fix on Uefi firmware GCC LTO build.
[Bug lto/70955] [6/7 Regression] Wrong code generation for __builtin_ms_va_list with -flto
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70955 --- Comment #19 from Steven Shi --- (In reply to vries from comment #18) > Created attachment 39484 [details] > Tentative patch using attributes ms_abi/sysv_abi > > not build or regression tested yet, but at least makes test-case pass. Vries, I tried apply your patch on latest gcc trunk, build and install the new gcc7, it still cannot work. Below is my test case. $ gcc --version gcc (GCC) 7.0.0 20160823 (experimental) $ cat test2.c #include int __attribute__((ms_abi)) foo (int n, ...) { __builtin_ms_va_list ap; int sum = 0; __builtin_ms_va_start (ap, n); while (n--) { sum += __builtin_va_arg (ap, int); printf("sum = %d\n", sum); } __builtin_ms_va_end (ap); return sum; } int main () { int res = foo (10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); if (res != 55) __builtin_abort (); return 0; } $ gcc -flto -Os test2.c $ ./a.out Segmentation fault (core dumped) But GCC5 works. $ gcc-5 -flto -Os test2.c $ ./a.out sum = 1 sum = 3 sum = 6 sum = 10 sum = 15 sum = 21 sum = 28 sum = 36 sum = 45 sum = 55
[Bug lto/70955] [6/7 Regression] Wrong code generation for __builtin_ms_va_list with -flto
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70955 --- Comment #21 from Steven Shi --- Vries, Sorry, my bad. I didn't apply your patch completely. Yes, your patch works. And with your patch, my UEFU firmware gcc lto build pass and boot successfully. Hope we could check in a formal fix ASAP, because the lto build is Uefi firmware GCC default build now. This regression bug block us to adopt new version GCC on Uefi firmware. Thanks!