[all-commits] [llvm/llvm-project] be5a84: [MC] Compute fragment offsets eagerly

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Jul 30 18:38:26 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: be5a845e4c29aadb513ae6e5e2879dccf37efdbb
      https://github.com/llvm/llvm-project/commit/be5a845e4c29aadb513ae6e5e2879dccf37efdbb
  Author: Fangrui Song <i at maskray.me>
  Date:   2024-07-30 (Tue, 30 Jul 2024)

  Changed paths:
    M llvm/include/llvm/MC/MCAsmBackend.h
    M llvm/include/llvm/MC/MCAssembler.h
    M llvm/include/llvm/MC/MCSection.h
    M llvm/lib/MC/MCAssembler.cpp
    M llvm/lib/MC/MCSection.cpp
    M llvm/lib/Target/Hexagon/MCTargetDesc/HexagonAsmBackend.cpp
    M llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
    M llvm/test/MC/ELF/relax-recompute-align.s

  Log Message:
  -----------
  [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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list