Bug 65908 - [5 Regression] ICE: in expand_thunk, at cgraphunit.c:1700
Summary: [5 Regression] ICE: in expand_thunk, at cgraphunit.c:1700
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: ipa (show other bugs)
Version: 5.1.0
: P2 normal
Target Milestone: 5.3
Assignee: Martin Liška
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-27 17:34 UTC by Mark M.
Modified: 2016-03-16 02:59 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.9.2, 6.0
Known to fail: 5.1.0
Last reconfirmed: 2015-04-27 00:00:00


Attachments
-save-temps generated output (240.75 KB, application/x-gzip)
2015-04-27 17:34 UTC, Mark M.
Details
Suggested fix (1.20 KB, application/mbox)
2015-05-12 14:08 UTC, Martin Liška
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mark M. 2015-04-27 17:34:10 UTC
Created attachment 35408 [details]
-save-temps generated output

Greetings.

In an attempt to compile the CVC4 SMT solver using GCC 5.1.0, the following error occurs:

/bin/bash ../../libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H -I. -I/home/marky/source/CVC4/builds/x86_64-unknown-linux-gnu/production-cln-glpk/../../../src/compat -I../..  -D__BUILDING_CVC4COM
PATLIB -I./.. -I/usr/local/include -I/home/marky/source/CVC4/builds/x86_64-unknown-linux-gnu/production-cln-glpk/../../../src/compat/../include -I/home/marky/source/CVC4/builds/x86_64-unknown-linux-gnu/p
roduction-cln-glpk/../../../src/compat/.. -pthread -I/usr/local/include   -DCVC4_STATISTICS_ON -DNDEBUG -DCVC4_DUMPING -I/home/marky/source/CVC4/glpk-cut-log/include -DCVC4_USE_GLPK -DCVC4_ANTLR3_OLD_INP
UT_STREAM -fno-strict-aliasing -I/usr/local/include   -O3 -ggdb3 -Wno-deprecated -MT libcvc4compat_la-cvc3_compat.lo -MD -MP -MF .deps/libcvc4compat_la-cvc3_compat.Tpo -c -o libcvc4compat_la-cvc3_compat.
lo `test -f 'cvc3_compat.cpp' || echo '/home/marky/source/CVC4/builds/x86_64-unknown-linux-gnu/production-cln-glpk/../../../src/compat/'`cvc3_compat.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I. -I/home/marky/source/CVC4/builds/x86_64-unknown-linux-gnu/production-cln-glpk/../../../src/compat -I../.. -D__BUILDING_CVC4COMPATLIB -I./.. -I/usr/local/include
 -I/home/marky/source/CVC4/builds/x86_64-unknown-linux-gnu/production-cln-glpk/../../../src/compat/../include -I/home/marky/source/CVC4/builds/x86_64-unknown-linux-gnu/production-cln-glpk/../../../src/co
mpat/.. -pthread -I/usr/local/include -DCVC4_STATISTICS_ON -DNDEBUG -DCVC4_DUMPING -I/home/marky/source/CVC4/glpk-cut-log/include -DCVC4_USE_GLPK -DCVC4_ANTLR3_OLD_INPUT_STREAM -fno-strict-aliasing -I/us
r/local/include -O3 -ggdb3 -Wno-deprecated -MT libcvc4compat_la-cvc3_compat.lo -MD -MP -MF .deps/libcvc4compat_la-cvc3_compat.Tpo -c /home/marky/source/CVC4/builds/x86_64-unknown-linux-gnu/production-cl$
-glpk/../../../src/compat/cvc3_compat.cpp  -fPIC -DPIC -o .libs/libcvc4compat_la-cvc3_compat.o
/home/marky/source/CVC4/builds/x86_64-unknown-linux-gnu/production-cln-glpk/../../../src/compat/cvc3_compat.cpp: In member function 'std::__cxx11::string CVC3::Expr::getUid() const':
/home/marky/source/CVC4/builds/x86_64-unknown-linux-gnu/production-cln-glpk/../../../src/compat/cvc3_compat.cpp:2552:1: internal compiler error: in expand_thunk, at cgraphunit.c:1700
 }/* CVC3 namespace */
 ^
0x7c0fc6 cgraph_node::expand_thunk(bool, bool)
        ../.././gcc/cgraphunit.c:1699
0x7c2b5b cgraph_node::create_wrapper(cgraph_node*)
        ../.././gcc/cgraphunit.c:2517
0xff15b9 ipa_icf::sem_function::merge(ipa_icf::sem_item*)
        ../.././gcc/ipa-icf.c:1133
0xfe95ef ipa_icf::sem_item_optimizer::merge_classes(unsigned int)
        ../.././gcc/ipa-icf.c:3232
0xff0f6c ipa_icf::sem_item_optimizer::execute()
        ../.././gcc/ipa-icf.c:2436
0xff26e6 ipa_icf_driver
        ../.././gcc/ipa-icf.c:3309
0xff26e6 ipa_icf::pass_ipa_icf::execute(function*)
        ../.././gcc/ipa-icf.c:3356
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

Release: g++ (GCC) 5.1.0
System: Debian 8.0 jessie (3.16.0-4-amd64)
CFLAGS as found in configured Makefile for CVC4:
Comment 1 Mark M. 2015-04-27 17:47:51 UTC
g++ version info

% g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/5.1.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --enable-lto --enable-libssp --enable-vtable-verify
Thread model: posix
gcc version 5.1.0 (GCC)
Comment 2 Markus Trippelsdorf 2015-04-27 17:59:00 UTC
markus@x4 tmp % cat cvc3_compat.ii
class A
{
  A (A &);
};
class B
{
  const A &m_fn1 () const;
};
class C
{
  A m_fn2 () const;
};
A
C::m_fn2 () const
{
  throw 0;
}
const A &
B::m_fn1 () const
{
  throw 0;
}

markus@x4 tmp % g++ -O2 -fPIC -c cvc3_compat.ii
cvc3_compat.ii: In member function ‘A C::m_fn2() const’:
cvc3_compat.ii:22:1: internal compiler error: in expand_thunk, at cgraphunit.c:1700
Comment 3 Jakub Jelinek 2015-04-27 22:29:55 UTC
Started with r217218.
Comment 4 Jakub Jelinek 2015-04-27 23:09:34 UTC
The problem is that IPA ICF compares the return type and argument types by looking at TREE_TYPE of DECL_RESULT (or PARM_DECLs from DECL_ARGUMENTS), but
that is modified by cp_genericize.
So, either in addition to comparing the types it should also compare
DECL_BY_REFERENCE values of RESULT_DECL and PARM_DECLs, or it should also (or only?) look at TREE_TYPE of the FUNCTION_TYPE/METHOD_TYPE and/or TYPE_ARG_TYPES of that).
Comment 5 Jan Hubicka 2015-05-11 11:50:42 UTC
Yep, I suppose we want to match both (TREE_TYPE/TYPE_ARG_TYPES and the decls since both control how calls.c produce code and should agree in equivalent functions anyway. I will look into why TREE_TYPE (fntype) and TREE_TYPE (result_decl) disagreees.
Comment 6 Martin Liška 2015-05-11 13:59:09 UTC
(In reply to Jan Hubicka from comment #5)
> Yep, I suppose we want to match both (TREE_TYPE/TYPE_ARG_TYPES and the decls
> since both control how calls.c produce code and should agree in equivalent
> functions anyway. I will look into why TREE_TYPE (fntype) and TREE_TYPE
> (result_decl) disagreees.

OK, I'm going to write a patch that will match both.

Martin
Comment 7 Martin Liška 2015-05-12 14:08:40 UTC
Created attachment 35533 [details]
Suggested fix

I've been testing following patch for 5.1.0 branch. I'm wondering if comparison of just TYPE_ARG_TYPES is sufficient?
Comment 8 Jan Hubicka 2015-05-12 19:44:33 UTC
I think pushing TYPE_CANONICAL is a bug: we do check ODR properties of the parameter and TYPE_CANONICAL is not guaranteed to be the same. Just remove the TYPE_CANONICAL wrap here.

The patch seems OK with this change both for mainline and branch. We will match the types of DECL_ARGUMENTS when verifying the body here:

  for (arg1 = DECL_ARGUMENTS (decl),
       arg2 = DECL_ARGUMENTS (m_compared_func->decl);
       arg1; arg1 = DECL_CHAIN (arg1), arg2 = DECL_CHAIN (arg2))
    if (!m_checker->compare_decl (arg1, arg2))
      return return_false ();

However I think there is one extra case to deal with. For functions that are !prototype_p, we get empty ARG_TYPES and only have ARGUMENTS. Such functions will bypass the checks:

      if (POINTER_TYPE_P (arg_types[i])
          && (TYPE_RESTRICT (arg_types[i]) 
              != TYPE_RESTRICT (m_compared_func->arg_types[i])))
        return return_false_with_msg ("argument restrict flag mismatch");
      /* nonnull_arg_p implies non-zero range to REFERENCE types.  */
      if (POINTER_TYPE_P (arg_types[i])
          && TREE_CODE (arg_types[i])
             != TREE_CODE (m_compared_func->arg_types[i])
          && opt_for_fn (decl, flag_delete_null_pointer_checks))
        return return_false_with_msg ("pointer wrt reference mismatch");

Please factor out this code to a function compatible_parm_types_p and call it both from sem_function::equals_wpa and the loop above.

Honza
Comment 9 Jakub Jelinek 2015-06-17 13:24:15 UTC
Any progress on this?  This is a P1 and we'd like to release GCC 5.2 soon.
Comment 10 Martin Liška 2015-06-17 13:29:03 UTC
There's pending patch in ML:
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00746.html

I'm going to ping Honza.
Comment 11 Jan Hubicka 2015-06-22 07:12:55 UTC
Author: hubicka
Date: Mon Jun 22 07:12:22 2015
New Revision: 224720

URL: https://gcc.gnu.org/viewcvs?rev=224720&root=gcc&view=rev
Log:

	PR ipa/65908
	* ipa-icf.c (sem_item::target_supports_symbol_aliases): Remove
	construction of arg_types.
	(sem_function::sem_function): Likewise.
	(sem_function::~sem_function): Remove destruction of arg_types.
	(sem_function::compatible_parm_types_p): New function.
	(sem_function::equals_wpa): Reorg matching of return values
	and parameter types.
	(sem_function::equals_private): Reorg mathcing of argument types.
	(sem_function::parse_tree_args): Remove.
	* ipa-icf.h (init_wpa): Do not call it.
	(parse_tree_args): Remove.
	(compatible_parm_types_p): Declare.
	(result_type): Remove.
	(arg_types): Remove.
	* testsuite/g++.dg/ipa/pr65908.C: New testcase.

Added:
    trunk/gcc/testsuite/g++.dg/ipa/pr65908.C
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-icf.c
    trunk/gcc/ipa-icf.h
    trunk/gcc/testsuite/ChangeLog
Comment 12 Richard Biener 2015-07-03 09:11:22 UTC
Fixed on trunk sofar.  Not sure why this is P1, downgrading to P2.
Comment 13 Richard Biener 2015-07-16 09:12:39 UTC
GCC 5.2 is being released, adjusting target milestone to 5.3.
Comment 14 Richard Biener 2015-11-20 12:43:11 UTC
Martin or Honza, can you work on a backport please?
Comment 15 Martin Liška 2015-11-20 12:47:43 UTC
I will prepare backport.

Martin
Comment 16 Martin Liška 2015-11-23 13:59:11 UTC
Author: marxin
Date: Mon Nov 23 13:58:40 2015
New Revision: 230756

URL: https://gcc.gnu.org/viewcvs?rev=230756&root=gcc&view=rev
Log:
PR ipa/65908

	* ipa-icf.c (sem_item::target_supports_symbol_aliases): Remove
	construction of arg_types.
	(sem_function::sem_function): Likewise.
	(sem_function::~sem_function): Remove destruction of arg_types.
	(sem_function::compatible_parm_types_p): New function.
	(sem_function::equals_wpa): Reorg matching of return values
	and parameter types.
	(sem_function::equals_private): Reorg mathcing of argument types.
	(sem_function::parse_tree_args): Remove.
	(sem_function::param_used_p): New function.
	* ipa-icf.h (init_wpa): Do not call it.
	(parse_tree_args): Remove.
	(compatible_parm_types_p): Declare.
	(result_type): Remove.
	(arg_types): Remove.
	(param_used_p): Declare.
	* g++.dg/ipa/pr65908.C: New testcase.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/ipa/pr65908.C
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/ipa-icf.c
    branches/gcc-5-branch/gcc/ipa-icf.h
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
Comment 17 Martin Liška 2015-11-23 13:59:54 UTC
Fixed in gcc-5-branch.
Comment 18 Arthur Rodrigues 2016-03-16 02:59:28 UTC
I'm using GCC 5.2.1 and the same happened to me just now.

Above is the output from `gcc -v` command:

====
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.2.1-22ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.2.1 20151010 (Ubuntu 5.2.1-22ubuntu2)
====