[all-commits] [llvm/llvm-project] e01562: MC: Allow .set to reassign non-MCConstantExpr expr...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Mon May 26 21:58:41 PDT 2025
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e015626f189dc76f8df9fdc25a47638c6a2f3feb
https://github.com/llvm/llvm-project/commit/e015626f189dc76f8df9fdc25a47638c6a2f3feb
Author: Fangrui Song <i at maskray.me>
Date: 2025-05-26 (Mon, 26 May 2025)
Changed paths:
M llvm/include/llvm/MC/MCContext.h
M llvm/include/llvm/MC/MCSymbol.h
M llvm/lib/MC/ELFObjectWriter.cpp
M llvm/lib/MC/MCContext.cpp
M llvm/lib/MC/MCExpr.cpp
M llvm/lib/MC/MCParser/AsmParser.cpp
M llvm/lib/MC/MCParser/MasmParser.cpp
M llvm/lib/MC/MCSymbol.cpp
M llvm/test/MC/ARM/thumb_set-diagnostics.s
M llvm/test/MC/AsmParser/redef.s
Log Message:
-----------
MC: Allow .set to reassign non-MCConstantExpr expressions
GNU Assembler supports symbol reassignment via .set, .equ, or =.
However, LLVM's integrated assembler only allows reassignment for
MCConstantExpr cases, as it struggles with scenarios like:
```
.data
.set x, 0
.long x // reference the first instance
x = .-.data
.long x // reference the second instance
.set x,.-.data
.long x // reference the third instance
```
Between two assignments binds, we cannot ensure that a reference binds
to the earlier assignment. We use MCSymbol::IsUsed and other conditions
to reject potentially unsafe reassignments, but certain MCConstantExpr
uses could be unsafe as well.
This patch enables reassignment by cloning the symbol upon reassignment
and updating the symbol table. Existing references to the original
symbol remain unchanged, and the original symbol is excluded from the
emitted symbol table.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list