checkasm: Improve 32-bit parameter clobbering on x86-64
The previous method of doing parameter clobbering was hacky and unreliable, but this approach works much better. The same could probably be done for AArch64 as well.
Also fix one bug that was detected because of this improvement.
This relies on _Generic()
, which is part of C11. AFAIK pretty much all reasonably modern compilers support this, however MSVC doesn't enable it unless compiled with /std:c11
. We already use some C11 features (stdatomic.h
and anonymous structs/unions), so maybe we should just embrace C11?
Merge request reports
Activity
changed milestone to %1.1.0
requested review from @mstorsjo
- Automatically resolved by Henrik Gramner
- Resolved by Henrik Gramner
- Resolved by Martin Storsjö
FWIW I think the form used here, to just check if we happen to have
_Generic
available even if we're in C99 mode and conditionally use it then, is fine - it doesn't disrupt builds in other configurations, etc, and should be plenty, as long as most compilers used in the CI actually do end up enabling it.
- Resolved by Martin Storsjö
The same could probably be done for AArch64 as well.
Yeah, I guess so. On the other hand, I haven't ever seen an aarch64 compiler call functions by locally pushing registers on the stack, as opposed to just write them into a preallocated stack area, so there's not much rush either (other than to keep things consistent - and reduce the risk of later surprises of course).
I guess one upside of the previous approach, is that it also takes care of clobbering more than 32 bit for smaller arguments, if the ABI allows more bits of a parameter register to be undefined.