Closed
Description
https://godbolt.org/z/36jshbhYh
int main() {
int a = 2;
}
compiled with clang produces such code:
main: // @main
sub sp, sp, #16
mov w8, #2
str w8, [sp, #12]
mov w0, wzr
add sp, sp, #16
ret
I've noticed while parsing binary with debug info (which was compiled with clang), that if we have a variable assignment, mov instruction refers to the previous block, and block with assignment starts only with str instruction on AArch64 (you can see this yellow block from the godbolt link).
The same, if you try to set a breakpoint on the second line in gdb it will jump to the str, skipping mov. GCC produces the correct result, block starts with mov instruction.