This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR42653
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 23 Apr 2010 16:19:26 +0200 (CEST)
- Subject: [PATCH] Fix PR42653
When generating debuginfo with LTO we need to be careful which
DECL_CONTEXT we are clearing. Especially we shouldn't change
a TYPE context to a DECL context.
Easiest is to just keep those for FUNCTION_DECLs like we do
for FIELD_DECLs.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2010-04-23 Richard Guenther <rguenther@suse.de>
PR lto/42653
* tree.c (free_lang_data_in_decl): Do not reset DECL_CONTEXT
of FUNCTION_DECLs.
* g++.dg/lto/20100423-1_0.C: New testcase.
Index: gcc/tree.c
===================================================================
*** gcc/tree.c (revision 158664)
--- gcc/tree.c (working copy)
*************** free_lang_data_in_decl (tree decl)
*** 4361,4367 ****
/* Ignore any intervening types, because we are going to clear their
TYPE_CONTEXT fields. */
! if (TREE_CODE (decl) != FIELD_DECL)
DECL_CONTEXT (decl) = decl_function_context (decl);
if (DECL_CONTEXT (decl)
--- 4361,4368 ----
/* Ignore any intervening types, because we are going to clear their
TYPE_CONTEXT fields. */
! if (TREE_CODE (decl) != FIELD_DECL
! && TREE_CODE (decl) != FUNCTION_DECL)
DECL_CONTEXT (decl) = decl_function_context (decl);
if (DECL_CONTEXT (decl)
Index: gcc/testsuite/g++.dg/lto/20100423-1_0.C
===================================================================
*** gcc/testsuite/g++.dg/lto/20100423-1_0.C (revision 0)
--- gcc/testsuite/g++.dg/lto/20100423-1_0.C (revision 0)
***************
*** 0 ****
--- 1,38 ----
+ // { dg-lto-do assemble }
+ // { dg-lto-options {{-g -flto}} }
+
+ namespace llvm
+ {
+ class Function;
+ class MachineCodeInfo;
+ class ExecutionEngine
+ {
+ };
+ class JIT : public ExecutionEngine
+ {
+ void runJITOnFunction (Function * F, MachineCodeInfo * MCI = 0);
+ };
+ class JITEventListener
+ {
+ public:
+ JITEventListener ()
+ {
+ }
+ virtual ~JITEventListener ();
+ };
+ }
+
+ using namespace llvm;
+ void
+ JIT::runJITOnFunction (Function * F, MachineCodeInfo * MCI)
+ {
+ class MCIListener:public JITEventListener
+ {
+ MachineCodeInfo *const MCI;
+ public:
+ MCIListener (MachineCodeInfo * mci):MCI (mci)
+ {
+ }
+ };
+ }
+