GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

gccrs: Evaluate call arguments from left to right

gccrs now evaluates function call arguments from left to right, matching Rust's evaluation order.

gccrs has corrected the evaluation order of function call arguments to match Rust’s specification. The compiler’s gimplifier previously evaluated arguments in the order they were pushed onto the stack (right-to-left on x86), affecting method calls and overloaded operators. The fix ensures that arguments, including the callee, are saved and evaluated strictly from left to right, addressing issues with side effects in argument evaluation. This change resolves Rust-GCC/gccrs#4956.

In Details

The gccrs compiler's call_expression handling has been modified to enforce Rust's left-to-right argument evaluation order. The gimplifier's default behavior, influenced by the target's calling convention (e.g., right-to-left argument pushing on x86), did not align with Rust's requirements. This commit introduces save_call_operands to correctly manage the evaluation and saving of the callee and all arguments in the specified order, particularly when arguments have side effects. This ensures consistent behavior for method calls and overloaded operators, resolving a known issue.

For Context
gimplifier
A component within GCC that converts the compiler's intermediate representation (GENERIC) into GIMPLE, a lower-level, three-address code representation used for optimization.
x86
A family of instruction set architectures developed by Intel, widely used in desktop and server computers. Calling conventions on x86 often involve pushing arguments onto the stack in reverse order.
calling convention
A set of rules that govern how function parameters are passed and how return values are handled between calling and called functions. This includes the order of arguments, register usage, and stack management.
side effect
In programming, an action that modifies the program's state beyond returning a value, such as assigning a value to a variable or performing I/O.
Filed Under: gccrsrustcompilercalling convention