Hasty Briefsbeta

Bilingual

Matt Godbolt's blog

15 hours ago
  • The calling convention is part of the ABI, varying by architecture and OS, with the System V ABI for x86 Linux discussed as the most sane.
  • On x86 Linux, the first two parameters (including structures) are passed in registers rdi and rsi, often allowing efficient passing of small structures.
  • For structures with multiple integer types (e.g., int), the compiler may pack them into a single register with extra instructions, while for many arguments (over 6), stack spilling occurs.
  • Changing argument types (e.g., to char) can avoid stack spilling if the entire structure fits in one register, though compilers may use different optimization tricks.
  • Understanding the ABI helps in designing types like std::string_view and std::optional to pass by value efficiently, using registers to avoid stack overhead.