diff options
author | Fangrui Song <i@maskray.me> | 2024-07-30 18:38:03 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2024-07-30 18:38:03 -0700 |
commit | be5a845e4c29aadb513ae6e5e2879dccf37efdbb (patch) | |
tree | a659acb325979bf401148e97e606b2f87fbff24a /llvm/lib/MC/MCSection.cpp | |
parent | c35c4c72e4977258fc1da940e0470e8d0671bf07 (diff) | |
download | llvm-be5a845e4c29aadb513ae6e5e2879dccf37efdbb.zip llvm-be5a845e4c29aadb513ae6e5e2879dccf37efdbb.tar.gz llvm-be5a845e4c29aadb513ae6e5e2879dccf37efdbb.tar.bz2 |
[MC] Compute fragment offsets eagerly
This builds on top of commit 9d0754ada5dbbc0c009bcc2f7824488419cc5530
("[MC] Relax fragments eagerly") and relaxes fragments eagerly to
eliminate MCSection::HasLayout and `getFragmentOffset` overhead. The
approach is slightly different from
1a47f3f3db66589c11f8ddacfeaecc03fb80c510 and has less performance
benefit.
The new layout algorithm also addresses the following problems:
* Size change of MCFillFragment/MCOrgFragment did not influence the
fixed-point iteration, which could be problematic for contrived cases.
* The `invalid number of bytes` error was reported too early. Since
`.zero A-B` might have temporary negative values in the first few
iterations.
* X86AsmBackend::finishLayout performed only one iteration, which might
not converge. In addition, the removed `#ifndef NDEBUG` code (disabled
by default) in X86AsmBackend::finishLayout was problematic, as !NDEBUG
and NDEBUG builds evaluated fragment offsets at different times before
this patch.
* The computed layout for relax-recompute-align.s is optimal now.
Builds with many text sections (e.g. full LTO) shall observe a decrease
in compile time while the new algorithm could be slightly slower for
some -O0 -g projects.
Aligned bundling from the deprecated PNaCl placed constraints how we can
perform iteration.
Diffstat (limited to 'llvm/lib/MC/MCSection.cpp')
-rw-r--r-- | llvm/lib/MC/MCSection.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCSection.cpp b/llvm/lib/MC/MCSection.cpp index 8c2ee56..97e87a4 100644 --- a/llvm/lib/MC/MCSection.cpp +++ b/llvm/lib/MC/MCSection.cpp @@ -23,8 +23,8 @@ using namespace llvm; MCSection::MCSection(SectionVariant V, StringRef Name, bool IsText, bool IsVirtual, MCSymbol *Begin) : Begin(Begin), BundleGroupBeforeFirstInst(false), HasInstructions(false), - HasLayout(false), IsRegistered(false), IsText(IsText), - IsVirtual(IsVirtual), Name(Name), Variant(V) { + IsRegistered(false), IsText(IsText), IsVirtual(IsVirtual), Name(Name), + Variant(V) { DummyFragment.setParent(this); // The initial subsection number is 0. Create a fragment list. CurFragList = &Subsections.emplace_back(0u, FragList{}).second; |