Open RIscRIpt opened 3 years ago
LLVM may generate alignment directives without using inline assembly at all when loops are involved due to either an explicit command line option or cpu-specific defaults.
The following will, at the time of writing, crash on trunk with the same error as above:
// clang test.c --target=aarch64-pc-windows-gnu -falign-loops=2 -O1
// clang test.c --target=aarch64-pc-windows-gnu -mtune=cortex-a72 -O2
void opaque();
void test(int x) {
for (int i = 0; i < x; ++i) opaque();
}
Workaround is to explicitly remove loop alignment hints through the command line via -falign-loops=1
or -mllvm -align-loops=1
.
Extended Description
For more info see FIXME in ARM64EmitUnwindInfo (llvm/lib/MC/MCWin64EH.cpp) https://github.com/llvm/llvm-project/blob/f69e090/llvm/lib/MC/MCWin64EH.cpp#L918-L943
Reproducible example:
Compiling with:
Gives no error, however, compiling with
Crashes:
fatal error: error in backend: Failed to evaluate function length in SEH unwind info Stack dump:
Related bug report: llvm/llvm-project#40926