[all-commits] [llvm/llvm-project] 627904: [MC] Fix .prefalign oscillation when body contains...

Fangrui Song via All-commits all-commits at lists.llvm.org
Thu Apr 16 00:05:44 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6279043b5b2613282d68818485b10e4038a511a7
      https://github.com/llvm/llvm-project/commit/6279043b5b2613282d68818485b10e4038a511a7
  Author: Fangrui Song <i at maskray.me>
  Date:   2026-04-16 (Thu, 16 Apr 2026)

  Changed paths:
    M llvm/lib/MC/MCAssembler.cpp
    A llvm/test/MC/ELF/prefalign-internal-align.s

  Log Message:
  -----------
  [MC] Fix .prefalign oscillation when body contains a .p2align (#192402)

The intervening FT_Align's padding depends on where this prefalign
lands, so body_size can oscillate across relaxOnce iterations.  When a
downstream section reacts (e.g. .debug_line DWARF deltas crossing a
special-opcode boundary), the outer loop never terminates -- originally
reported as a hang with -O1 -g on
https://github.com/llvm/llvm-project/pull/184032#issuecomment-4235991852

```
static int a;
void b() {}
int c() { for (;;) { int d; for (; a;) return 0; } }
void e() { for (;;) ; }
```

X86 sets both the preferred function alignment
and the loop-header alignment to 16 (X86ISelLowering
setPrefLoopAlignment),
so any function containing a small loop whose first BB gets .p2align 4
lands a same-alignment .p2align inside the prefalign body.

Fix: never decrease ComputedAlign across iterations.



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