diff options
author | Fangrui Song <i@maskray.me> | 2023-06-18 17:49:53 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2023-06-18 17:49:53 -0700 |
commit | e17bc023f4e5b79f08bfc7f624f8ff0f0cf17ce4 (patch) | |
tree | 9096a224223946b0e3415a00d299def31c90bf3f /llvm/lib/MC/MCSection.cpp | |
parent | 507efbcce03d8c2c5dbea3028bc39f02c88fea79 (diff) | |
download | llvm-e17bc023f4e5b79f08bfc7f624f8ff0f0cf17ce4.zip llvm-e17bc023f4e5b79f08bfc7f624f8ff0f0cf17ce4.tar.gz llvm-e17bc023f4e5b79f08bfc7f624f8ff0f0cf17ce4.tar.bz2 |
[MC] flushPendingLabels: set Atom for new fragment after D71368
Fixes: c26c5e47ab9ca60835f191c90fa751e9a7dd0f3d (essentially a no-op)
The newly created MCDataFragment should inherit Atom (see
MCMachOStreamer::finishImpl). To the best of my knowledge, this change cannot be
tested at present, but this is important to ensure
MCExpr.cpp:AttemptToFoldSymbolOffsetDifference gives the same result in case we
evaluate the expression again with a MCAsmLayout.
In the following case,
```
.section __DATA,xray_instr_map
lxray_sleds_start1:
.space 16
Lxray_sleds_end1:
.section __DATA,xray_fn_idx
.quad (Lxray_sleds_end1-lxray_sleds_start1)>>4 // can be folded without a MCAsmLayout
```
When we have a MCAsmLayout, without this change, evaluating
(Lxray_sleds_end1-lxray_sleds_start1)>>4 again will fail due to
`FA->getAtom() == nullptr && FB.getAtom() != nullptr` in
MachObjectWriter::isSymbolRefDifferenceFullyResolvedImpl, called by
AttemptToFoldSymbolOffsetDifference.
Diffstat (limited to 'llvm/lib/MC/MCSection.cpp')
-rw-r--r-- | llvm/lib/MC/MCSection.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCSection.cpp b/llvm/lib/MC/MCSection.cpp index 9b784a6..0fb9e8e 100644 --- a/llvm/lib/MC/MCSection.cpp +++ b/llvm/lib/MC/MCSection.cpp @@ -113,11 +113,13 @@ void MCSection::flushPendingLabels() { PendingLabel& Label = PendingLabels[0]; iterator CurInsertionPoint = this->getSubsectionInsertionPoint(Label.Subsection); + const MCSymbol *Atom = nullptr; + if (CurInsertionPoint != begin()) + Atom = std::prev(CurInsertionPoint)->getAtom(); MCFragment *F = new MCDataFragment(); getFragmentList().insert(CurInsertionPoint, F); F->setParent(this); - if (CurInsertionPoint != begin()) - F->setAtom(std::prev(CurInsertionPoint)->getAtom()); + F->setAtom(Atom); flushPendingLabels(F, 0, Label.Subsection); } } |