Unfortunately I don’t think that is really what is going on here.
I became suspicious because I have never seen padding filled with anything but
nops. This behaviour seemed a bit too clever for no real gain.
Looking a bit more closely at the Compiler Explorer it shows assembly before padding has even been generated. You can turn of filtering of assembly directives to see that there is a
.p2align 4, 0x90 right after the
xor, that will later be expanded to padding. Looking at generated bytes
xor eax, eax is also too short. There are 14 bytes required in this position, this
xor only has 2.
xor is really there I don’t know. Locally using rustc 1.19 it does not appear, so this might just be a missing/misbehaving optimization in LLVM which has been fixed by now.