public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/48623] gcc 4.6.0 generates no code for a function with __attribute__((always_inline))
2011-04-15 14:23 [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline)) richard at nod dot at
@ 2011-04-15 14:17 ` richard at nod dot at
2011-04-15 14:47 ` rguenth at gcc dot gnu.org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: richard at nod dot at @ 2011-04-15 14:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48623
--- Comment #1 from Richard Weinberger <richard at nod dot at> 2011-04-15 14:16:22 UTC ---
Created attachment 23995
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23995
Testcase for gcc 4.6.0
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline))
@ 2011-04-15 14:23 richard at nod dot at
2011-04-15 14:17 ` [Bug c/48623] " richard at nod dot at
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: richard at nod dot at @ 2011-04-15 14:23 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48623
Summary: gcc 4.6.0 generates no code for a function with
__attribute__((always_inline))
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: major
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: richard@nod.at
gcc 4.6.0 builds a non-functional User Mode Linux kernel.
It seems to optimize away the function sub_preempt_count() used in
kernel/softirq.c:__local_bh_enable().
Thus, the preempt counter gets out of balance and the kernel crashes.
A standalone test case is attached.
Just compile it with:
gcc testcase.c -Os -g -c -o testcase.o
Using objdump you can see that no code was generated for sub_preempt_count().
gcc 4.3, 4.4 and 4.5 generate code.
Without __attribute__((always_inline)) 4.6.0 produces code...
Thanks,
//richard
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/48623] gcc 4.6.0 generates no code for a function with __attribute__((always_inline))
2011-04-15 14:23 [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline)) richard at nod dot at
2011-04-15 14:17 ` [Bug c/48623] " richard at nod dot at
@ 2011-04-15 14:47 ` rguenth at gcc dot gnu.org
2011-04-15 14:53 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-15 14:47 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48623
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-15 14:46:32 UTC ---
Because current_thread_info() returns garbage (an address derived from an
address of a stack local).
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/48623] gcc 4.6.0 generates no code for a function with __attribute__((always_inline))
2011-04-15 14:23 [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline)) richard at nod dot at
2011-04-15 14:17 ` [Bug c/48623] " richard at nod dot at
2011-04-15 14:47 ` rguenth at gcc dot gnu.org
@ 2011-04-15 14:53 ` rguenth at gcc dot gnu.org
2011-04-15 17:35 ` richard at nod dot at
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-15 14:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48623
--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-15 14:52:04 UTC ---
Instead using
static inline struct thread_info *current_thread_info(void)
{
struct thread_info *ti;
void *p;
asm volatile ("" : "=r" (p) : "0" (&ti));
ti = (struct thread_info *) (((unsigned long) p) & ~mask);
return ti;
}
might confuse GCC enough and is still architecture independent.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/48623] gcc 4.6.0 generates no code for a function with __attribute__((always_inline))
2011-04-15 14:23 [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline)) richard at nod dot at
` (2 preceding siblings ...)
2011-04-15 14:53 ` rguenth at gcc dot gnu.org
@ 2011-04-15 17:35 ` richard at nod dot at
2011-04-15 17:38 ` richard at nod dot at
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: richard at nod dot at @ 2011-04-15 17:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48623
--- Comment #4 from Richard Weinberger <richard at nod dot at> 2011-04-15 17:34:33 UTC ---
Created attachment 24000
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24000
objdump of __local_bh_enable
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/48623] gcc 4.6.0 generates no code for a function with __attribute__((always_inline))
2011-04-15 14:23 [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline)) richard at nod dot at
` (3 preceding siblings ...)
2011-04-15 17:35 ` richard at nod dot at
@ 2011-04-15 17:38 ` richard at nod dot at
2011-04-15 17:39 ` richard at nod dot at
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: richard at nod dot at @ 2011-04-15 17:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48623
Richard Weinberger <richard at nod dot at> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |UNCONFIRMED
Resolution|INVALID |
--- Comment #5 from Richard Weinberger <richard at nod dot at> 2011-04-15 17:37:23 UTC ---
(In reply to comment #3)
It's not that easy.
Your trick solves the problem only for the test case.
Within the kernel again no code has been produced.
I have the objdump of the __local_bh_enable function attached.
See line 86.
Sorry for not providing a standalone test.
Here you can see the source code of __local_bh_enable, it's a pretty simple
function.
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=kernel/softirq.c;h=174f976c2874a19f1d06fee972468e2c730bc7f9;hb=HEAD#l134
Thanks,
//richard
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/48623] gcc 4.6.0 generates no code for a function with __attribute__((always_inline))
2011-04-15 14:23 [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline)) richard at nod dot at
` (4 preceding siblings ...)
2011-04-15 17:38 ` richard at nod dot at
@ 2011-04-15 17:39 ` richard at nod dot at
2011-04-15 20:13 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: richard at nod dot at @ 2011-04-15 17:39 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48623
--- Comment #6 from Richard Weinberger <richard at nod dot at> 2011-04-15 17:38:55 UTC ---
Created attachment 24001
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24001
objdump of __local_bh_enable
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/48623] gcc 4.6.0 generates no code for a function with __attribute__((always_inline))
2011-04-15 14:23 [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline)) richard at nod dot at
` (5 preceding siblings ...)
2011-04-15 17:39 ` richard at nod dot at
@ 2011-04-15 20:13 ` rguenth at gcc dot gnu.org
2011-04-15 20:26 ` richard at nod dot at
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-04-15 20:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48623
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2011.04.15 20:11:31
Ever Confirmed|0 |1
--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-04-15 20:11:31 UTC ---
Please provide preprocessed source for the translation unit that has the
broken function.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/48623] gcc 4.6.0 generates no code for a function with __attribute__((always_inline))
2011-04-15 14:23 [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline)) richard at nod dot at
` (6 preceding siblings ...)
2011-04-15 20:13 ` rguenth at gcc dot gnu.org
@ 2011-04-15 20:26 ` richard at nod dot at
2011-04-15 20:27 ` richard at nod dot at
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: richard at nod dot at @ 2011-04-15 20:26 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48623
--- Comment #8 from Richard Weinberger <richard at nod dot at> 2011-04-15 20:26:03 UTC ---
Created attachment 24006
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24006
preprocessed __local_bh_enable function
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/48623] gcc 4.6.0 generates no code for a function with __attribute__((always_inline))
2011-04-15 14:23 [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline)) richard at nod dot at
` (7 preceding siblings ...)
2011-04-15 20:26 ` richard at nod dot at
@ 2011-04-15 20:27 ` richard at nod dot at
2011-04-15 22:04 ` matz at gcc dot gnu.org
2011-04-15 22:28 ` richard at nod dot at
10 siblings, 0 replies; 12+ messages in thread
From: richard at nod dot at @ 2011-04-15 20:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48623
--- Comment #9 from Richard Weinberger <richard at nod dot at> 2011-04-15 20:26:48 UTC ---
Created attachment 24007
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24007
preprocessed softirq.c
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/48623] gcc 4.6.0 generates no code for a function with __attribute__((always_inline))
2011-04-15 14:23 [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline)) richard at nod dot at
` (8 preceding siblings ...)
2011-04-15 20:27 ` richard at nod dot at
@ 2011-04-15 22:04 ` matz at gcc dot gnu.org
2011-04-15 22:28 ` richard at nod dot at
10 siblings, 0 replies; 12+ messages in thread
From: matz at gcc dot gnu.org @ 2011-04-15 22:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48623
Michael Matz <matz at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
CC| |matz at gcc dot gnu.org
Resolution| |INVALID
--- Comment #10 from Michael Matz <matz at gcc dot gnu.org> 2011-04-15 22:03:05 UTC ---
You didn't change the current_thread_info carefully enough as per
comment #3. It still reads:
static inline __attribute__((always_inline)) struct thread_info
*current_thread_info(void)
{
struct thread_info *ti;
void *p;
unsigned long mask = ((1 << 0) * ((1UL) << 12)) - 1;
asm volatile ("" : "=r" (p) : "0" (&ti));
ti = (struct thread_info *) (((unsigned long) &ti) & ~mask);
return ti;
}
You have to make use of 'p' of course. Your return value still is based
on &ti.
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c/48623] gcc 4.6.0 generates no code for a function with __attribute__((always_inline))
2011-04-15 14:23 [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline)) richard at nod dot at
` (9 preceding siblings ...)
2011-04-15 22:04 ` matz at gcc dot gnu.org
@ 2011-04-15 22:28 ` richard at nod dot at
10 siblings, 0 replies; 12+ messages in thread
From: richard at nod dot at @ 2011-04-15 22:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48623
--- Comment #11 from Richard Weinberger <richard at nod dot at> 2011-04-15 22:27:19 UTC ---
(In reply to comment #10)
> You have to make use of 'p' of course. Your return value still is based
> on &ti.
Damn, you're right!
Now gcc produces a functional UML kernel. :-)
I fear current_thread_info() is not the only function in the kernel
which returns a local stack address.
Thanks,
//richard
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2011-04-15 22:28 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-15 14:23 [Bug c/48623] New: gcc 4.6.0 generates no code for a function with __attribute__((always_inline)) richard at nod dot at
2011-04-15 14:17 ` [Bug c/48623] " richard at nod dot at
2011-04-15 14:47 ` rguenth at gcc dot gnu.org
2011-04-15 14:53 ` rguenth at gcc dot gnu.org
2011-04-15 17:35 ` richard at nod dot at
2011-04-15 17:38 ` richard at nod dot at
2011-04-15 17:39 ` richard at nod dot at
2011-04-15 20:13 ` rguenth at gcc dot gnu.org
2011-04-15 20:26 ` richard at nod dot at
2011-04-15 20:27 ` richard at nod dot at
2011-04-15 22:04 ` matz at gcc dot gnu.org
2011-04-15 22:28 ` richard at nod dot at
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).