Skip to content

[AArch64] UnwindInfo cannot be emitted if inline asm with align or fill are used #47432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
RIscRIpt opened this issue Nov 5, 2020 · 1 comment
Labels
bugzilla Issues migrated from bugzilla mc Machine (object) code

Comments

@RIscRIpt
Copy link
Member

RIscRIpt commented Nov 5, 2020

Bugzilla Link 48088
Version 11.0
OS Windows NT
CC @RIscRIpt

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:

void test() { __asm__(".balign 1");  }

Compiling with:

clang.exe --target=x86_64-pc-windows -c test.cpp

Gives no error, however, compiling with

clang.exe --target=aarch64-pc-windows -c test.cpp

Crashes:

fatal error: error in backend: Failed to evaluate function length in SEH unwind info
Stack dump:

0.      Program arguments: clang.exe --target=aarch64-pc-windows -c test.cpp
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'test.cpp'.
4.      Running pass 'AArch64 Assembly Printer' on function '@"?test@@YAXXZ"'

Related bug report: #40926

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
@duk-37
Copy link
Contributor

duk-37 commented Jul 14, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla mc Machine (object) code
Projects
None yet
Development

No branches or pull requests

2 participants