Bug 11442 - [3.3 regression] [arm] invalid assembler on arm
Summary: [3.3 regression] [arm] invalid assembler on arm
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.1
: P1 critical
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2003-07-06 11:57 UTC by Debian GCC Maintainers
Modified: 2003-10-01 10:16 UTC (History)
1 user (show)

See Also:
Host:
Target: arm-linux
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-07-09 22:19:22


Attachments
preprocessed source (37.20 KB, application/gzip)
2003-07-06 11:58 UTC, Debian GCC Maintainers
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2003-07-06 11:57:50 UTC
[forwarded from http://bugs.debian.org/188513]

rechecked with CVS 3.3.1 and HEAD CVS 20030531, binutils-2.14.0.90.4
regression compared to gcc-2.95

$ gcc -c -O2 engine.i 
/tmp/ccVcqHkK.s: Assembler messages:
/tmp/ccVcqHkK.s:4532: Warning: source register same as write-back base
/tmp/ccVcqHkK.s:3038: Error: bad immediate value for offset (4104)
/tmp/ccVcqHkK.s:3056: Error: bad immediate value for offset (4176)
/tmp/ccVcqHkK.s:3084: Error: bad immediate value for offset (4288)
/tmp/ccVcqHkK.s:3092: Error: bad immediate value for offset (4140)
/tmp/ccVcqHkK.s:3103: Error: bad immediate value for offset (4104)
/tmp/ccVcqHkK.s:5237: Error: bad immediate value for offset (4132)
/tmp/ccVcqHkK.s:5250: Error: bad immediate value for offset (4184)
/tmp/ccVcqHkK.s:5264: Error: bad immediate value for offset (4240)
/tmp/ccVcqHkK.s:5276: Error: bad immediate value for offset (4108)
Comment 1 Debian GCC Maintainers 2003-07-06 11:58:39 UTC
Created attachment 4352 [details]
preprocessed source
Comment 2 Dara Hazeghi 2003-07-09 22:19:22 UTC
Confirmed with gcc 3.1, 3.3 branch and mainline (20030708).
Comment 3 Richard Earnshaw 2003-10-01 09:15:16 UTC
Not a bug.  Your source code is invalid.

You can't put any "asm" in your source code that requires more than 4 bytes per
statement.  You have ".skip 16" operations which are violating this constraint
and consequently gcc gets confused in a way which can only be detected by the
assembler.

The compiler does not parse the body of asm statements to divine their meaning.
Comment 4 Richard Earnshaw 2003-10-01 09:18:56 UTC
Note for clarity.  By "four bytes per statement" I mean between each semicolon
in the input string.  So 

	asm ("insn1; insn2; insn3 insn4")

is ok and (on ARM) will be counted as 16 bytes.  But

	asm (".space 16")

is not, it will only be counted as 4 bytes by the compiler.
Comment 5 falk.hueffner 2003-10-01 09:29:14 UTC
Subject: Re:  [3.3 regression] [arm] invalid assembler on arm

"rearnsha at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org> writes:

> You can't put any "asm" in your source code that requires more than
> 4 bytes per statement.  You have ".skip 16" operations which are
> violating this constraint and consequently gcc gets confused in a
> way which can only be detected by the assembler.

Is this something ARM specific? I can't find anything in the manual
about it. If it's a general statement, we can also close 12108.

> The compiler does not parse the body of asm statements to divine
> their meaning.

But it does count the ;'s?

Comment 6 Richard Earnshaw 2003-10-01 10:16:26 UTC
> Is this something ARM specific? I can't find anything in the manual
> about it. If it's a general statement, we can also close 12108.

Not specifically.  It applies to any port which relies on accurate tracking of
the size of instructions generated (sh spings to mind here).

In the ARM case we have to do this because of the limited range of a pc-relative
load, which means that constants have to split into sub-pools that are reachable
by a single instruction.

12108 is similar, but subtly different.  In that case (as I understand it from a
quick scan) the compiler is trying to suppress an ASM statement by the use of a
special instruction which will cause the following instruction to not be
executed (or only executed under specific conditions).  In this case the
compiler must know that the asm body will expand into exactly one target
instruction -- so it's not the length of the sequence generated, but the number
of instructions.  It could be argued that conditional suppression of an ASM
should never be attempted by the compiler, but I don't know enough about the
processor in question to be sure.

The documentation for ASM should probably be updated to make it clear that gcc
has to estimate the number of bytes that an ASM will generate and that the
estimate is based on the number of statements multiplied by the longest
instruction in the target.  Use of any ASM statement that produces more bytes
than that should be considered "unspecified behaviour" (it might work on some
platforms all the time, but on others only some of the time).