This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/50741] [4.7 Regression] remove_unused_locals causes seg fault
- From: "rguenth at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 18 Oct 2011 11:00:49 +0000
- Subject: [Bug middle-end/50741] [4.7 Regression] remove_unused_locals causes seg fault
- Auto-submitted: auto-generated
- References: <bug-50741-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50741
Richard Guenther <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hubicka at gcc dot gnu.org,
| |jakub at gcc dot gnu.org
--- Comment #7 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-10-18 11:00:49 UTC ---
Bootstraps and tests ok. But I suppose with BLOCK_NONLOCAL_VARS we could
refer to an inlined functions static vars, and their initializer could refer
to static vars from the inlined function that are otherwise unused.
int foo()
{
static volatile int i;
static volatile int * volatile p = &i;
return *p;
}
int bar()
{
return foo();
}
when foo is inlined into bar. And indeed with the patch we get
{ Scope block 0x7ffff5b3ac30#0
{ Scope block 0x7ffff5b950a0#2 t.c:10 Originating from : static intD.6
fooD.1604 ();
{ Scope block 0x7ffff5b950f0#3 Originating from : 0x7ffff5b3ab90#0
static volatile intD.6 i.1606D.1606; (nonlocalized)
static volatile intD.6 * volatile p.1607D.1607 = &i.1606D.1606;
(nonlocalized)
}
}
}
bar ()
{
volatile intD.6 * volatile p.0D.2736;
intD.6 D.2735;
# BLOCK 2 freq:10000
# PRED: ENTRY [100.0%] (fallthru,exec)
# VUSE <.MEMD.2734_2(D)>
# PT = nonlocal escaped
p.0D.2736_4 ={v} p.1607D.1607;
# VUSE <.MEMD.2734_2(D)>
D.2735_5 ={v} *p.0D.2736_4;
# VUSE <.MEMD.2734_2(D)>
return D.2735_5;
while without we get
Scope blocks after cleanups:
{ Scope block 0x7ffff5b3ac30#0
{ Scope block 0x7ffff5b950a0#2 t.c:10 Originating from : static intD.6
fooD.1604 ();
{ Scope block 0x7ffff5b950f0#3 Originating from : 0x7ffff5b3ab90#0
static volatile intD.6 i.1606D.1606; (nonlocalized)
static volatile intD.6 * volatile p.1607D.1607 = &i.1606D.1606;
(nonlocalized)
}
}
bar ()
{
volatile intD.6 * volatile p.0D.2736;
static volatile intD.6 iD.1606;
static volatile intD.6 * volatile p.1607D.1607 = &iD.1606;
intD.6 D.2735;
static volatile intD.6 * volatile p.1607D.1607 = &iD.1606;
static volatile intD.6 iD.1606;
# BLOCK 2 freq:10000
# PRED: ENTRY [100.0%] (fallthru,exec)
# VUSE <.MEMD.2734_2(D)>
# PT = nonlocal escaped
p.0D.2736_4 ={v} p.1607D.1607;
# VUSE <.MEMD.2734_2(D)>
D.2735_5 ={v} *p.0D.2736_4;
# VUSE <.MEMD.2734_2(D)>
return D.2735_5;
# SUCC: EXIT [100.0%]
so there is a difference in what local_decls contains. Not sure if that
is important though.