http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55970
Bug #: 55970
Summary: [x86] Avoid reverse order of function argument
gimplifying
Classification: Unclassified
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: [email protected]
ReportedBy: [email protected]
One important customer met with this problem in a process of porting app from
ARN to IA. The issue can be illustrated by attached example and essential for
x86 platform since only it defines 'PUSH_ARGS_REVERSED' macros. Note also that
attached code is not compliant with C99 standard since it assume definite order
of argument calculation.
gcc -O3 t.c t_main.c
./a.out
Test Failed
gcc -O3 t.c t_main_fix.c
./a.out
Test Passed
diff t_main.c t_main_fix.c
13c13,14
< if (foo (foo1(), foo1()))
---
> int x1 = foo1(), x2 = foo1();
> if (foo (x1, x2))
You can see that gimplifying of function arguments (gimplify.c,
dimplify_call_expr) uses reverse order of arguments:
/* Finally, gimplify the function arguments. */
if (nargs > 0)
{
for (i = (PUSH_ARGS_REVERSED ? nargs - 1 : 0);
PUSH_ARGS_REVERSED ? i >= 0 : i < nargs;
PUSH_ARGS_REVERSED ? i-- : i++)
{
...
I assume that we must no use reverse order in this place, i.e. loop header must
look like
for (i = 0; i < nargs; i++)