pogo59 wrote:

I guess I'm a little confused still. Are you claiming that `cold` has a 
specified ABI effect? That if some pass decides a function is cold, that 
decision (correctly) affects its ABI? I'm not seeing any documentation to that 
effect, either on the clang attribute or the IR attribute. My admittedly aging 
copy of the psABI doesn't mention function alignment at all, either.

We're not inventing an ABI rule that `cold` functions are special and must have 
a specific alignment; we just want `cold` functions to have the same alignment 
as non-`cold` functions. (And if you specify `-Os` then that alignment changes 
to 1, for cold and non-cold functions alike.)

The only thing that makes `cold` functions special _in this implementation_ is 
that, as an implementation convenience, clang's `cold` attribute also sets 
`optsize` which has an effect that we are finding inconvenient. We just want 
`cold` not to have that particular effect. We played around with several 
different ways to make that happen, and this seemed the least intrusive.

I suppose another way to go at this would be for `-Os` or clang's `minsize` to 
add both `optsize` and align(1) to functions, and have LLVM's implementation of 
`optsize` stop implying align(1). This would make everything more orthogonal 
and disentangled, yes? And then clang's `cold` could set `optsize` without 
affecting alignment; if non-PS targets still wanted `cold` to mean align(1), we 
can set that as well. No new attributes, and that bit of code down in LLVM to 
compute alignment gets a wee bit cleaner. WDYT?

https://github.com/llvm/llvm-project/pull/72387
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to