llvm-project
b799b380 - [AsmPrinter] Fix redundant/weaker .prefalign when IR align attr >= prefalign (#191675)

Commit
34 days ago
[AsmPrinter] Fix redundant/weaker .prefalign when IR align attr >= prefalign (#191675) PR #155529 (only fired with -ffunction-sections, then modified by PR 184032) compared `MF->getAlignment()` (the backend's minimum function alignment) against `MF->getPreferredAlignment()` to decide whether to emit `.prefalign`. This ignored the IR function's own align attribute, which `emitAlignment` picks up later via `getGVAlignment`, so the comparison was against the wrong minimum. Consequences on x86 (backend min = 1, target pref = 16): * `[[gnu::aligned(32)]] void g(){}` lowers to `align 32 prefalign(32)`. .p2align 5 .prefalign 5, .Lfunc_end, nop The .prefalign is fully redundant: .p2align 5 already forces the desired 32-byte alignment. * `define void @f4() align 32 prefalign(16)`. .p2align 5 .prefalign 4, .Lfunc_end, nop Here .prefalign with a weak alignment is harmless but the assembly output is nonsensical. This patch updates `emitAlignment` to return the effective alignment it emits and use that as the true minimum in `emitFunctionHeader`.
Author
Parents
Loading