Skip to content

[arm64ec] llvm/test/CodeGen/AArch64/arm64ec-varargs.ll fails with -filetype=obj #141541

Open
@MaskRay

Description

@MaskRay

The test would fail with -filetype=obj. llvm/lib/Target/AArch64/AArch64MCInstLower.cpp:80 Printer.OutStreamer->emitAssignment calls setVariableValue, which has an assertion that SymbolContents must be SymContentsUnset/SymContentsVariable.
However, when using MCObjectStreamer, the SymbolContents would be SymContentsOffset.

% myllc -mtriple=arm64ec-pc-windows-msvc -arm64ec-generate-thunks=false < CodeGen/AArch64/arm64ec-varargs.ll -filetype=obj
llc: /home/ray/llvm/llvm/lib/MC/MCSymbol.cpp:52: void llvm::MCSymbol::setVariableValue(const MCExpr *): Assertion `(SymbolContents == SymContentsUnset || SymbolContents == SymContentsVariable) && "Cannot give common/offset symbol a variable value"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /tmp/Debug/bin/llc -mtriple=arm64ec-pc-windows-msvc -arm64ec-generate-thunks=false -filetype=obj
1.      Running pass 'Function Pass Manager' on module '<stdin>'.
2.      Running pass 'AArch64 Assembly Printer' on function '@varargs_caller'
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVMSupport.so.21.0git 0x000077b2cc05303d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 61
^Cfish: Job 1, '/tmp/Debug/bin/llc $argv' terminated by signal SIGABRT (Abort)

Additionally, MCSymbolRefExpr::VK_WEAKREF is probably not a good fit for COFF. The specifier was originally designed for ELF .weakref directive. This specifier was probably chosen to prevent variable expansion, but it had a few issues and I reworked the ELF implementatin in 95756e6.

My notes on `.weakref

.weakref enables the creation of weak aliases without directly modifying the target symbol's binding. This allows a header file in library A to optionally depend on symbols from library B. When the target symbol is otherwise not referenced, the object file affected by the weakref directive will include an undefined weak symbol. However, when the target symbol is defined or referenced (by the user), it can retain STB_GLOBAL binding to support archive member extraction. GCC's [[gnu::weakref]] attribute, as used in runtime library headers like libgcc/gthr-posix.h, utilizes this feature.

I know nearly nothing about arm64ec, but if we want to disable variable expansion (canExpand), using isWeakExternal or another mechanism would likely be more appropriate.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions