ambiguity of .align

I just got this error message from the GNU assembler:

Error: alignment too large: 15 assumed

Which made me laugh at first. The corresponding input line was:

  .align 16

Apparently what's going on here is that ".align 16" is ambiguous: on
some architectures it means ".balign 16", and on some it means ".p2align
16", which would mean ".balign 65536" if it were allowed. See:

http://ftp.gnu.org/pub/old-gnu/Manuals/gas-2.9.1/html_node/as_68.html

I'm not sure what the best way is to fix this. If LLVM wants to support
other assemblers presumably an architecture-dependency is required.

Edmund

I just got this error message from the GNU assembler:

Error: alignment too large: 15 assumed

Which made me laugh at first. The corresponding input line was:

   \.align  16

Apparently what's going on here is that ".align 16" is ambiguous: on
some architectures it means ".balign 16", and on some it means ".p2align
16", which would mean ".balign 65536" if it were allowed. See:

Using as - Align

I'm not sure what the best way is to fix this. If LLVM wants to support
other assemblers presumably an architecture-dependency is required.

On what architecture did you got the error? We have AlignmentIsInBytes
in MCAsmInfo for that. It is probably wrong for your architecture.

Edmund

Cheers,

Assuming you're working with an ARM target, you may also hit a problem
with the alignment option on the .comm directive.

Attached is a first-cut patch for this latter problem.

deep

deep-llvm-comm-align.diff (4.04 KB)

The particular version of the GNU assembler that I'm using doesn't
accept an alignment argument to .lcomm. It does accept an alignment
argument to .comm, but this is a number of bytes rather than a number of
address bits.

http://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_chapter/as_7.html
suggests that the third argument to .comm (and perhaps, by analogy, the
third argument to .lcomm) is always a number of bytes. So
COMMDirectiveAlignmentIsInBytes might not be needed.

Edmund

Thanks. This was on ARM, and this one-line diff against r94535 made it
work for me.

diff (352 Bytes)

Thanks. This was on ARM, and this one-line diff against r94535 made it
work for me.

We changed that recently because .comm directives were not getting
sufficiently aligned. So for gas we have to use bytes in .comm but
the log2 for .align? Is this case Sandeep Patel's patch is probably
going in the right direction.

I will check that with my copy gas.

Just checking, you guys are using a AAPCS ELF target like
arm-none-linux-gnueabi?

Cheers,

I have updated your patch to reflect the recent changes. I have also
updated the tests. I have checked that it produces

comm.patch (4.6 KB)

Patch looks good to me. Please put a comment in the ARM MCAsmInfo sayings ".comm align is in bytes but .align is pow-2." or something like that. Thanks!

-Chris

FWIW, I now realize that I originally submitted this on 11/5/09 and
forgot to ping it. Sorry about that.

deep