public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-22  0:11 Robert Dewar
  2003-04-22  1:35 ` Jamie Lokier
  0 siblings, 1 reply; 101+ messages in thread
From: Robert Dewar @ 2003-04-22  0:11 UTC (permalink / raw)
  To: aoliva, dewar; +Cc: gcc-patches, gcc, kenner, rth

> So if you turn:
> 
> T i __attribute__((align(2)));
> T j __attribute__((align(2)));
> 
> into
> 
> typedef T T2 __attribute__((align(2)));
> T2 i, j;
> 
> you say we could get different code?  It sounds to me like they
> *should* be equivalent.  The compiler can't tell whether the user
> meant the alignment of a type is meant for composites only or for
> factoring of attributes in object declarations.

Yes, at least that's the intention in Ada. Setting an alignment for a type
specifies a minimum alignment for objects.

Consider the following

   type A is ....
   for A'Alignment use 4;

   B : A:

   Put_Line (Integer'Image (B'Alignment));

Ada semantics say that the value printed must be 4 or a multiple of 4.


  type A is ...

  B : A;
  for B'Alignment use 4;

  Put_Line (Integer'Image (B'Alignment));

This must output 4. Of course the compiler could still silently put
B on a bigger alignment, since there would be no way to tell that it
was doing this systematically, but this would be a poor implementation.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-23  3:29 Robert Dewar
  0 siblings, 0 replies; 101+ messages in thread
From: Robert Dewar @ 2003-04-23  3:29 UTC (permalink / raw)
  To: aoliva, kenner; +Cc: gcc-patches, gcc

> So the question is when to supress the an optional increase for
> objects and I claim the only time should be if there is an alignment
> specified *for a particular object*.

seems reasonable to me ...

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-23  2:20 Richard Kenner
  2003-04-23  5:31 ` Alexandre Oliva
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-23  2:20 UTC (permalink / raw)
  To: aoliva; +Cc: gcc-patches, gcc

    The point is that you're saying it could increase the alignment of an
    object in spite of a user-specified alignment for its type.  You can't
    tell whether the alignment was defined for interface, space or
    performance, so a user-specified alignment for a type should be
    obeyed.

As has been discussed, "obeyed" means very different things for types
and objects.  For types, you must not treat the type as being more
aligned.  For objects, a more-aligned object is *also* less aligned, so
aligning an object more than that of its type is "obeying" the alignment
of the type.  And we know there are cases (such as minimum alignment on
S390) where you *must* increase the alignment of an object from that of
its type.

So the question is when to supress the an optional increase for
objects and I claim the only time should be if there is an alignment
specified *for a particular object*.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-22 15:08 Richard Kenner
  2003-04-23  1:07 ` Alexandre Oliva
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-22 15:08 UTC (permalink / raw)
  To: aoliva; +Cc: gcc-patches, gcc

    But the compiler can't tell whether, when you specify alignment for a
    type, you mean for interface or for efficiency, so I think it
    shouldn't make an assumption that it's to be used only for the former
    case like you seem to believe it should do.

No, I don't believe that, but it's not relevant.  Because it *might*
have been meant for interface, the compiler is not allowed to change
the alignment of types.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-22  0:15 Robert Dewar
  2003-04-22  1:58 ` Jamie Lokier
  0 siblings, 1 reply; 101+ messages in thread
From: Robert Dewar @ 2003-04-22  0:15 UTC (permalink / raw)
  To: aoliva, kenner; +Cc: gcc-patches, gcc

> And the reason is as I said: you specify alignment for a type both for
> interface and efficiency reasons, but for an object only for the latter.

Not quite. consider

   type R is array (Natural range <>) of Character;
   for R'Alignment use 1;

   X : R (1 .. 100);
   pragma Import (C, X);

now for the above, the generated code can only assume an alignment of 1.

But we might want to do

  Y : R (1 .. 1000);
  for Y'Alignment use 8;
  pragma Export (C, Y);

in a case where the C code expects an alignment for the object of 8 for
correct operation.

So even for objects, specifying an alignment different from that for the
type may be appropriately needed for functional correctness.



^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-21 21:25 Richard Kenner
  0 siblings, 0 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-21 21:25 UTC (permalink / raw)
  To: jamie; +Cc: gcc-patches, gcc

    Oh.  I like yours more!  Much simpler, otherwise you still need code
    in the compiler to dereference at small alignments, which there
    doesn't seem to be at present.

Sure it is.  emit_block_move would handle the case just fine for aggregate
types.  Of course this is more problematic for scalars, but if you do it
indirectly via a BLKmode object, it'll work, though that's probably more
trouble than it's worth.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-21 20:59 Richard Kenner
  2003-04-21 21:14 ` Jamie Lokier
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-21 20:59 UTC (permalink / raw)
  To: jamie; +Cc: gcc-patches, gcc

    Are you saying that it should be an error to take the address of such
    an object?

What I was thinking was more that it should be an error to create an object
whose alignment is less than that of its type, but you correctly point out
that an alternate solution is to allow that but, like a bitfield, to forbid
taking its address.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-21 20:45 Richard Kenner
  2003-04-21 20:58 ` Jamie Lokier
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-21 20:45 UTC (permalink / raw)
  To: jamie; +Cc: gcc-patches, gcc

I really think you are making this unnecessarily complex here because
I can't follow most of what you are writing.

    > Now consider a function that takes an object of type T that is *not* part
    > of the current compilation.  When generating code to dereference P, it is
    > not allowed to assume that the alignment of the object pointed to by P
    > is *more* than four bytes.

    This I understood already.  I think everyone sees this.

Actually not, because that's the key point in below:

    <lightbulb>
      Oh, I see why you mustn't increase alignment on types!  Thanks!
    </lightbulb>

If the above were obvious, so would this have been.

    > So doing so would be conforming to the standard.

    Somebody brought up an example where that might not be reasonable:
    multiple object in a special linker section, and the programmer
    expects them to be laid out as if in an array.  

Yes, but it's important to distinguish between what's "conforming" and
what's "reasonable".  As Robert Dewar points out, it's comforming to
implement multiplication as a loop over addition, but not reasonable.
But you can't try to determine what's "reasonable" by consulting a
standards document.

    Ok, now I agree it is practical to want to reduce an object's
    alignment for storage purposes.  (But isn't that why we have
    __attribute__((packed))?)

Yes.

    The essential quirk is this: whenever you take the address of an
    object, if you have specified the object's alignment and it is less
    than that of the original type, 

That should be an error.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-21 18:14 Richard Kenner
  2003-04-21 20:33 ` Jamie Lokier
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-21 18:14 UTC (permalink / raw)
  To: jamie; +Cc: gcc-patches, gcc

    So, starting from the second (typedef) sample, if I write:

	__typeof__(i) * ptr = &i;
	use (*ptr);

    That should be equivalent to:

	T2 * ptr = &i;
	use (*ptr);

    The code for `use' may assume that the pointer has at least an
    alignment of 2, i.e. the least significant bit of the pointer is zero?

In this case, "use" should know what is being pointed to, so I don't
understand your example at all.

    Robert Dewar, on behalf of Ada, seems to think that the object
    alignment specification implies a _maximum_ alignment as well as a
    minimum.  For fields in structures this is relevant.  But for data
    variables?

This isn't an Ada issue, but a generic one, and I also raised the point.
The issue is one of interfacing.

Consider a type P that is a pointer to type T where I say that type
T has 4-byte alignment.  Now consider a function which is passed an
object of type T.  If that function is not part of the current compilation,
the specifcation of an alignment for T means that the compiler must ensure
that any object of type T must be aligned to *at least* 4 bytes since the
function is entitled to assume that.

Now consider a function that takes an object of type T that is *not* part
of the current compilation.  When generating code to dereference P, it is
not allowed to assume that the alignment of the object pointed to by P
is *more* than four bytes.

This means that it is an error to change the alignment of the *type*
in either direction from what the user specified.

    I have always expected that a user-specific alignment attribute can
    only increase the alignment of a type or object, not decrease it.
    After all, an object with alignment 8 *is* an object with alignment 4,
    for pointer dereferences and arithmetic purposes.

Except in the case above, where you are *importing* an object that type
and need to know what code to generate.  The reference to Ada is just that
these things are discussed specifically in the Ada RM, but they really apply
just as well to GNU C.

    But now I see that decreasing alignment is sometimes useful, because
    that influences how data is packed in memory, which is useful in some
    data structures and things like variables in special sections.

    It seems that in Ada, this "exact alignment" constraint is a language
    requirement.  (Is this correct, Robert?)

Be careful to distinguish the alignment of *type* with the alignment of
an object of that type.  Also be careful to realize that an implementation
must only provide an 'as if' implementation of the standard.

It is certainly true in Ada that if you have
	for x'alignment use 4;
then if you later ask for x'alignment, you must get 4 (bytes).  It's
also true that x'address must be a multiple of 4.  But if the compiler
were actually to tell the linker to align X to 8 bytes, there would be no
way to distinguish that case from the case where it just happened to be
aligned at that boundary.  So doing so would be conforming to the standard.

So the issue with objects is not conformance, but what's "best".  To
me, it seems that if the user goes to the trouble of specifying an
alignment for an object, they are doing so for a reason and it should
not be overriden unless there's a good reason to do that (e.g.,
minimum alignment on a machine, like S390).

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-21 17:25 Richard Kenner
  2003-04-21 18:14 ` Jamie Lokier
  2003-04-22  9:00 ` Alexandre Oliva
  0 siblings, 2 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-21 17:25 UTC (permalink / raw)
  To: aoliva; +Cc: gcc-patches, gcc

    So if you turn:

    T i __attribute__((align(2)));
    T j __attribute__((align(2)));

    into

    typedef T T2 __attribute__((align(2)));
    T2 i, j;

    you say we could get different code?  

I say so, yes.

And the reason is as I said: you specify alignment for a type both for
interface and efficiency reasons, but for an object only for the latter.
So there is a difference in meaning between these two constructs.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-20 21:28 Robert Dewar
  2003-04-21 17:05 ` Alexandre Oliva
  0 siblings, 1 reply; 101+ messages in thread
From: Robert Dewar @ 2003-04-20 21:28 UTC (permalink / raw)
  To: kenner, rth; +Cc: aoliva, gcc-patches, gcc

> You might.  It depends on what you're doing with that object.
> Perhaps it's been put into a special section and so smooshed
> into an array created at link time.  Indeed, that's *exactly*
> the case that caused us to respect USER_ALIGN in varasm.c at
> all costs.

In that case, you would specify an explicit alignment *for the
object*, which a compiler would take as a clear indication that
the alignment should not be increased. This shows why it is important
to know if the alignment from an object was explicitly specified
for the object.

We specify the alignment of a type to determine the treatment within
composites, but we do not necessarily expect that to not be increased
for stand alone objects.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-20 21:19 Robert Dewar
  0 siblings, 0 replies; 101+ messages in thread
From: Robert Dewar @ 2003-04-20 21:19 UTC (permalink / raw)
  To: aoliva, kenner; +Cc: gcc-patches, gcc

> Thanks, I do see your point now.  However, I still don't think the
> compiler should disregard alignment requirements set to the type just
> because an object is not part of a record.  I do agree that the
> compiler may do it, and it may even happen by chance, but the property
> of the type should carry over to objects and fields uniformly, in the
> absence of an overrider.  The same point you make for someone setting
> the alignment for an object to something different than the type's
> alignment could be made for someone setting the alignment for say a
> typedef, expecting it to affect all uses of the typedef.
> Distinguishing between type-specified and decl-specified alignments
> defeats this purpose.

yes, of course the properties of the type must carry over to objects. But
once again, if you specify an alignment of 1 for a big string (in fact
this is the default alignmment):

  type R is new string (1 .. 1000);
  for R'Alignment use 1;

Then most certainly any stand alone object of type R must have an alignment
of 1, but most certainly may have a larger alignment, and giving stand alone
objects of this type nice large alignments is in fact a very appropriate
optimization (and one that is quite target dependent, so we certainly do
NOT want the user to have to specify a large alignment explicitly).

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-18 11:41 Richard Kenner
  0 siblings, 0 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-18 11:41 UTC (permalink / raw)
  To: rth; +Cc: gcc-patches, gcc

    > No, it's being overloaded for two *other* meanings:
    > 
    > (1) The user really did set the alignment of the object.
    > (2) The user really did set the alignment of the object's *type*.

    I see the two as equivalent.

I see them as very different because the semantics of setting the alignment
of a type and of an object are fundamentally different.  The first has both
efficiency and code generation impact, but the second has only the latter.

This is codified in the Ada RM, but actually applies to all languages.

When you set the alignment of a *type*, you are making an interface statement
about that type, more specifically about pointers to that type.  You are
requiring the compiler to align any objects of that type that it creates to
be at least as aligned as you specify but *also* stating that any objects of
that type *imported* to the code will have that minimum alignment, but aren't
guaranteeing it will have more than that alignment.  So the compiler is not
permitted to assume a larger alignment when it generates code to access
objects of that type (via a pointer, when it knows nothing else about the
object itself).

This means that the specification of the alignment of a type bounds the
compiler on both sides: it must ensure that any object it makes is *no less*
aligned, but it cannot generate code that assumes the alignment is *more*
than that specified.

So if the alignment of a type is specified, the alignment of the type cannot
be changed by the compiler: it must either honor that alignment or give an
error.

But specifying the alignment of an *object* is very different.  It's not
making a statement about an interface, but about efficiency.  If I specify
the alignment of an object, I'm asserting that I've analyzed accesses to the
object and determined the optimal alignment.

In which cases is the compiler allowed to override a user-specified
alignment?  Well, for types it must *never* override the alignment since that
would be an interface violation.

For objects, if an object is at least as aligned as that requested, it's
fine, so I'd argue that a compiler should feel free to over-align an object
for efficiency reasons even if the type's alignment is specified because
there's no reason not to.  On the other hand, if the *object's* alignment is
specified, one can presume it was done with a knowlege of what the optimal
alignment was so that overriding it is not a good idea.

However, if it *has* to be overriden, such as for the minimum alignment of
S390, it certainly *should* be since it's not an error to increase the
alignment of an object (as opposed to a type).

But, in some sense, this isn't even the point.

My major point is that decision of what alignment to actually give an
object may depend on lots of things, including:

(1) the target machine
(2) the language
(3) the mode and alignment of the type
(4) whether the alignment of the type was user-specified
(5) the alignment of the object
(6) whether the alignment of the object was user-specified

What we're doing now is not providing #6, but instead providing the "or"
of #4 and #6.  I see no justification for elminating potentially-useful
information.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-18  8:06 Richard Kenner
  2003-04-18  8:59 ` Richard Henderson
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-18  8:06 UTC (permalink / raw)
  To: rth; +Cc: gcc-patches, gcc

    The fact of the matter is that this field is being overloaded
    for two meanings:

No, it's being overloaded for two *other* meanings:

(1) The user really did set the alignment of the object.
(2) The user really did set the alignment of the object's *type*.

      The user REALLY DID set the alignment, and expects it to
      be honored exactly as stated

Yes, but there's a fundamental ambiguity here.  If the user says he
wants an object aligned at a 4-byte boundary, is it an error to align
it to a page boundary?  Is there some requirement that we ensure that
every such object is at an address that has *exactly* the number of
low-order zeros as requested by the alignment and no more?

What, precisely, does "honored" mean here?

I'll have more to say about this, but tomorrow morning when I'm fresher.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-17 21:41 Richard Kenner
  2003-04-17 23:20 ` Alexandre Oliva
  2003-04-18  1:16 ` Richard Henderson
  0 siblings, 2 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-17 21:41 UTC (permalink / raw)
  To: aoliva; +Cc: gcc-patches, gcc

    Ok, you got me curious.  Would you mind explaining to an Ada-clueless
    person how come these two cases can possibly be different?  In my
    C-centric view, I really can't see the difference.  Code snippets
    demonstrating the semantic difference would be highly appreciated.

You gave one in your previous message: if you specify the alignment of
a type, you don't want to see the alignment of the type made more
strict since that would affect *fields* of that type.  But you don't
mind if stand-alone objects of that type were aligned stricter.  If
you specifically set the alignment of an object, you are presumably
doing so because you *don't* want the object to be put at a stricter
alignment.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-17 21:40 Richard Kenner
  0 siblings, 0 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-17 21:40 UTC (permalink / raw)
  To: aoliva; +Cc: gcc-patches, gcc

    I hope not if this would change the layout of a structure containing a
    member with the specified alignment requirement.  This is where
    propagating the user-requested alignment for a type into the field
    decl comes into play: by doing this, we make sure the alignment
    request is obeyed, regardless of whether it comes from the field decl
    or from its type.

Yes, but this is precisely the case you have been asking to see: if you
set the alignment of a type, you do *not* want a field of the type to
be stricter aligned, but you don't care about an object.  You *do* care
about the object if you *also* specify an alignment for it, which is why
you must distinguish between the two cases.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-17 11:56 Richard Kenner
  2003-04-17 20:35 ` Alexandre Oliva
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-17 11:56 UTC (permalink / raw)
  To: aoliva; +Cc: gcc-patches, gcc

    Well...  You can always compare DECL_USER_ALIGN with TYPE_USER_ALIGN,
    if you care strongly about that.  

No, you can't.  You can't distinguish between the cases where the alignment
is specified for the type and not the object and the case where it is
specified for both.

    But the point that whether the alignment came from a decl-specific
    attribute or from the type shouldn't make a difference.

Why not?  They are two *very* different things with different semantics.

    But why should the common case be more difficult and error-prone?  

Which is "the common case"?  Specifying the alignment of either in C is 
very rare since it is a GNU extension.  Specifying alignment in Ada is
much more common and there the most common case is specifying it for
types and not for objects.

    Do you have any situation in mind in which it is actually important to
    tell whether a decl-specific user-requested alignment came from the
    variable declaration or from its type?

Sure.  It's required to properly implement these specifications for Ada,
where the semantics of the two cases are completely different.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-17 10:44 Robert Dewar
  2003-04-17 20:30 ` Alexandre Oliva
  0 siblings, 1 reply; 101+ messages in thread
From: Robert Dewar @ 2003-04-17 10:44 UTC (permalink / raw)
  To: aoliva, kenner; +Cc: gcc-patches, gcc, rth

> What I don't get is why such cases must be distinguished.  I mean, if
> an alignment is specified by the user for a type, is it not true that
> the user is also specifying the alignment for any objects of that
> type, except when overridden for a specific object?  It seems to me
> that this is the point of the change that propagates TYPE_USER_ALIGN
> to DECL_USER_ALIGN, and I can't see how this could possibly be
> incorrect.  I mean, if it is not, then, given:

Yes, you are specifying an alignment for objects of the type, but the
implementation is always free to give a larger alignment. Consider in
Ada

   type r is new string (1 .. 1000);
   for r'alignment use 1; -- that's also the default if not specified

   a,b : r;

a compiler may well decide to give larger alignment for a and b to improve
the efficiency of the code (e.g. for the assignment a := b).

An alignment specifies the minimum alignment that is guaranteed and that
can be assumed of all objects. It is just fine for a compiler to increase
the alignment to improve the code provided that does not violate other
specifications (e.g. a record that is layed out that contains components
of the type).

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-17  8:12 Richard Kenner
  2003-04-17  8:38 ` Alexandre Oliva
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-17  8:12 UTC (permalink / raw)
  To: aoliva; +Cc: gcc-patches, gcc

    What I don't get is why such cases must be distinguished.  I mean, if
    an alignment is specified by the user for a type, is it not true that
    the user is also specifying the alignment for any objects of that
    type, except when overridden for a specific object?  

Perhaps, but the point is that if you set DECL_USER_ALIGN from
TYPE_USER_ALIGN you *can't tell* if it was "overridden for a specific
object" or not and that information is useful.

    It seems to me that this is the point of the change that propagates
    TYPE_USER_ALIGN to DECL_USER_ALIGN, and I can't see how this could
    possibly be incorrect.  

It might be reasonable for a "consumer" of these bits to do

	DECL_USER_ALIGN (decl) || TYPE_USER_ALIGN (TREE_TYPE (decl))

if it wanted that interpretation, but I think all four cases are
potentially different and the flags should be set up to be able to
distinguish them.  

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-11 22:26 Robert Dewar
  0 siblings, 0 replies; 101+ messages in thread
From: Robert Dewar @ 2003-04-11 22:26 UTC (permalink / raw)
  To: dewar, guerby; +Cc: gcc, kenner, rth

> So there's no specific reason to have -C in ada/Makefile.in,
> I'll look into removing it at some point.

Don't you think that in the context of gcc, it is more convenient to have
the main program in C than in Ada?

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-11 16:59 Robert Dewar
  2003-04-11 18:49 ` Laurent Guerby
  0 siblings, 1 reply; 101+ messages in thread
From: Robert Dewar @ 2003-04-11 16:59 UTC (permalink / raw)
  To: guerby, rth; +Cc: gcc, kenner

> Question to ACT: is "gnatbind -C" here for other than historical reasons
> (supporting previous gnatbind without the feature to generate Ada)?

Not at all, there are many reasons why people find it convenient to generate
a main program in C rather than Ada. This is a feature that is quite widely
used, and we certainly intend to keep supporting it.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-11 16:51 Robert Dewar
  0 siblings, 0 replies; 101+ messages in thread
From: Robert Dewar @ 2003-04-11 16:51 UTC (permalink / raw)
  To: dewar, kenner; +Cc: gcc-patches, gcc

> No, that's actually OK since it is the property of the macros that
> modify alignment that if you start with the alignment that they
> produced, they produce that alignment again.  I suppose nobody has
> even formally documented this property, but it would be very hard to
> see why they would do anything else.

Well indeed it should be formally documented if we depend on it. But
in that case, I also see no harm in setting a "user defined" alignment
that corresponds to this default value.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-11 14:52 Robert Dewar
  0 siblings, 0 replies; 101+ messages in thread
From: Robert Dewar @ 2003-04-11 14:52 UTC (permalink / raw)
  To: kenner, rth; +Cc: gcc-patches, gcc

> Why?  It seems like what it means is "the alignment of this type was set the
> way it is for a reason.  Please don't change it."  And that applies here.

Yes, that's exactly what we want in Ada, and the reason is that Ada has to
know the alignment. Furthermore, the semantics of this alignment are required
to be exactly what would be obtained if a confirming rep clause were given.

So either

a) the confirming rep clause (and setting USER_ALIGN) has no effect in this
case, in which case why bother about it.

or

b) the confirming rep clause WOULD have an effect if USER_ALIGN is only set
in the presence of this rep clause. In that case we must set USER_ALIGN 
regardless, since we don't want the addition of the confirming rep clause
to have any effect.

Seems clear to me!

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-11  4:45 Richard Kenner
  2003-04-17  5:39 ` Alexandre Oliva
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-11  4:45 UTC (permalink / raw)
  To: rth; +Cc: gcc-patches, gcc

    > But it *isn't* set in Ada! 

    Ulrich's experience clearly belies this.

What I meant is that the Ada front end doesn't set it, not that it
isn't getting set.  Instead, it gets set from TYPE_USER_ALIGN, which
seems wrong to me because it doesn't properly distinguish (in any
language) the cases where an alignment is specified for a type
vs. when its specified for a decl.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-11  0:45 Ulrich Weigand
  0 siblings, 0 replies; 101+ messages in thread
From: Ulrich Weigand @ 2003-04-11  0:45 UTC (permalink / raw)
  To: rth; +Cc: gcc, kenner

Richard Henderson wrote:

>On Thu, Apr 10, 2003 at 06:35:54PM -0400, Richard Kenner wrote:
>>     I definitely think there's a bug in that the Ada front end sets
>>     DECL_USER_ALIGN for these objects and the C front end (in response to
>>     the auto-generated files) does not.  That mis-match should be
>>     addressed in some way -- either by not setting DECL_USER_ALIGN in Ada
>> 
>> But it *isn't* set in Ada! 
>
>Ulrich's experience clearly belies this.

You probably missed one of the forks of this thread; to clear 
up possible confusion, what happens is that the Ada frontend
does in fact not set DECL_USER_ALIGN, only TYPE_USER_ALIGN.

It is the middle-end (stor-layout.c), that copies TYPE_USER_ALIGN
to DECL_USER_ALIGN.  And in fact, this is done only as a result
of a patch by Jason Merrill as of last week:

http://gcc.gnu.org/ml/gcc-patches/2003-04/msg00209.html

As this patch is a bit complex, I'm not sure if the change in
behaviour (for Ada) was intended or not, but this patch is
definitely the immediate cause of the s390x / Ada problems ...

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 22:43 Richard Kenner
  2003-04-11  0:31 ` Richard Henderson
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 22:43 UTC (permalink / raw)
  To: rth; +Cc: gcc-patches, gcc

    I definitely think the bug is *not* in varasm.c.  If I write
    "double x __attribute__((aligned(1)))", I expect to see 

        .comm   x,8,1
    not
	.comm	x,8,8

    in the assembly file.

of course.  That's because in this case you are setting the alignment
of the *object*, not the *type*.

    I definitely think there's a bug in that the Ada front end sets
    DECL_USER_ALIGN for these objects and the C front end (in response to
    the auto-generated files) does not.  That mis-match should be
    addressed in some way -- either by not setting DECL_USER_ALIGN in Ada

But it *isn't* set in Ada! 

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 22:23 Richard Kenner
  0 siblings, 0 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 22:23 UTC (permalink / raw)
  To: dje; +Cc: gcc-patches, gcc

    Yes.  64-bit S/390 requires 2-byte alignment.  The alignment can be 2
    or anything stricter than 2 for 64-bit S/390.  GNU Ada currently is
    setting USER_ALIGN to 1 for some objects, which is breaking GNU Ada on
    64-bit S/390.

Actually, it *isn't* setting DECL_USER_ALIGN for any objects and I
believe that's correct.  It's stor-layout.c that is setting it from
TYPE_USER_ALIGN and that seems quite wrong: there is a difference
between specifying the alignment of a type and that of an object and
DECL_USER_ALIGN means the latter.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 22:16 Richard Kenner
  0 siblings, 0 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 22:16 UTC (permalink / raw)
  To: dewar; +Cc: gcc-patches, gcc

    Wel then there is some other funny behavior, which is that it is widely
    understood that provinding a confirming rep clause shoud have no effect
    at all on the generated code.

    So if it should make no difference to the code whether a confirming rep
    clause is given, how can it be possbiule in some cases that it should be
    omitted.

No, that's actually OK since it is the property of the macros that
modify alignment that if you start with the alignment that they
produced, they produce that alignment again.  I suppose nobody has
even formally documented this property, but it would be very hard to
see why they would do anything else.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 22:07 Richard Kenner
  2003-04-10 22:23 ` David Edelsohn
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 22:07 UTC (permalink / raw)
  To: dje; +Cc: gcc-patches, gcc

    1) If the front-end has to specify USER_ALIGN so that the alignment is
    static and the backend will not modify the alignment,

    2) and the front-end is allowed to align the type more strictly,

    3) and the target has minimum alignment requirements,

    then it seems that the front-end needs to know the minimum alignment so
    that it does not specify USER_ALIGN which conflicts with the target
    requirements.  The front-end will use USER_ALIGN and will specify an exact
    alignment, but the alignment will be compatible with the target's own
    minimum alignment requirements.

I don't understand what a "minimum alignment requirement" might mean.
Would it apply to types or only to objects?  

If only to objects, saying that an object is 1-byte aligned allows
*any* alignment.

But I can't find a macro that specifies an minimum alignment.  What is
it called?

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 22:05 Robert Dewar
  0 siblings, 0 replies; 101+ messages in thread
From: Robert Dewar @ 2003-04-10 22:05 UTC (permalink / raw)
  To: dewar, dje; +Cc: gcc-patches, gcc, kenner, rth, weigand

>         Interpret "type" as "primitive type" in your nomenclature.  As
> long as the user does not explicitly override the default alignment of the
> primitive type (probably the natural alignment, or whatever the language
> or target ABI specifies), the compiler should not need to annotate the GCC
> type information with an explicit user type.

Wel then there is some other funny behavior, which is that it is widely
understood that provinding a confirming rep clause shoud have no effect
at all on the generated code.

So if it should make no difference to the code whether a confirming rep
clause is given, how can it be possbiule in some cases that it should be
omitted.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 22:02 Richard Kenner
  2003-04-10 22:24 ` Richard Henderson
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 22:02 UTC (permalink / raw)
  To: rth; +Cc: gcc-patches, gcc

    Seems to me that if this is happening, it's a failing of the
    layout_type interface.  It definitely seems Wrong to abuse
    *USER_ALIGN for this.

Why?  It seems like what it means is "the alignment of this type was set the
way it is for a reason.  Please don't change it."  And that applies here.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 21:56 Richard Kenner
  2003-04-10 22:02 ` David Edelsohn
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 21:56 UTC (permalink / raw)
  To: dje; +Cc: gcc-patches, gcc

    Then it sounds like we need a way for the port to specify or the
    front-end to query the minimum alignment allowed for the target.  This
    would allow the front-end to statically know the alignment of the type
    while maintaining the target requirements.

The issue isn't *minimum*, but *exact*.  The front end needs to know what 
the alignment for a particular type will be.  Yes, it is possible for it
to make on-the-fly calls to the back end to lay out types incrementally, but
that's a very difficult thing to do due to dependencies of types on variables.
It's not clear it's worth it.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 21:45 Richard Kenner
  2003-04-10 21:52 ` David Edelsohn
  2003-04-10 21:57 ` Richard Henderson
  0 siblings, 2 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 21:45 UTC (permalink / raw)
  To: rth; +Cc: gcc-patches, gcc

    Maybe.  I'm a bit confused as to why *_USER_ALIGN would be set for
    "most types" though.  Seems to me that should only be done if the
    USER did something specific, like "for x'alignment use N".

Because of the requirement that the alignment of most types be *static*.
So they cannot be changed from what the front end thinks they are, whether
or not they got that way by explicit user action.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 21:44 Richard Kenner
  0 siblings, 0 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 21:44 UTC (permalink / raw)
  To: geoffk; +Cc: gcc-patches, gcc

    So, what you actually want to do is to set the alignment of the object
    to be *more* aligned than its type?  

Yes.

    Or, to phrase it another way, you want the object to be of a type
    which is more aligned than its declared type?

Not necessarily.  We had this discussion before.  I believe it should be
possible to have DECL_ALIGN > TYPE_ALIGN and likewise for DECL_SIZE.
If it's not, then why have them in the first place?

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 21:32 Robert Dewar
  2003-04-10 21:32 ` David Edelsohn
  0 siblings, 1 reply; 101+ messages in thread
From: Robert Dewar @ 2003-04-10 21:32 UTC (permalink / raw)
  To: dewar, dje; +Cc: gcc-patches, gcc, kenner, rth, weigand

>         Yes, the type can have greater alignment.  However type normally
> does imply a minimum alignment and minimum size.  Specifying user
> alignment for a well-defined type seems redundant.

Well the front end must know statically the alignment of any non-primitive
type, so it makes some sense to specify it as having the value that the
front end thinks it has.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 21:31 Richard Kenner
  0 siblings, 0 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 21:31 UTC (permalink / raw)
  To: dje; +Cc: gcc-patches, gcc

    Yes, the type can have greater alignment.  However type normally does
    imply a minimum alignment and minimum size.  Specifying user alignment
    for a well-defined type seems redundant.

You lost me.

If I have a record of two 16-bit fields, the natural alignment of that type
is 16 bits.  However, the user is allowed to specify an alignment of 32
bits for the type.

I'm not sure what your second sentence means, but it is indeed true
that the compiler cannot change the alignment of a type since it
bounds it in both directions: it gives the minimum alignment that an
object of that type created by the compiler is guaranteed to have, but
it also gives the *maximum* alignment that the compiler is allowed to assume
that a user-created object of that type will have.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 21:29 Robert Dewar
  0 siblings, 0 replies; 101+ messages in thread
From: Robert Dewar @ 2003-04-10 21:29 UTC (permalink / raw)
  To: geoffk, kenner; +Cc: gcc-patches, gcc

> This is the terminology point that Robert alluded to.  If something
> has an alignment of 64 bits, it *also* has an alignment of 32 bits and
> of 16 bits, etc.  So an object that is aligned to 64 bits and is of a
> type that is aligned to 32 bits *has* "the properties (including
> alignment)" of its type.

It's not just that. It would also be fine to have

   type x is record ....
   for x'alignment use 2;

   xx : x;

   Put_Line (Integer'Image (XX'Alignment));

output a value of 4 or 8 or ...

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 21:10 Robert Dewar
  2003-04-10 21:17 ` David Edelsohn
  0 siblings, 1 reply; 101+ messages in thread
From: Robert Dewar @ 2003-04-10 21:10 UTC (permalink / raw)
  To: dewar, weigand; +Cc: gcc-patches, gcc, kenner, rth

> Is it not true in Ada that if something is a particular type, then
> it has the properties (including alignment) of that type?
> 
> That sounds like a pretty fundamental part of the idea of 'type', not
> language-specific.

No, that is not the case, if type'alignment is set, then objects of the type
can have that alignment or a greater alignment. The same is true for 
type'size.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 21:10 Richard Kenner
  0 siblings, 0 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 21:10 UTC (permalink / raw)
  To: geoffk; +Cc: gcc-patches, gcc

    Is it not true in Ada that if something is a particular type, then
    it has the properties (including alignment) of that type?

The other issue is that DECL_USER_ALIGN is supposed to indicate if an
alignment was specified *for a decl*.  If you want to know if an
alignment is specified for *the type of a decl*, you check
TYPE_USER_ALIGN (TREE_TYPE (decl)).  Some code may wish to do
something if *either* alignment was user-specified, but then it can
check *both* flags.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 21:04 Richard Kenner
  2003-04-10 21:41 ` Geoff Keating
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 21:04 UTC (permalink / raw)
  To: geoffk; +Cc: gcc-patches, gcc

    Is it not true in Ada that if something is a particular type, then
    it has the properties (including alignment) of that type?

This is the terminology point that Robert alluded to.  If something
has an alignment of 64 bits, it *also* has an alignment of 32 bits and
of 16 bits, etc.  So an object that is aligned to 64 bits and is of a
type that is aligned to 32 bits *has* "the properties (including
alignment)" of its type.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 20:57 Robert Dewar
  2003-04-10 21:07 ` Ulrich Weigand
  0 siblings, 1 reply; 101+ messages in thread
From: Robert Dewar @ 2003-04-10 20:57 UTC (permalink / raw)
  To: rth, weigand; +Cc: gcc-patches, gcc, kenner

> > This means that when compiling the C source that references
> > the variables, I do not know that they are in fact 1-byte
> > aligned.  Do you think the backend should be able to cope
> > with even this scenario, or would you consider this a 
> > frontend bug?

What does it mean "I do not know that they are in fact 1-byte aligned".
All variables (other than bit fields) are 1-byte aligned.

Part of the trouble here is difference in terminology between Ada and
gcc alignment requirements. This has also caused severe unresolved
difficulties when it comes to maximum alignment values.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 20:52 Robert Dewar
  0 siblings, 0 replies; 101+ messages in thread
From: Robert Dewar @ 2003-04-10 20:52 UTC (permalink / raw)
  To: geoffk, weigand; +Cc: gcc-patches, gcc, kenner

> I'm not sure whether this is the preferred fix; in particular
> I don't understand why those variables need to have forced 
> alignment in the first place ...


The Ada semantics is that they must have the indicated alignment. It is
of course always fine to give a larger alignment that is a multiple of
the requested alignment (it's just a special case of meeting the alignment
requirement).

We are discussing now exactly what the relation between the Ada semantics
and the gcc semantics for alignment. 

Right now, it looks like the alignment should be forced for subtypes and
not forced for objects, and that is correct provided that objects are always
given an alignment at least as large as that of the subtype.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 20:39 Richard Kenner
  2003-04-10 21:00 ` Geoff Keating
                   ` (2 more replies)
  0 siblings, 3 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 20:39 UTC (permalink / raw)
  To: weigand; +Cc: gcc-patches, gcc

    Well, it looks like DECL_USER_ALIGN is copied from TYPE_USER_ALIGN
    in do_type_align (stor-layout.c), called via this call chain:

I figured it had to be something like that.  It's probably correct for C,
but not for Ada.  Perhaps we need a new lang hook?

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 20:13 Richard Kenner
  2003-04-10 20:28 ` Ulrich Weigand
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 20:13 UTC (permalink / raw)
  To: weigand; +Cc: gcc-patches, gcc

After extensive discussion, I think the proper thing is for the Ada
front end to set TYPE_USER_ALIGN on all (or nearly all) types, but
not to set DECL_USER_ALIGN on any decls.  However, when I looked, I see
that is indeed what it *does* do, so I'm now confused about the problem
you are seeing.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10 19:20 Richard Kenner
  0 siblings, 0 replies; 101+ messages in thread
From: Richard Kenner @ 2003-04-10 19:20 UTC (permalink / raw)
  To: weigand; +Cc: gcc-patches, gcc

    I'm not sure whether this is the preferred fix; in particular
    I don't understand why those variables need to have forced 
    alignment in the first place ...

I think it needs more thought.  Ada semantics on alignment are quite
complex.  At first though, DECL_USER_ALIGN should either *always* be
set or *never* be set, but it's not clear which or even, yet, whether
that's correct or not.

I've started a discussion among the alignment experts in Ada.

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-10  5:33 Richard Kenner
  2003-04-10  7:20 ` Ulrich Weigand
  0 siblings, 1 reply; 101+ messages in thread
From: Richard Kenner @ 2003-04-10  5:33 UTC (permalink / raw)
  To: weigand; +Cc: gcc

    But this does not solve my problem that Ada does not
    bootstrap; for some reason the Ada frontend sets the
    USER_ALIGN flag for a huge number of variables, even
    those that were defined without any special 'Alignment
    attributes ...

That's because the front end will specify the alignment of some variables.
But what does that have to with failure to bootstrap?

^ permalink raw reply	[flat|nested] 101+ messages in thread
* Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-09 23:31 Ulrich Weigand
  2003-04-10  2:27 ` Richard Henderson
  0 siblings, 1 reply; 101+ messages in thread
From: Ulrich Weigand @ 2003-04-09 23:31 UTC (permalink / raw)
  To: rth; +Cc: gcc

Hello Richard,

I wrote:
>My question is now, why is DATA_ALIGNMENT ignored in such cases?
>Is this a bug or a feature?  If the latter, what other options does
>a backend have to absolutely enforce a minimum alignment for global
>variables?

checking CVS logs showed that this is apparently a feature, 
introduced in a patch of yours a couple of years ago:
http://gcc.gnu.org/ml/gcc-patches/2001-08/msg01037.html
("suppress optional alignment for user variables").

However, the problem remains that on s390, the alignment is not
in fact 'optional' but a hard requirement.  (Looking at the
various implementations of DATA_ALIGNMENT, it seems that mmix
also needs this to be handled as required, while for the others
it is indeed optional.) 

I'm now wondering what we can do to fix this.  One way might
be to add another target macro; or else we could shift the
burden to distinguish between optional and required alignments
into the DATA_ALIGNMENT macro: the macro gets the type as
parameter, and the backend can check whether the USER_ALIGN
is bit is set and if so, only perform mandatory, not optional,
alignment adjustments.

Would you agree with this or do you have other suggestions?

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  weigand@informatik.uni-erlangen.de

^ permalink raw reply	[flat|nested] 101+ messages in thread
* DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
@ 2003-04-08 17:47 Ulrich Weigand
  0 siblings, 0 replies; 101+ messages in thread
From: Ulrich Weigand @ 2003-04-08 17:47 UTC (permalink / raw)
  To: gcc

Hello,

the target macro DATA_ALIGNMENT is supposed to be able to override the
alignment used for global data variables.  We are using this on s390x
to make sure all data objects are at least 2-byte aligned.  This is not
an optimization, but essential for correctness, as we cannot load the
address of a label that is not 2-byte aligned.

Unfortunately, DATA_ALIGNMENT is simply ignored when outputting a
variable that has the DECL_USER_ALIGNMENT flag set.  While this does
not usually occur with C code unless using source code like

  char x __attribute__ ((__aligned__(1)));

this flag is apparently much more frequently set by the Ada frontend.
In fact, this is currently causing bootstrap errors for Ada on s390x
because an elaboration check flag variable is not correctly aligned.


My question is now, why is DATA_ALIGNMENT ignored in such cases?
Is this a bug or a feature?  If the latter, what other options does
a backend have to absolutely enforce a minimum alignment for global
variables?


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

--
  Dr. Ulrich Weigand
  Linux for S/390 Design & Development
  IBM Deutschland Entwicklung GmbH, Schoenaicher Str. 220, 71032 Boeblingen
  Phone: +49-7031/16-3727   ---   Email: Ulrich.Weigand@de.ibm.com

^ permalink raw reply	[flat|nested] 101+ messages in thread

end of thread, other threads:[~2003-04-25  0:09 UTC | newest]

Thread overview: 101+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-22  0:11 DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT Robert Dewar
2003-04-22  1:35 ` Jamie Lokier
  -- strict thread matches above, loose matches on Subject: below --
2003-04-23  3:29 Robert Dewar
2003-04-23  2:20 Richard Kenner
2003-04-23  5:31 ` Alexandre Oliva
2003-04-24  6:23   ` Jason Merrill
2003-04-24  8:43     ` Geert Bosch
2003-04-24 17:48       ` Jason Merrill
2003-04-24 18:04         ` Zack Weinberg
2003-04-24 19:31           ` Jason Merrill
2003-04-24 21:32         ` Geert Bosch
2003-04-24 23:24           ` Jason Merrill
2003-04-25  2:56     ` Richard Henderson
2003-04-22 15:08 Richard Kenner
2003-04-23  1:07 ` Alexandre Oliva
2003-04-22  0:15 Robert Dewar
2003-04-22  1:58 ` Jamie Lokier
2003-04-21 21:25 Richard Kenner
2003-04-21 20:59 Richard Kenner
2003-04-21 21:14 ` Jamie Lokier
2003-04-21 20:45 Richard Kenner
2003-04-21 20:58 ` Jamie Lokier
2003-04-21 18:14 Richard Kenner
2003-04-21 20:33 ` Jamie Lokier
2003-04-21 17:25 Richard Kenner
2003-04-21 18:14 ` Jamie Lokier
2003-04-22  9:00 ` Alexandre Oliva
2003-04-20 21:28 Robert Dewar
2003-04-21 17:05 ` Alexandre Oliva
2003-04-20 21:19 Robert Dewar
2003-04-18 11:41 Richard Kenner
2003-04-18  8:06 Richard Kenner
2003-04-18  8:59 ` Richard Henderson
2003-04-17 21:41 Richard Kenner
2003-04-17 23:20 ` Alexandre Oliva
2003-04-18  1:16 ` Richard Henderson
2003-04-17 21:40 Richard Kenner
2003-04-17 11:56 Richard Kenner
2003-04-17 20:35 ` Alexandre Oliva
2003-04-17 22:41   ` Geert Bosch
2003-04-17 23:19     ` Alexandre Oliva
2003-04-17 10:44 Robert Dewar
2003-04-17 20:30 ` Alexandre Oliva
2003-04-17  8:12 Richard Kenner
2003-04-17  8:38 ` Alexandre Oliva
2003-04-11 22:26 Robert Dewar
2003-04-11 16:59 Robert Dewar
2003-04-11 18:49 ` Laurent Guerby
2003-04-11 16:51 Robert Dewar
2003-04-11 14:52 Robert Dewar
2003-04-11  4:45 Richard Kenner
2003-04-17  5:39 ` Alexandre Oliva
2003-04-11  0:45 Ulrich Weigand
2003-04-10 22:43 Richard Kenner
2003-04-11  0:31 ` Richard Henderson
2003-04-11  2:19   ` David Edelsohn
2003-04-10 22:23 Richard Kenner
2003-04-10 22:16 Richard Kenner
2003-04-10 22:07 Richard Kenner
2003-04-10 22:23 ` David Edelsohn
2003-04-10 22:05 Robert Dewar
2003-04-10 22:02 Richard Kenner
2003-04-10 22:24 ` Richard Henderson
2003-04-11 11:20   ` Laurent Guerby
2003-04-11 11:57     ` Arnaud Charlet
2003-04-11 14:16       ` Laurent Guerby
2003-04-10 21:56 Richard Kenner
2003-04-10 22:02 ` David Edelsohn
2003-04-10 21:45 Richard Kenner
2003-04-10 21:52 ` David Edelsohn
2003-04-10 21:57 ` Richard Henderson
2003-04-10 21:44 Richard Kenner
2003-04-10 21:32 Robert Dewar
2003-04-10 21:32 ` David Edelsohn
2003-04-10 21:31 Richard Kenner
2003-04-10 21:29 Robert Dewar
2003-04-10 21:10 Robert Dewar
2003-04-10 21:17 ` David Edelsohn
2003-04-10 21:10 Richard Kenner
2003-04-10 21:04 Richard Kenner
2003-04-10 21:41 ` Geoff Keating
2003-04-10 20:57 Robert Dewar
2003-04-10 21:07 ` Ulrich Weigand
2003-04-10 20:52 Robert Dewar
2003-04-10 20:39 Richard Kenner
2003-04-10 21:00 ` Geoff Keating
2003-04-10 21:01 ` Ulrich Weigand
2003-04-10 21:44 ` Richard Henderson
2003-04-10 20:13 Richard Kenner
2003-04-10 20:28 ` Ulrich Weigand
2003-04-10 19:20 Richard Kenner
2003-04-10  5:33 Richard Kenner
2003-04-10  7:20 ` Ulrich Weigand
2003-04-09 23:31 Ulrich Weigand
2003-04-10  2:27 ` Richard Henderson
2003-04-10  3:10   ` Ulrich Weigand
2003-04-10 16:20     ` Ulrich Weigand
2003-04-10 16:39       ` Geoff Keating
2003-04-10 16:44         ` Ulrich Weigand
2003-04-10 18:06       ` Richard Henderson
2003-04-08 17:47 Ulrich Weigand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).