When compiling for x86_64, bool, char and short arguments that are passed directly to an argument of exactly the same type on another function with no modification, e.g.: void __bio_release_pages(char mark_dirty); void bio_release_pages(char mark_dirty) { __bio_release_pages(mark_dirty); } get sign/zero-extended unnecessarily. In the case of the above code, it compiles to: 0: 40 0f be ff movsbl %dil,%edi 4: e9 00 00 00 00 jmp 9 <bio_release_pages+0x9> with "gcc -Os -c test.c". Can the extension be optimised away? Granted, the upper bits bits of RDI could contain rubbish on entry to bio_release_pages(), so sanitisation is not unreasonable - but on the other hand, __bio_release_pages() would surely have to assume the same and do the same sanitisation? The toolchain used is the Fedora 37 system compiler: gcc-12.2.1-4.fc37.x86_64 binutils-2.38-25.fc37.x86_64
Confirmed. This is the C frontend doing ;; Function bio_release_pages (null) ;; enabled by -tree-original { __bio_release_pages ((int) mark_dirty); } aka targetm.calls.promote_prototypes