armel: incorrect immediate for movt

Bug #730440 reported by Jani Monoses on 2011-03-07
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro GCC
Fix Released
Medium
Ramana Radhakrishnan
Linaro GCC Tracking
Fix Released
Undecided
Ramana Radhakrishnan
gcc
Fix Released
Medium
gcc-4.5 (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: gcc-4.5

 firebird2.1 FTBFS with gcc 4.5
http://launchpadlibrarian.net/65645274/buildlog_ubuntu-natty-armel.firebird2.1_2.1.3.18185-0.ds1-11build1_FAILEDTOBUILD.txt.gz

g++ -g -O2 -DTERMINATE_IDLE_LOCK_MANAGER -Werror=write-strings -DBOOT_BUILD -I../src/include/gen -I../src/include -I../src/vulcan -DNAMESPACE=Vulcan -O3 -DNDEBUG -DLINUX -DARM -pipe -p -MMD -fPIC -fsigned-char -fmessage-length=0 -DPROD_BUILD -c ../src/jrd/shut.cpp -o ../temp/boot/jrd/shut.o
In file included from ../src/jrd/../jrd/../jrd/all.h:30:0,
                 from ../src/jrd/../jrd/jrd.h:35,
                 from ../src/jrd/shut.cpp:26:
../src/jrd/../jrd/../jrd/../common/classes/fb_string.h:355:8: note: the mangling of 'va_list' has changed in GCC 4.4
{standard input}: Assembler messages:
{standard input}:1964: Error: immediate value out of range -- `movt r1,-1'

It only occurs at -O3 and gcc 4.5
The same command line works with either gcc 4.4 or -O2

Download full text (4.1 KiB)

Created attachment 22618
a module

When compiling the attached file the compiler does not warn, but the assambler gives the following error:
C:\DOKUME~1\tkr\LOKALE~1\Temp\ccqr1SmQ.s: Assembler messages:
C:\DOKUME~1\tkr\LOKALE~1\Temp\ccqr1SmQ.s:522: Error: immediate value out of range -- `movt r3,-32768'
The line "dwCalcVal.u_16_values.u_16_value_1=0x8000u;" causes the error.
It looks to me like a singned-unsigned fault and in fact it is so. reducing the constant to a value 0x0000 till 0x7FFF will compile without error.
The problem appears also only when:
- the value is at the stack (local)
- the second value in struct is used (u_16_value_0 works fine).
GCC v 4.3.3 also works fine on the same code.

Configuarion:
-------------
PC Windows XP with Codesourcery, Target STM32F103 ARM-Controller
>arm-none-eabi-gcc.exe -v
Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc.exe
COLLECT_LTO_WRAPPER=c:/temp/codesourcery/bin/../libexec/gcc/arm-none-eabi/4.5.1/lto-wrapper.exe
Target: arm-none-eabi
Configured with: /scratch/julian/2010q3-release-eabi-lite/src/gcc-4.5-2010.09/configure --build=i686-pc-linux-gnu --host=i686-mingw32 --target=arm-none-eabi --enable-threads --disable-libmudflap --disable-libssp --disable-libstdcxx-pch --enable-extra-sgxxlite-multilibs --with-gnu-as --with-gnu-ld --with-specs='%{save-temps: -fverbose-asm} -D__CS_SOURCERYGXX_MAJ__=2010 -D__CS_SOURCERYGXX_MIN__=9 -D__CS_SOURCERYGXX_REV__=51 %{O2:%{!fno-remove-local-statics: -fremove-local-statics}} %{O*:%{O|O0|O1|O2|Os:;:%{!fno-remove-local-statics: -fremove-local-statics}}}' --enable-languages=c,c++ --disable-s
hared --enable-lto --with-newlib --with-pkgversion='Sourcery G++ Lite 2010.09-51' --with-bugurl=https://support.codesourcery.com/GNUToolchain/ --disable-nls --prefix=/opt/codesourcery --with-headers=yes --with-sysroot=/opt/codesourcery/arm-none-eabi --with-build-sysroot=/scratch/julian/2010q3-release-eabi-lite/install/host-i686-mingw32/arm-none-eabi --with-libiconv-prefix=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr --with-gmp=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr --with-mpfr=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr --with-mpc=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr --with-ppl=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lst dc++,-Bdynamic -lm' --with-cloog=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr --with-libelf=/scratch/julian/2010q3-release-eabi-lite/obj/host-libs-2010.09-51-arm-none-eabi-i686-mingw32/usr --disable-libgomp --enable-poison-system-directories --with-build-time-tools=/scratch/julian/2010q3-release-eabi-lite/obj/tools-i686-pc-linux-gnu-2010.09-51-arm-none-eabi-i686-mingw32/arm-none-eabi/bin --with-build-time-tools=/scratch/julian/2010q3-release-eabi-lite/obj/tools-i686-pc-linux-gnu-2010.09-51-arm-none-eabi-i686-mingw32/arm-none-eabi/bin
Thread model: single
gcc version 4.5.1 (Sourc...

Read more...

Please report to CodeSourcery or use a FSF version.

In , Mikpe (mikpe) wrote :

I can reproduce this with FSF gcc-4.5/4.6 and binutils-2.20.1 on armv5tel-linux-gnueabi:

> gcc/xgcc -Bgcc -mcpu=cortex-m3 -mthumb -O2 -c MyFile.c
/tmp/ccCisNkW.s: Assembler messages:
/tmp/ccCisNkW.s:27: Error: immediate value out of range -- `movt r3,-32768'

With gcc-4.4 the error does not occur.

In , Mikpe (mikpe) wrote :

It's caused by 150953:

Author: ramana
Date: Thu Aug 20 08:09:29 2009
New Revision: 150953

URL: http://gcc.gnu.org/viewcvs?root=3Dgcc&view=3Drev&rev=3D150953
Log:
Fix twolf ICE for ARM

2009-08-19 Ramana Radhakrishnan <email address hidden>
            Richard Earnshaw <email address hidden>

        * config/arm/arm.c (arm_emit_movpair): Handle CONST_INT.
        * config/arm/arm.md (*arm_movtas_ze): New pattern for
        movt.

You're missing an "#:upper16:" annotation in the *arm_movtas_ze pattern, c.f. the *arm_movt pattern.

(Not posting a patch since my renewed attempt to get a copyright assignment seems to have ended up in /dev/null over at the FSF.)

Jani Monoses (jani) wrote :

Here is a shorter snippet that exhibits the issue, however in this case both -O2 and -O3 fail with the same error
Error: immediate value out of range -- `movt r1,-77'

// Shutdown lock data
union shutdown_data {
        struct {
                SSHORT flag;
                SSHORT delay;
        } data_items;
        SLONG data_long;
};

void notify_shutdown(Database* dbb)
{
        shutdown_data data;

        data.data_items.flag = 1;
        data.data_items.delay = -77;

        LOCK_write_data(dbb->dbb_lock->lck_id, data.data_long);

}

the called function is in another source file and looks like this
SLONG LOCK_write_data(SRQ_PTR request_offset, SLONG data)
{
/**************************************
 *
 * L O C K _ w r i t e _ d a t a
 *
 **************************************
 *
 * Functional description
 * Write a longword into the lock block.
 *
 **************************************/
        LOCK_TRACE(("LOCK_write_data (%ld)\n", request_offset));

        lrq* request = get_request(request_offset);
        acquire(request->lrq_owner);
        ++LOCK_header->lhb_write_data;
        request = (LRQ) SRQ_ABS_PTR(request_offset); /* Re-init after a potential remap */
        lbl* lock = (LBL) SRQ_ABS_PTR(request->lrq_lock);
        remove_que(&lock->lbl_lhb_data);
        if (lock->lbl_data = data)
                insert_data_que(lock);

        if (lock->lbl_series < LCK_MAX_SERIES)
                ++LOCK_header->lhb_operations[lock->lbl_series];
        else
                ++LOCK_header->lhb_operations[0];

        release(request->lrq_owner);

        return data;
}

Jani Monoses (jani) wrote :

If more info is needed it can be reproduced by building firebird2.1 on natty.

tags: added: arm-porting-queue
Ramana Radhakrishnan (ramana) wrote :

Missing pre-processed source and command line options.
Can you attach the .i file you get after running --save-temps on
the command line with the bug report ? It is much faster than
trying to recreate the environment and starting from there.

cheers
Ramana

Changed in gcc-4.5 (Ubuntu):
status: New → Incomplete
Michael Hope (michaelh1) wrote :

Attached preprocessed source and assembly. Reproduced with gcc-linaro-4.5-2011.03-0:

g++ -g -O2 -DTERMINATE_IDLE_LOCK_MANAGER -Werror=write-strings -save-temps -DBOOT_BUILD -I../src/include/gen -I../src/include -I../src/vulcan -DNAMESPACE=Vulcan -O3 -DNDEBUG -DLINUX -DARM -pipe -p -MMD -fPIC -fsigned-char -fmessage-length=0 -DPROD_BUILD -c ../src/jrd/shut.cpp -o ../temp/boot/jrd/shut.o
g++: warning: -pipe ignored because -save-temps specified
In file included from ../src/jrd/../jrd/../jrd/all.h:30:0,
                 from ../src/jrd/../jrd/jrd.h:35,
                 from ../src/jrd/shut.cpp:26:
../src/jrd/../jrd/../jrd/../common/classes/fb_string.h:355:8: note: the mangling of 'va_list' has changed in GCC 4.4
shut.s: Assembler messages:
shut.s:1964: Error: immediate value out of range -- `movt r1,-1'
make[4]: *** [../temp/boot/jrd/shut.o] Error 1

Michael Hope (michaelh1) wrote :

Assembly.

Changed in gcc-linaro:
status: New → Triaged
importance: Undecided → Medium
Changed in gcc-4.5 (Ubuntu):
status: Incomplete → New

Confirmed

Ramana Radhakrishnan (ramana) wrote :

Related to http://gcc.gnu.org/PR46788 upstream.

Ramana

Ramana Radhakrishnan (ramana) wrote :

I have a patch being tested.

Changed in gcc-linaro:
assignee: nobody → Ramana Radhakrishnan (ramana)
Changed in gcc-4.5 (Ubuntu):
status: New → In Progress
Changed in gcc:
importance: Unknown → Medium
status: Unknown → In Progress
Changed in gcc-linaro:
status: Triaged → In Progress

I've just merged Ramana's patch into lp:gcc-linaro/4.5

Changed in gcc-linaro:
milestone: none → 4.5-2011.04-0
status: In Progress → Fix Committed

Assigning Ramana to submit this upstream (or set it to "Invalid" if that's not appropriate).

Related: lp:gcc-linaro/4.5,revno=99489

Changed in gcc-linaro-tracking:
assignee: nobody → Ramana Radhakrishnan (ramana)
milestone: none → 4.7.0

Author: ramana
Date: Tue Mar 15 17:05:51 2011
New Revision: 171002

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171002
Log:

Fixup last commit.

Fixed PR target/46788 and not PR 47688

Added:
    trunk/gcc/testsuite/gcc.target/arm/pr46788.c
      - copied unchanged from r171001, trunk/gcc/testsuite/gcc.target/arm/pr47688.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog

(In reply to comment #5)
> Author: ramana
> Date: Tue Mar 15 17:05:51 2011
> New Revision: 171002
>
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171002
> Log:
>
> Fixup last commit.
>
> Fixed PR target/46788 and not PR 47688
>
>
> Added:
> trunk/gcc/testsuite/gcc.target/arm/pr46788.c
> - copied unchanged from r171001,
> trunk/gcc/testsuite/gcc.target/arm/pr47688.c
> Modified:
> trunk/gcc/ChangeLog
> trunk/gcc/testsuite/ChangeLog

This was fixed on trunk with this original commit followed by the commit in the previous comment.

Author: ramana
Date: Tue Mar 15 16:14:21 2011
New Revision: 171000

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171000
Log:
Fix PR 47688

2011-03-18 Ramana Radhakrishnan <email address hidden>

    PR target/47668
    gcc/
    * config/arm/arm.md (arm_movtas_ze): Use 'L' instead of 'c'
    in the output template.
    gcc/testsuite/
    * gcc.target/arm/pr47688.c: New.

Added:
    trunk/gcc/testsuite/gcc.target/arm/pr47688.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/arm/arm.md
    trunk/gcc/testsuite/ChangeLog

AFAICS, however, pr47688.c is still there.

Author: ramana
Date: Tue Mar 15 19:59:25 2011
New Revision: 171017

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171017
Log:

Fix PR target/46788

Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.target/arm/pr46788.c
      - copied unchanged from r171005, trunk/gcc/testsuite/gcc.target/arm/pr46788.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/config/arm/arm.md
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog

(In reply to comment #7)
> AFAICS, however, pr47688.c is still there.

I think I managed to delete it now even though I did do a svn rename.

Ramana

In , Mikpe (mikpe) wrote :

(In reply to comment #8)
> Author: ramana
> Date: Tue Mar 15 19:59:25 2011
> New Revision: 171017
>
> URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171017
> Log:
>
> Fix PR target/46788
>
>
> Added:
> branches/gcc-4_6-branch/gcc/testsuite/gcc.target/arm/pr46788.c
> - copied unchanged from r171005,
> trunk/gcc/testsuite/gcc.target/arm/pr46788.c
> Modified:
> branches/gcc-4_6-branch/gcc/ChangeLog
> branches/gcc-4_6-branch/gcc/config/arm/arm.md
> branches/gcc-4_6-branch/gcc/testsuite/ChangeLog

The ChangeLog entry refers to PR 46778, it should refer to PR 46788.

Michael Hope (michaelh1) on 2011-04-21
Changed in gcc-linaro:
status: Fix Committed → Fix Released
Changed in gcc-linaro-tracking:
milestone: 4.7.0 → 4.6.0
status: New → Fix Released
tags: added: 46merge
Matthias Klose (doko) wrote :

fixed in oneiric

Changed in gcc-4.5 (Ubuntu):
status: In Progress → Fix Released

Fixed.

Changed in gcc:
status: In Progress → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.