diff options
author | Fangrui Song <i@maskray.me> | 2024-06-14 10:01:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-14 10:01:36 -0700 |
commit | b1932b8483011c2bfebbea1ef56a565634570e6b (patch) | |
tree | 4163392354f514ae8c97f806f3f72b5c55af63b5 /llvm/lib/MC/MCObjectStreamer.cpp | |
parent | 72b841d016c7403ac1f7678d25b864dac80d06dc (diff) | |
download | llvm-b1932b8483011c2bfebbea1ef56a565634570e6b.zip llvm-b1932b8483011c2bfebbea1ef56a565634570e6b.tar.gz llvm-b1932b8483011c2bfebbea1ef56a565634570e6b.tar.bz2 |
[MC] Aligned bundling: remove special handling for RelaxAll
When both aligned bundling and RelaxAll are enabled, bundle padding is
directly written into fragments (https://reviews.llvm.org/D8072).
(The original motivation was memory usage, which has been achieved from
different angles with recent assembler improvement).
The code presents challenges with the work to replace fragment
representation (e.g. #94950 #95077). This patch removes the special
handling. RelaxAll still works but the behavior seems slightly different
as revealed by 2 changed tests. However, most `-mc-relax-all` tests are
unchanged.
RelaxAll used to be the default for clang -O0. This mode has significant
code size drawbacks and newer Clang doesn't use it (#90013).
---
flushPendingLabels: The FOffset parameter can be removed: pending labels
will be assigned to the incoming fragment at offset 0.
Pull Request: https://github.com/llvm/llvm-project/pull/95188
Diffstat (limited to 'llvm/lib/MC/MCObjectStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCObjectStreamer.cpp | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/llvm/lib/MC/MCObjectStreamer.cpp b/llvm/lib/MC/MCObjectStreamer.cpp index 24bed31..35521dd 100644 --- a/llvm/lib/MC/MCObjectStreamer.cpp +++ b/llvm/lib/MC/MCObjectStreamer.cpp @@ -81,7 +81,7 @@ void MCObjectStreamer::flushPendingLabels(MCFragment *F, uint64_t FOffset) { } // Associate the labels with F. - CurSection->flushPendingLabels(F, FOffset, CurSubsectionIdx); + CurSection->flushPendingLabels(F, CurSubsectionIdx); } void MCObjectStreamer::flushPendingLabels() { @@ -215,7 +215,7 @@ static bool canReuseDataFragment(const MCDataFragment &F, // When bundling is enabled, we don't want to add data to a fragment that // already has instructions (see MCELFStreamer::emitInstToData for details) if (Assembler.isBundlingEnabled()) - return Assembler.getRelaxAll(); + return false; // If the subtarget is changed mid fragment we start a new fragment to record // the new STI. return !STI || F.getSubtargetInfo() == STI; @@ -292,8 +292,7 @@ void MCObjectStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) { // Otherwise queue the label and set its fragment pointer when we emit the // next fragment. auto *F = dyn_cast_or_null<MCDataFragment>(getCurrentFragment()); - if (F && !(getAssembler().isBundlingEnabled() && - getAssembler().getRelaxAll())) { + if (F) { Symbol->setFragment(F); Symbol->setOffset(F->getContents().size()); } else { @@ -465,9 +464,6 @@ void MCObjectStreamer::emitInstructionImpl(const MCInst &Inst, void MCObjectStreamer::emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &STI) { - if (getAssembler().getRelaxAll() && getAssembler().isBundlingEnabled()) - llvm_unreachable("All instructions should have already been relaxed"); - // Always create a new, separate fragment here, because its size can change // during relaxation. MCRelaxableFragment *IF = |