Bug 44561 - using nullptr_t with -flto/-fwhopr causes ICE: tree code 'lang_type' is not supported in gimple streams
Summary: using nullptr_t with -flto/-fwhopr causes ICE: tree code 'lang_type' is not s...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: 4.6.0
Assignee: Richard Biener
URL:
Keywords: lto
Depends on:
Blocks:
 
Reported: 2010-06-16 20:17 UTC by Zdenek Sojka
Modified: 2010-10-14 12:02 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-06-16 20:39:38


Attachments
WIP patch (1.01 KB, patch)
2010-10-11 09:51 UTC, Richard Biener
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2010-06-16 20:17:04 UTC
Command line:
$ g++ -std=gnu++0x -flto testcase.C
testcase.C:2:12: internal compiler error: tree code 'lang_type' is not supported in gimple streams

-------- testcase.C --------
typedef decltype(nullptr) nullptr_t;
nullptr_t a;
----------------------------

Tested revisions:
r160687 - crash
r159696 - crash
r159387 - crash
r158969 - nullptr is not recognized

The problem is that almost any code using C++0x mode fails to compile with -flto -fkeep-inline-functions.
Comment 1 Richard Biener 2010-06-16 20:39:37 UTC
Confirmed.

It isn't valid for LANG_TYPE node to leak to the middle-end.

gdb) call debug_tree (expr)
 <lang_type 0xb77a3180 nullptr_t unsigned SI
    size <integer_cst 0xb7722288 type <integer_type 0xb7739060 bit_size_type> constant 32>
    unit size <integer_cst 0xb77220c0 type <integer_type 0xb7739000 unsigned int> constant 4>
    align 8 symtab 0 alias set -1 canonical type 0xb7799000>
Comment 2 Richard Biener 2010-09-27 11:10:21 UTC
*** Bug 45789 has been marked as a duplicate of this bug. ***
Comment 3 Richard Biener 2010-10-10 13:31:30 UTC
This btw fails nearly all libstdc++ tests when built with -flto.  Jason, is
there no way to avoid lang_type to leak into the middle-end like this?
Why do we need to use lang_type for nullptr and cannot use void * with
some lang-specific flag?

This really breaks LTO badly for 4.6, so if it cannot be resolved in the FE
I guess I'll just drop all lang_type nodes at streaming time replacing
them with ptr_type_node (ugh).
Comment 4 Richard Biener 2010-10-10 13:53:08 UTC
Another way to handle it in LTO would be to simply stream LANG_TYPE, assuming
it must be completely opaque to the rest of the compiler anyway.  Probably
better than the ptr_type_node idea.  I will give that a try if no other ideas
pop up.
Comment 5 Richard Biener 2010-10-10 20:54:25 UTC
I have a patch.
Comment 6 Richard Biener 2010-10-11 09:30:57 UTC
New problems.

typedef decltype(nullptr) nullptr_t;
class shared_ptr {
public:
    shared_ptr(nullptr_t __p);
};
shared_ptr p = nullptr;

exposes a nullptr constant (INTEGER_CST of LANG_TYPE).  Of course
build_int_cst_wide doesn't like this at all.  From cp/decl.c:cxx_init_decl_processing():

    nullptr_node = make_node (INTEGER_CST);
    TREE_TYPE (nullptr_node) = nullptr_type_node;

:(

One more reason to make NULLPTR_TYPE a regular middle-end tree code.
Comment 7 Richard Biener 2010-10-11 09:51:19 UTC
Created attachment 22014 [details]
WIP patch

Work-in-progress for the just-stream-lang-type idea.  Adding odd LANG_TYPE
handling to the middle-end in various places.
Comment 8 Richard Biener 2010-10-14 11:59:50 UTC
Author: rguenth
Date: Thu Oct 14 11:59:47 2010
New Revision: 165462

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=165462
Log:
2010-10-14  Richard Guenther  <rguenther@suse.de>

	PR lto/44561
	* tree.def (NULLPTR_TYPE): New tree code.
	* dbxout.c (dbxout_type): Handle NULLPTR_TYPE.
	* dwarf2out.c (is_base_type): Likewise.
	(gen_type_die_with_usage): Likewise.
	* sdbout.c (plain_type_1): Likewise.
	* tree.c (build_int_cst_wide): Likewise.
	* gimple.c (gimple_types_compatible_p_1): NULLPTR_TYPE types
	are equal.

	cp/
	* cp-tree.h (NULLPTR_TYPE_P): Adjust.
	* decl.c (cxx_init_decl_processing): Build a NULLPTR_TYPE node,
	use build_int_cst.
	* error.c (dump_type): Handle NULLPTR_TYPE.
	(dump_type_prefix): Likewise.
	(dump_type_suffix): Likewise.
	* mangle.c (write_type): Likewise.
	* name-lookup.c (arg_assoc_type): Likewise.
	* rtti.c (typeinfo_in_lib_p): Likewise.
	* pt.c (tsubst): Likewise.

	* g++.dg/lto/20101010-3_0.C: New testcase.
	* g++.dg/lto/20101010-4_0.C: Likewise.

Added:
    trunk/gcc/testsuite/g++.dg/lto/20101010-3_0.C
    trunk/gcc/testsuite/g++.dg/lto/20101010-4_0.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/cp-tree.h
    trunk/gcc/cp/decl.c
    trunk/gcc/cp/error.c
    trunk/gcc/cp/mangle.c
    trunk/gcc/cp/name-lookup.c
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/rtti.c
    trunk/gcc/dbxout.c
    trunk/gcc/dwarf2out.c
    trunk/gcc/gimple.c
    trunk/gcc/sdbout.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree.c
    trunk/gcc/tree.def
Comment 9 Richard Biener 2010-10-14 12:02:34 UTC
Fixed.