Consistency of function attributes between prototype and definition
Segher Boessenkool
segher@kernel.crashing.org
Mon Oct 5 20:01:00 GMT 2015
On Mon, Oct 05, 2015 at 12:05:44PM +0200, Florian Weimer wrote:
> >>>>> Maybe aligned(1) will do what you want?
> >>>>
> >>>> Interesting idea. Would this alter generated code?
> >>>
> >>> It shouldn't -- it can only increase alignment (not decrease it).
> >>
> >> Why do you think that?
> >
> > Because the documentation says so. Maybe it is wrong though, I didn't
> > test it. If so, please file a bug.
>
> I see a difference on x86_64:
>
> @@ -3,7 +3,6 @@
> .LCOLDB0:
> .text
> .LHOTB0:
> - .p2align 4,,15
> .globl f
> .type f, @function
> f:
>
> I don't think this is a bug because the manual says:
>
> âHowever, when you explicitly specify a function alignment this
> overrides the effect of the '-falign-functions' [â¦] option for this
> function.â
>
> So I think this attribute isn't useful for this purpose. Looks like
> we'd need a new attribute, as Jeff suggested.
And even worse, for targets where minimum alignment is bigger than 1
(most risc targets), the compiler errors if you try to use aligned(1).
:-(
Segher
More information about the Gcc-help
mailing list