[llvm] 2afa193 - [MC] Remove MCAsmLayout::invalidateFragmentsFrom
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 29 23:32:55 PDT 2024
Author: Fangrui Song
Date: 2024-06-29T23:32:51-07:00
New Revision: 2afa193b3b4250aa90ae827a4832370ad9c127f6
URL: https://github.com/llvm/llvm-project/commit/2afa193b3b4250aa90ae827a4832370ad9c127f6
DIFF: https://github.com/llvm/llvm-project/commit/2afa193b3b4250aa90ae827a4832370ad9c127f6.diff
LOG: [MC] Remove MCAsmLayout::invalidateFragmentsFrom
The simplification is enabled by
9d0754ada5dbbc0c009bcc2f7824488419cc5530 ("[MC] Relax fragments eagerly").
Added:
Modified:
llvm/include/llvm/MC/MCAsmLayout.h
llvm/lib/MC/MCFragment.cpp
llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCAsmLayout.h b/llvm/include/llvm/MC/MCAsmLayout.h
index e3f707fd21a18..7f54a996df649 100644
--- a/llvm/include/llvm/MC/MCAsmLayout.h
+++ b/llvm/include/llvm/MC/MCAsmLayout.h
@@ -40,11 +40,6 @@ class MCAsmLayout {
/// Get the assembler object this is a layout for.
MCAssembler &getAssembler() const { return Assembler; }
- /// Invalidate the fragments starting with F because it has been
- /// resized. The fragment's size should have already been updated, but
- /// its bundle padding will be recomputed.
- void invalidateFragmentsFrom(MCFragment *F);
-
void layoutBundle(MCFragment *Prev, MCFragment *F);
/// \name Section Access (in layout order)
diff --git a/llvm/lib/MC/MCFragment.cpp b/llvm/lib/MC/MCFragment.cpp
index 9e9a03af945dc..d2b8b1d917fe1 100644
--- a/llvm/lib/MC/MCFragment.cpp
+++ b/llvm/lib/MC/MCFragment.cpp
@@ -40,10 +40,6 @@ MCAsmLayout::MCAsmLayout(MCAssembler &Asm) : Assembler(Asm) {
SectionOrder.push_back(&Sec);
}
-void MCAsmLayout::invalidateFragmentsFrom(MCFragment *F) {
- F->getParent()->setHasLayout(false);
-}
-
// Simple getSymbolOffset helper for the non-variable case.
static bool getLabelOffset(const MCAsmLayout &Layout, const MCSymbol &S,
bool ReportError, uint64_t &Val) {
diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
index 54efe4bc25efe..6f8853733ae9d 100644
--- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
+++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
@@ -756,7 +756,7 @@ class HexagonAsmBackend : public MCAsmBackend {
//assert(!Error);
(void)Error;
ReplaceInstruction(Asm.getEmitter(), RF, Inst);
- Layout.invalidateFragmentsFrom(&RF);
+ I->setHasLayout(false);
Size = 0; // Only look back one instruction
break;
}
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
index 372de5c18ac2b..bf30cee1d5cda 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -925,7 +925,6 @@ void X86AsmBackend::finishLayout(MCAssembler const &Asm,
// the align directive. This is purely about human understandability
// of the resulting code. If we later find a reason to expand
// particular instructions over others, we can adjust.
- MCFragment *FirstChangedFragment = nullptr;
unsigned RemainingSize = OrigSize;
while (!Relaxable.empty() && RemainingSize != 0) {
auto &RF = *Relaxable.pop_back_val();
@@ -933,7 +932,7 @@ void X86AsmBackend::finishLayout(MCAssembler const &Asm,
// the encoding size of the given instruction. Target independent code
// will try further relaxation, but target's may play further tricks.
if (padInstructionEncoding(RF, Asm.getEmitter(), RemainingSize))
- FirstChangedFragment = &RF;
+ Sec.setHasLayout(false);
// If we have an instruction which hasn't been fully relaxed, we can't
// skip past it and insert bytes before it. Changing its starting
@@ -946,13 +945,6 @@ void X86AsmBackend::finishLayout(MCAssembler const &Asm,
}
Relaxable.clear();
- if (FirstChangedFragment) {
- // Make sure the offsets for any fragments in the effected range get
- // updated. Note that this (conservatively) invalidates the offsets of
- // those following, but this is not required.
- Layout.invalidateFragmentsFrom(FirstChangedFragment);
- }
-
// BoundaryAlign explicitly tracks it's size (unlike align)
if (F.getKind() == MCFragment::FT_BoundaryAlign)
cast<MCBoundaryAlignFragment>(F).setSize(RemainingSize);
More information about the llvm-commits
mailing list