[clang] [llvm] [clang] Support per-function [[clang::code_align(N)]] attribute. (PR #80765)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 9 09:35:23 PST 2024


MaskRay wrote:

> > Aligning the targets of branches is a different thing from what you've implemented. There are basic blocks which are not branch targets, and there are branch targets which are not at the beginning of a basic block. (Branch targets that aren't at the beginning of a basic block are rare on most targets, but it doesn't seem like something we should completely ignore.)
> 
> This makes sense, thanks. Would there be an interest in something like [[clang::x86_align_branch_boundary]] that would align branch instructions in a function?

(I was involved in adding `-mbranches-within-32B-boundaries` and relevant assembler support.) I think the interest is low. A function attribute is for finer granularity so that you can mix some functions with unannotated functions. Users either specify `-mbranches-within-32B-boundaries` to mitigate performance penalty for the whole TU (or globally for LTO) when a microcode update is applied for certain Intel CPUs or not. I am not sure a case where people care for specific functions and want annotating them.

https://github.com/llvm/llvm-project/pull/80765


More information about the cfe-commits mailing list