> On Oct 29, 2018, at 4:08 PM, Martin Sebor <mse...@gmail.com> wrote:
>
> On 10/29/2018 09:19 AM, Paul Koning wrote:
>>
>>
>>> On Oct 29, 2018, at 10:54 AM, Martin Sebor <mse...@gmail.com> wrote:
>>>
>>> On 10/29/2018 07:45 AM, Paul Koning wrote:
>>>> I noticed an inconsistency in the handling of the aligned attribute. When
>>>> applied to variables, I get an error message if the alignment is too large
>>>> for the platform. But when applied to functions, there is no error check.
>>>> The same applies to label alignment (from the -falign-labels switch).
>>>>
>>>> The result is an ICE in my target code because it is asked to output
>>>> assembly language for an alignment not supported by the target.
>>>>
>>>> Should these cases also produce error messages? Or should the back end
>>>> ignore attempts to align too much?
>>>
>>> check_user_alignment() in c-attribs.c rejects excessive alignments
>>> the same for functions and variables:
>>>
>>> else if (i >= HOST_BITS_PER_INT - LOG2_BITS_PER_UNIT)
>>> {
>>> error ("requested alignment is too large");
>>> return -1;
>>> }
>>>
>>> so I don't immediately see where this inconsistency comes from
>>> Is there different/more restrictive handling for variables in
>>> the back end? (a test case would be great).
>>
>> I forgot to attach it. Here it is.
>
> I don't see any errors with the test case on x86_64. In GDB I see
> the alignment for ag is 524288 and MAX_OFILE_ALIGNMENT is 2147483648.
> What target do you see the error with?
>
> Martin
There are two related issues.
One is that GCC says the max alignment for variables on x86 is 32768
(MAX_OFILE_ALIGNMENT is 32768). And it enforces that, for variables. But a
request to align a function to 65536 is permitted. Since the assembler doesn't
actually complain, no errors appear.
On pdp11, MAX_OFILE_ALIGNMENT is 2. So in the test file I sent, the aligned(2)
entries are legal and the others are not. Since the target doesn't know how to
generate assembly code for alignment greater than 2, the overly aligned
function results in an ICE. But the overly aligned variables generate error
messages, as expected.
What I want is for function and label alignment to honor MAX_OFILE_ALIGNMENT.
The only alternative is to silently ignore excessive function alignment in the
target code.
paul