public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/39378] New: Multiple inheritence thunk not working with -mthumb
@ 2009-03-05 4:47 dougkwan at google dot com
2009-03-11 23:30 ` [Bug middle-end/39378] " ramana dot r at gmail dot com
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: dougkwan at google dot com @ 2009-03-05 4:47 UTC (permalink / raw)
To: gcc-bugs
This simple test case crashed in sim when compiler by arm-eabi-gcc for thumb.
-------
class B1
{
public:
virtual void foo1(void) {}
int b1;
};
class B2
{
public:
virtual void foo2 (void) {}
};
class D : public B1, public B2
{
void foo1(void) {}
void foo2(void) {}
};
void __attribute__((noinline))
test(B2* bp)
{
bp->foo2();
}
int
main()
{
D d;
test (&d);
return 0;
}
-------
$ arm-eabi-g++ -mthumb -mthumb-interwork bug.cc
$ arm-eabi-gdb a.out
GNU gdb 6.7.1
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=i686-unknown-linux-gnu --target=arm-eabi"...
(gdb) target sim
Connected to the simulator.
(gdb) load a.out
Loading section .init, size 0xc vma 0x8000
Loading section .text, size 0x32b8 vma 0x800c
Loading section .fini, size 0xc vma 0xb2c4
Loading section .rodata, size 0x208 vma 0xb2d0
Loading section .ARM.extab, size 0x90 vma 0xb4d8
Loading section .ARM.exidx, size 0x248 vma 0xb568
Loading section .eh_frame, size 0x4 vma 0xb7b0
Loading section .init_array, size 0x4 vma 0x137b4
Loading section .fini_array, size 0x4 vma 0x137b8
Loading section .jcr, size 0x4 vma 0x137bc
Loading section .data, size 0x930 vma 0x137c0
Start address 0x806c
Transfer rate: 132992 bits in <1 sec.
(gdb) run
Starting program: /usr/local/google/data/dougkwan/arm-elf/test/a.out
Unhandled v6 thumb insn: e92d
sim: exception: Unhandled Instruction '0xe92d4080' at 0x000081d0. Stopping.
Program received signal 0, Signal 0.
0x00000b90 in ?? ()
(gdb) quit
The program is running. Exit anyway? (y or n) y
$ arm-eabi-g++ -v
Using built-in specs.
Target: arm-eabi
Configured with: /data/dougkwan/arm-elf/src/gcc-trunk/configure
--prefix=/data/dougkwan/arm-elf/install --target=arm-eabi
--build=i686-unknown-linux-gnu --host=i686-unknown-linux-gnu
--with-gmp=/home/dougkwan/gcc-lib/install
--with-mpfr=/home/dougkwan/gcc-lib/install --with-arch=armv5te
--enable-interwork --enable-multilib --with-newlib --with-gnu-as --with-gnu-ld
--enable-languages=c,c++
Thread model: single
gcc version 4.4.0 20090305 (experimental) (GCC)
This works fine in 4.2.x. The problem is that crtl->is_thunk is set during
thunk emission but is not not reset after. So target function of a thunk is
also emitted with crtl->is_thunk set. That cause the function to be emitted in
ARM mode. Below is part of the assembly output of the test above.
.section .text._ZN1D4foo2Ev,"axG",%progbits,_ZN1D4foo2Ev,comdat
.align 2
.weak _ZThn8_N1D4foo2Ev
.code 32
.type _ZThn8_N1D4foo2Ev, %function
_ZThn8_N1D4foo2Ev:
.fnstart
ldr r12, .LTHUMBFUNC0
sub r0, r0, #8
bx r12
.align 2
.LTHUMBFUNC0:
.word .LTHUNK0
.fnend
.size _ZThn8_N1D4foo2Ev, .-_ZThn8_N1D4foo2Ev
.align 2
.weak _ZN1D4foo2Ev
.code 32
.type _ZN1D4foo2Ev, %function
_ZN1D4foo2Ev:
.fnstart
.LFB3:
.save {r7, lr}
push {r7, lr}
.LCFI9:
sub sp, sp, #8
.LCFI10:
add r7, sp, #0
.LCFI11:
str r0, [r7, #4]
mov sp, r7
add sp, sp, #8
@ sp needed for prologue
pop {r7, pc}
.LFE3:
.cantunwind
.fnend
.size _ZN1D4foo2Ev, .-_ZN1D4foo2Ev
Note that the function _ZN1D4foo2Ev (unmangled as D::foo2()) is emitted in ARM
mode. However, in the typeinfo for B1, the function is marked as a THUMB
function.
_ZTI2B1:
.word _ZTVN10__cxxabiv117__class_type_infoE+8
.word _ZTS2B1
.thumb_set .LTHUNK0,_ZN1D4foo2Ev
I believe this problem can be fixed by saving and restoring crtl->is_thunk
around the call to the lang-hook callgraph.emit_associated_thunks in
cgraphunit.c
--
Summary: Multiple inheritence thunk not working with -mthumb
Product: gcc
Version: 4.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: dougkwan at google dot com
GCC build triplet: i686-unknown-linux-gnu
GCC host triplet: i686-unknown-linux-gnu
GCC target triplet: arm-eabi
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39378
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/39378] Multiple inheritence thunk not working with -mthumb
2009-03-05 4:47 [Bug middle-end/39378] New: Multiple inheritence thunk not working with -mthumb dougkwan at google dot com
@ 2009-03-11 23:30 ` ramana dot r at gmail dot com
2009-03-17 20:18 ` dougkwan at gcc dot gnu dot org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: ramana dot r at gmail dot com @ 2009-03-11 23:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from ramana dot r at gmail dot com 2009-03-11 23:30 -------
Patch submitted at http://gcc.gnu.org/viewcvs?view=rev&revision=143367
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39378
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/39378] Multiple inheritence thunk not working with -mthumb
2009-03-05 4:47 [Bug middle-end/39378] New: Multiple inheritence thunk not working with -mthumb dougkwan at google dot com
2009-03-11 23:30 ` [Bug middle-end/39378] " ramana dot r at gmail dot com
@ 2009-03-17 20:18 ` dougkwan at gcc dot gnu dot org
2009-03-17 20:20 ` dougkwan at google dot com
2009-03-17 21:22 ` ebotcazou at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: dougkwan at gcc dot gnu dot org @ 2009-03-17 20:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from dougkwan at gcc dot gnu dot org 2009-03-17 20:18 -------
Subject: Bug 39378
Author: dougkwan
Date: Tue Mar 17 20:18:21 2009
New Revision: 144918
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144918
Log:
2009-03-12 Jing Yu <jingyu@google.com>
PR middle-end/39378
* function.h: Move is_thunk from rtl_data structure to function
structure.
* cp/method.c (use_thunk): Change is_thunk from crtl to cfun.
* varasm.c (assemble_start_function): Change is_thunk from crtl to
cfun.
* config/alpha/alpha.c: Change is_thunk from crtl to cfun.
* config/rs6000/rs6000.c: Change is_thunk from crtl to cfun.
* config/arm/arm.h: Change is_thunk from crtl to cfun.
* testsuite/g++.dg/inherit/thunk10.C: New file.
Patch submitted by Doug Kwan <dougkwan@google.com>
Modified:
trunk/gcc/ChangeLog
trunk/gcc/config/alpha/alpha.c
trunk/gcc/config/arm/arm.h
trunk/gcc/config/rs6000/rs6000.c
trunk/gcc/cp/method.c
trunk/gcc/function.h
trunk/gcc/testsuite/ChangeLog
trunk/gcc/varasm.c
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39378
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/39378] Multiple inheritence thunk not working with -mthumb
2009-03-05 4:47 [Bug middle-end/39378] New: Multiple inheritence thunk not working with -mthumb dougkwan at google dot com
2009-03-11 23:30 ` [Bug middle-end/39378] " ramana dot r at gmail dot com
2009-03-17 20:18 ` dougkwan at gcc dot gnu dot org
@ 2009-03-17 20:20 ` dougkwan at google dot com
2009-03-17 21:22 ` ebotcazou at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: dougkwan at google dot com @ 2009-03-17 20:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from dougkwan at google dot com 2009-03-17 20:20 -------
Patch checked into trunk.
--
dougkwan at google dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39378
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug middle-end/39378] Multiple inheritence thunk not working with -mthumb
2009-03-05 4:47 [Bug middle-end/39378] New: Multiple inheritence thunk not working with -mthumb dougkwan at google dot com
` (2 preceding siblings ...)
2009-03-17 20:20 ` dougkwan at google dot com
@ 2009-03-17 21:22 ` ebotcazou at gcc dot gnu dot org
3 siblings, 0 replies; 5+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2009-03-17 21:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from ebotcazou at gcc dot gnu dot org 2009-03-17 21:22 -------
* cp/method.c (use_thunk): Change is_thunk from crtl to cfun.
in ChangeLog is incorrect. It should be
* method.c (use_thunk): Change is_thunk from crtl to cfun.
in cp/ChangeLog.
--
ebotcazou at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |ebotcazou at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39378
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-03-17 21:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-03-05 4:47 [Bug middle-end/39378] New: Multiple inheritence thunk not working with -mthumb dougkwan at google dot com
2009-03-11 23:30 ` [Bug middle-end/39378] " ramana dot r at gmail dot com
2009-03-17 20:18 ` dougkwan at gcc dot gnu dot org
2009-03-17 20:20 ` dougkwan at google dot com
2009-03-17 21:22 ` ebotcazou at gcc dot gnu dot org
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).