[all-commits] [llvm/llvm-project] 027447: [MC][test] Add relax-branch-align.s demonstrating ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Tue Mar 3 22:10:12 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 027447c61724385ae82f0a8dea34b45da2fd4c39
      https://github.com/llvm/llvm-project/commit/027447c61724385ae82f0a8dea34b45da2fd4c39
  Author: Fangrui Song <i at maskray.me>
  Date:   2026-03-03 (Tue, 03 Mar 2026)

  Changed paths:
    A llvm/test/MC/ELF/relax-branch-align.s

  Log Message:
  -----------
  [MC][test] Add relax-branch-align.s demonstrating unnecessary branch relaxation (#184551)

The two-pass relaxation approach (relaxFragment, then layoutSection)
can unnecessarily relax a backward branch from short (2B) to near (5B).

When a forward branch relaxes (2B->6B), it shifts the backward target
by +4B. A .p2align between target and source absorbs this growth. The
true displacement is -125 (fits short), but the two-pass approach
evaluates the backward branch with stale target offsets, seeing -129
(beyond [-128,127]) and relaxing it unnecessarily.



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