Michael Karcher via llvm-dev
2017-Oct-29 22:59 UTC
[llvm-dev] Sparc64 stack realignment broken
While trying to get rust running on Sparc64, I encountered an issue inside llvm. For some reason I did not try to hunt down, rustc decides to do strict (over-)alignment of some stack frames. At a certain point, it is requesting an alignment of 64 bytes. This creates the following sparc assembly code in the output from SparcFrameLowering.cpp: andn %sp,63,%sp This ensures (as intended) that the stack pointer has its low 6 bits cleared and is perfectly aligned on 64 bytes. Alas, this does not take Sparc64's stack pointer bias into account: The real register value is 2047 (0x7ff) lower than the effective stack pointer address. As the stack an Sparc64 is always 8-byte aligned, the stack pointer register modulo 8 has to be 1. A crude fix to this is to not mask the lowest bit of the stack pointer (which will keep it 0 on Sparc32 and 1 on Sparc64), which I have verified to fix a Bus Error in rustc on Sparc64/Linux. Kind regards, Michael Karcher