Skip to content

Commit

Permalink
[MC] Don't treat altentry symbols as atoms
Browse files Browse the repository at this point in the history
The current `setAtom` is inaccurate: a `.alt_entry` label can also be
recognized as an atom. This is mostly benign, but might cause two
locations only separated by an `.alt_entry` to have different atoms.

https://reviews.llvm.org/D153167 changed a `evaluateKnownAbsolute` to
`evaluateAsAbsolute` and would not fold `A-B` even if they are only
separated by a `.alt_entry` label, leading to a spurious error
`invalid CFI advance_loc expression`.

The fix is similar to llvm#82268: add a special case for `.alt_entry`.

Fix llvm#97116

Pull Request: llvm#97479
  • Loading branch information
MaskRay authored and kbluck committed Jul 6, 2024
1 parent ae3e3e6 commit 2fe0c78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion llvm/lib/MC/MCMachOStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ void MCMachOStreamer::finishImpl() {
DenseMap<const MCFragment *, const MCSymbol *> DefiningSymbolMap;
for (const MCSymbol &Symbol : getAssembler().symbols()) {
if (getAssembler().isSymbolLinkerVisible(Symbol) && Symbol.isInSection() &&
!Symbol.isVariable()) {
!Symbol.isVariable() && !cast<MCSymbolMachO>(Symbol).isAltEntry()) {
// An atom defining symbol should never be internal to a fragment.
assert(Symbol.getOffset() == 0 &&
"Invalid offset in atom defining symbol!");
Expand Down
5 changes: 5 additions & 0 deletions llvm/test/MC/MachO/cfi-advance-loc-err.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ _foo:
subq $8, %rsp
.cfi_adjust_cfa_offset 8

.alt_entry _bar
_bar: # alt_entry label can appear here as it is not an atom
addq $8, %rsp
.cfi_adjust_cfa_offset -8

tmp0: # non-private label cannot appear here
addq $8, %rsp
# CHECK: :[[#@LINE+1]]:3: error: invalid CFI advance_loc expression
Expand Down

0 comments on commit 2fe0c78

Please sign in to comment.