Assuming the x86-64 ABI on Linux, under what conditions in C++ are structs passed to functions in registers vs. on the stack? Under what conditions are they returned in regi
The x86-64 ABI is documented here with version 252 (the latest ABI as of my answer) downloadable here.
If I have read page 21 et seq correctly, it says that if sizeof(struct) is 8 bytes or less, then it will be passed in a normal register. The rules get complicated after that, but I think if it 9-16 bytes, it may get passed in SSE registers.
As to classes, remember the only difference between a class and a struct is default access. However the rules do clearly say that if there is a non-trivial copy constructor or non-trivial destructor, the struct will be passed as a hidden reference.