Created attachment 27289 [details] directory with two source files from real-life code after pre-processor difficult (for what I'm concerned)to reduce more tar -xzf ltobug1.tgz [innocent@vinavx0 ~/w3]$ c++ -O2 -flto -std=c++0x -shared -fPIC -o bha.so ltobug1/*.cc In file included from :352:0: /afs/cern.ch/user/i/innocent/w3/gcc47slc5/include/c++/4.8.0/bits/stl_tree.h: In function '_ZNSt8_Rb_treeISsSt4pairIKSsN17PerformanceResult10ResultTypeEESt10_Select1stIS4_ESt4lessISsESaIS4_EE14_M_lower_boundEPSt13_Rb_tree_nodeIS4_ESD_RS1_.isra.197.17998.constprop.1309': /afs/cern.ch/user/i/innocent/w3/gcc47slc5/include/c++/4.8.0/bits/stl_tree.h:1093:5: internal compiler error: Segmentation fault _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: ^ Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. lto-wrapper: c++ returned 1 exit status collect2: error: lto-wrapper returned 1 exit status [innocent@vinavx0 ~/w3]$ c++ -v Using built-in specs. COLLECT_GCC=c++ COLLECT_LTO_WRAPPER=/afs/cern.ch/user/i/innocent/w2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ./configure --prefix=/afs/cern.ch/user/i/innocent/w2 --enable-languages=c,c++,fortran -enable-gold=yes --enable-lto --with-build-config=bootstrap-lto --with-gmp-lib=/usr/local/lib64 --with-mpfr-lib=/usr/local/lib64 -with-mpc-lib=/usr/local/lib64 --enable-cloog-backend=isl --with-cloog=/usr/local --with-ppl-lib=/usr/local/lib64 CFLAGS='-O2 -ftree-vectorize -fPIC' CXXFLAGS='-O2 -fPIC -ftree-vectorize -fvisibility-inlines-hidden -march=native' -enable-libitm -disable-multilib Thread model: posix gcc version 4.8.0 20120428 (experimental) [trunk revision 186932] (GCC)
does not happen with latest version of gcc version 4.7.1 20120504 (prerelease) (GCC)
I cannot reproduce it with trunk rev. 187148. Can you re-check?
effectively… (verified before doing svn update, was still crashing!) c++ -O2 -flto -std=c++0x -shared -fPIC -o bha.so ltobug1/*.cc [innocent@vinavx0 ~/w3]$ c++ -v Using built-in specs. COLLECT_GCC=c++ COLLECT_LTO_WRAPPER=/afs/cern.ch/user/i/innocent/w2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ./configure --prefix=/afs/cern.ch/user/i/innocent/w2 --enable-languages=c,c++,fortran -enable-gold=yes --enable-lto --with-build-config=bootstrap-lto --with-gmp-lib=/usr/local/lib64 --with-mpfr-lib=/usr/local/lib64 -with-mpc-lib=/usr/local/lib64 --enable-cloog-backend=isl --with-cloog=/usr/local --with-ppl-lib=/usr/local/lib64 CFLAGS='-O2 -ftree-vectorize -fPIC' CXXFLAGS='-O2 -fPIC -ftree-vectorize -fvisibility-inlines-hidden -march=native' -enable-libitm -disable-multilib Thread model: posix gcc version 4.8.0 20120504 (experimental) [trunk revision 187149] (GCC)
Created attachment 27308 [details] directory with three source files from real-life code after pre-processor
found a different place where it happens: requires three files to segfault… with gcc version 4.8.0 20120504 (experimental) [trunk revision 187149] (GCC) and gcc version 4.7.1 20120504 (prerelease) [gcc-4_7-branch revision 187154] (GCC) bzip2 -d ltoBug2.tar.bz2 ; tar -xf ltoBug2.tar [innocent@vinavx0 ~/w3]$ c++ -O2 -flto -std=c++0x -shared -fPIC -o bha.so ltoBug2/*.cc In file included from :834:0: /afs/cern.ch/user/i/innocent/w3/gcc47slc5/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/../../../../include/c++/4.7.1/bits/stl_tree.h: In function '_ZNSt8_Rb_treeISsSt4pairIKSsN3pat17CandKinResolution15ParametrizationEESt10_Select1stIS5_ESt4lessISsESaIS5_EE14_M_lower_boundEPSt13_Rb_tree_nodeIS5_ESE_RS1_.isra.129.11169.constprop.1554': /afs/cern.ch/user/i/innocent/w3/gcc47slc5/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/../../../../include/c++/4.7.1/bits/stl_tree.h:1093:5: internal compiler error: Segmentation fault _Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>:: ^ Please submit a full bug report,
and gdb gdb /afs/cern.ch/user/i/innocent/w2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto1 -dumpdir ./ -dumpbase bha.so.ltrans8 -mtune=generic -march=x86-64 -mtune=generic -march=x86-64 -auxbase-strip bha.so.ltrans8.ltrans.o -O2 -version -fexceptions -fPIC -fltrans @/tmp/innocent/cc6htdxw -o bha.so.ltrans8.s gdb: unrecognized option '-dumpdir' Use `gdb --help' for a complete list of options. [innocent@vinavx0 ~/w3]$ gdb /afs/cern.ch/user/i/innocent/w2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto1 GNU gdb (GDB) Red Hat Enterprise Linux (7.2-50.el6) Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-redhat-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>... Reading symbols from /afs/cern.ch/user/i/innocent/w2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto1...done. (gdb) run -dumpdir ./ -dumpbase bha.so.ltrans8 -mtune=generic -march=x86-64 -mtune=generic -march=x86-64 -auxbase-strip bha.so.ltrans8.ltrans.o -O2 -version -fexceptions -fPIC -fltrans @/tmp/innocent/cc6htdxw -o bha.so.ltrans8.s Starting program: /afs/cern.ch/user/i/innocent/w2/libexec/gcc/x86_64-unknown-linux-gnu/4.8.0/lto1 -dumpdir ./ -dumpbase bha.so.ltrans8 -mtune=generic -march=x86-64 -mtune=generic -march=x86-64 -auxbase-strip bha.so.ltrans8.ltrans.o -O2 -version -fexceptions -fPIC -fltrans @/tmp/innocent/cc6htdxw -o bha.so.ltrans8.s reading VI .tcshrc tty resize: Command not found. GNU GIMPLE (GCC) version 4.8.0 20120504 (experimental) [trunk revision 187149] (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.0 20120504 (experimental) [trunk revision 187149], GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 GNU GIMPLE (GCC) version 4.8.0 20120504 (experimental) [trunk revision 187149] (x86_64-unknown-linux-gnu) compiled by GNU C version 4.8.0 20120504 (experimental) [trunk revision 187149], GMP version 4.3.2, MPFR version 2.4.2, MPC version 0.8.1 GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096 options passed: -mtune=generic -march=x86-64 -mtune=generic -march=x86-64 -auxbase-strip bha.so.ltrans8.ltrans.o -O2 -fexceptions -fPIC -fltrans bha.so.ltrans8.o options enabled: -fPIC -falign-labels -fasynchronous-unwind-tables -fauto-inc-dec -fbranch-count-reg -fcaller-saves -fcombine-stack-adjustments -fcommon -fcompare-elim -fcprop-registers -fcrossjumping -fcse-follow-jumps -fdefer-pop -fdelete-null-pointer-checks -fdevirtualize -fdwarf2-cfi-asm -fearly-inlining -feliminate-unused-debug-types -fexceptions -fexpensive-optimizations -fforward-propagate -ffunction-cse -fgcse -fgcse-lm -fgnu-runtime -fguess-branch-probability -fident -fif-conversion -fif-conversion2 -findirect-inlining -finline -finline-atomics -finline-functions-called-once -finline-small-functions -fipa-cp -fipa-profile -fipa-pure-const -fipa-reference -fipa-sra -fira-share-save-slots -fira-share-spill-slots -fivopts -fkeep-static-consts -fleading-underscore -fltrans -fmath-errno -fmerge-constants -fmerge-debug-strings -fmove-loop-invariants -fomit-frame-pointer -foptimize-register-move -foptimize-sibling-calls -foptimize-strlen -fpartial-inlining -fpeephole -fpeephole2 -fprefetch-loop-arrays -free -freg-struct-return -fregmove -freorder-blocks -freorder-functions -frerun-cse-after-loop -fsched-critical-path-heuristic -fsched-dep-count-heuristic -fsched-group-heuristic -fsched-interblock -fsched-last-insn-heuristic -fsched-rank-heuristic -fsched-spec -fsched-spec-insn-heuristic -fsched-stalled-insns-dep -fschedule-insns2 -fshow-column -fshrink-wrap -fsigned-zeros -fsplit-ivs-in-unroller -fsplit-wide-types -fstrict-aliasing -fstrict-overflow -fstrict-volatile-bitfields -fsync-libcalls -fthread-jumps -ftoplevel-reorder -ftrapping-math -ftree-bit-ccp -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copy-prop -ftree-copyrename -ftree-cselim -ftree-dce -ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre -ftree-loop-if-convert -ftree-loop-im -ftree-loop-ivcanon -ftree-loop-optimize -ftree-parallelize-loops= -ftree-phiprop -ftree-pre -ftree-pta -ftree-reassoc -ftree-scev-cprop -ftree-sink -ftree-slp-vectorize -ftree-sra -ftree-switch-conversion -ftree-tail-merge -ftree-ter -ftree-vect-loop-version -ftree-vrp -funit-at-a-time -funwind-tables -fvar-tracking -fvar-tracking-assignments -fvect-cost-model -fzero-initialized-in-bss -m128bit-long-double -m64 -m80387 -maccumulate-outgoing-args -malign-stringops -mfancy-math-387 -mfp-ret-in-387 -mglibc -mieee-fp -mmmx -mno-sse4 -mpush-args -mred-zone -msse -msse2 -mtls-direct-seg-refs Reading object files: bha.so.ltrans8.o Reading the callgraph Merging declarations Reading summaries Reading function bodies: __copy_move_b __copy_move_backward_a2 move_backward __insertion_sort _ZNSt8_Rb_treeISsSt4pairIKSsN3pat17CandKinResolution15ParametrizationEESt10_Select1stIS5_ESt4lessISsESaIS5_EE14_M_lower_boundEPSt13_Rb_tree_nodeIS5_ESE_RS1_.isra.129 _ZNK9StringMap13MatchByStringclERKSt4pairISsiERKSs.isra.9 lower_bound compare operator< operator< operator= __push_heap _M_dispose __base_dtor __base_dtor __adjust_heap _ZNSt12_Vector_baseIN3edm3PtrIN4reco9CandidateEEESaIS4_EE13_M_deallocateEPS4_m.isra.215 __base_dtor __base_dtor _ZNSt12_Vector_baseIiSaIiEE13_M_deallocateEPim.isra.163 __base_dtor __base_dtor _ZNSt12_Vector_baseIfSaIfEE13_M_deallocateEPfm.isra.171 __base_dtor __base_dtor _ZNSt12_Vector_baseIN3edm3RefISt6vectorIN4reco11GenParticleESaIS4_EES4_NS0_9refhelper16FindUsingAdvanceIS6_S4_EEEESaISA_EE13_M_deallocateEPSA_m.isra.192 __base_dtor __base_dtor _ZNSt12_Vector_baseISsSaISsEE13_M_deallocateEPSsm.isra.131 __base_dtor __base_dtor _ZNSt12_Vector_baseIN3pat17LookupTableRecordESaIS1_EE13_M_deallocateEPS1_m.isra.184 __base_dtor __base_dtor __base_dtor __deleting_dtor __base_dtor __deleting_dtor operator[] daughter __base_ctor operator* getProduct getPtr_ operator* deref deref Performing interprocedural optimizations Assembling functions: deref daughter __base_dtor __deleting_dtor __base_dtor __deleting_dtor __adjust_heap lower_bound _ZNSt8_Rb_treeISsSt4pairIKSsN3pat17CandKinResolution15ParametrizationEESt10_Select1stIS5_ESt4lessISsESaIS5_EE14_M_lower_boundEPSt13_Rb_tree_nodeIS5_ESE_RS1_.isra.129.11169.constprop.1554 Program received signal SIGSEGV, Segmentation fault. set_is_used (tp=Unhandled dwarf expression opcode 0xf3 ) at ../.././gcc/tree-flow-inline.h:567 567 ann->used = true; Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.47.el6_2.9.x86_64 (gdb) where #0 set_is_used (tp=Unhandled dwarf expression opcode 0xf3 ) at ../.././gcc/tree-flow-inline.h:567 #1 mark_all_vars_used_1 (tp=Unhandled dwarf expression opcode 0xf3 ) at ../.././gcc/tree-ssa-live.c:380 #2 0x00000000009e933c in walk_tree_1 (tp=0x7ffff6339c78, func=0x8db9f0 <mark_all_vars_used_1(tree*, int*, void*)>, data=0x0, pset=0x0, lh=0) at ../.././gcc/tree.c:10538 #3 0x00000000009e9ade in walk_tree_1 (tp=0x7ffff6339c50, func=0x8db9f0 <mark_all_vars_used_1(tree*, int*, void*)>, data=0x0, pset=0x0, lh=0) at ../.././gcc/tree.c:10794 #4 0x00000000008dc6c6 in mark_all_vars_used () at ../.././gcc/tree-ssa-live.c:596 #5 remove_unused_locals () at ../.././gcc/tree-ssa-live.c:755 #6 remove_unused_locals () at ../.././gcc/tree-ssa-live.c:685 #7 0x0000000000753af5 in execute_function_todo (data=Unhandled dwarf expression opcode 0xf3 ) at ../.././gcc/passes.c:1809 #8 0x000000000075484e in execute_todo (flags=2132516) at ../.././gcc/passes.c:1858 #9 0x0000000000756f4b in execute_one_ipa_transform_pass () at ../.././gcc/passes.c:2036 #10 execute_all_ipa_transforms () at ../.././gcc/passes.c:2064 #11 0x000000000054322f in expand_function (node=0x7ffff62ae3a8) at ../.././gcc/cgraphunit.c:1591 #12 0x0000000000545fe3 in expand_all_functions () at ../.././gcc/cgraphunit.c:1703 #13 compile () at ../.././gcc/cgraphunit.c:2368 #14 compile () at ../.././gcc/cgraphunit.c:2291 #15 0x00000000004c37aa in _Z8lto_mainv.part.19 () at ../.././gcc/lto/lto.c:2119 #16 lto_main () at ../.././gcc/lto/lto.c:2097 #17 0x00000000007fc430 in compile_file (argc=19, argv=0x12ac480) at ../.././gcc/toplev.c:551 #18 do_compile (argc=19, argv=0x12ac480) at ../.././gcc/toplev.c:1874 #19 toplev_main (argc=19, argv=0x12ac480) at ../.././gcc/toplev.c:1950 #20 0x00007ffff6d6bfbd in __libc_start_main (main=0x4d35a0 <main(int, char**)>, argc=19, ubp_av=0x7fffffffda38, init=<value optimized out>, fini=<value optimized out>, rtld_fini=<value optimized out>, stack_end=0x7fffffffda28) at libc-start.c:226 #21 0x00000000004a9ca9 in _start () (gdb)
Can you possibly identify a set of files that reproduces the error with -flto-partition=1to1? Confirmed at least.
We are walking the PHI argument &MEM[(struct map *)&parMaps + 8B] of __y_7 = PHI <&MEM[(struct map *)&parMaps + 8B](2), __y_9(13)> in the function _ZNSt8_Rb_treeISsSt4pairIKSsN3pat17CandKinResolution15ParametrizationEESt10_Select1stIS5_ESt4lessISsESaIS5_EE14_M_lower_boundEPSt13_Rb_tree_nodeIS5_ESE_RS1_.isra.129.11161.constprop.1554 where parMaps is a non-automatic variable declared in fromString. It has no doubtly being IPA constant propagated. The variable is <var_decl 0x7ffff587d6e0 parMaps type <record_type 0x7ffff5c13000 map addressable needs-constructing BLK ... addressable used public external BLK file /build/vin/CMSSW_6_0_X_2012-05-03-0200/src/DataFormats/PatCandidates/src/ParametrizationHelper.cc line 20 col 40 size <integer_cst 0x7ffff5c03660 384> unit size <integer_cst 0x7ffff5c036a0 48> align 256 context <function_decl 0x7ffff5901100 fromString>> The issue is we do not properly record referenced vars that come in from paramter initializers during inlining. Tentative patch: Index: gcc/tree-flow.h =================================================================== --- gcc/tree-flow.h (revision 187228) +++ gcc/tree-flow.h (working copy) @@ -499,6 +499,7 @@ extern bool stmt_references_abnormal_ssa extern tree get_ref_base_and_extent (tree, HOST_WIDE_INT *, HOST_WIDE_INT *, HOST_WIDE_INT *); extern tree get_addr_base_and_unit_offset (tree, HOST_WIDE_INT *); +extern tree find_vars_r (tree *, int *, void *); extern void find_referenced_vars_in (gimple); /* In tree-phinodes.c */ Index: gcc/tree-dfa.c =================================================================== --- gcc/tree-dfa.c (revision 187228) +++ gcc/tree-dfa.c (working copy) @@ -62,7 +62,6 @@ struct dfa_stats_d /* Local functions. */ static void collect_dfa_stats (struct dfa_stats_d *); -static tree find_vars_r (tree *, int *, void *); /*--------------------------------------------------------------------------- @@ -441,7 +440,7 @@ collect_dfa_stats (struct dfa_stats_d *d /* Callback for walk_tree. Used to collect variables referenced in the function. */ -static tree +tree find_vars_r (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) { /* If we are reading the lto info back in, we need to rescan the Index: gcc/tree-inline.c =================================================================== --- gcc/tree-inline.c (revision 187228) +++ gcc/tree-inline.c (working copy) @@ -2607,6 +2607,13 @@ setup_one_parameter (copy_body_data *id, /* Make gimplifier happy about this variable. */ DECL_SEEN_IN_BIND_EXPR_P (var) = 1; + /* We are eventually using the value - make sure all variables + referenced therein are properly recorded. */ + if (value + && gimple_in_ssa_p (cfun) + && !CONSTANT_CLASS_P (value)) + walk_tree (&value, find_vars_r, NULL, NULL); + /* If the parameter is never assigned to, has no SSA_NAMEs created, we would not need to create a new variable here at all, if it weren't for debug info. Still, we can just use the argument
Simpler fix: Index: tree-inline.c =================================================================== --- tree-inline.c (revision 187228) +++ tree-inline.c (working copy) @@ -2607,6 +2607,17 @@ setup_one_parameter (copy_body_data *id, /* Make gimplifier happy about this variable. */ DECL_SEEN_IN_BIND_EXPR_P (var) = 1; + /* We are eventually using the value - make sure all variables + referenced therein are properly recorded. */ + if (value + && gimple_in_ssa_p (cfun) + && TREE_CODE (value) == ADDR_EXPR) + { + tree base = get_base_address (TREE_OPERAND (value, 0)); + if (base && TREE_CODE (base) == VAR_DECL) + add_referenced_var (base); + } + /* If the parameter is never assigned to, has no SSA_NAMEs created, we would not need to create a new variable here at all, if it weren't for debug info. Still, we can just use the argument
"unfortunately" -flto-partition=1to1 fixes the ICE for the library in question. I do not have any other standing ICE at the moment. btw I've applied the patch in comment 9 on the top of gcc version 4.7.1 20120504 (prerelease) [gcc-4_7-branch revision 187154] (GCC) and now the library builds. No obvious side effects.
Author: rguenth Date: Mon May 7 12:59:05 2012 New Revision: 187235 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187235 Log: 2012-05-07 Richard Guenther <rguenther@suse.de> PR tree-optimization/53195 * tree-inline.c (setup_one_parameter): Properly add referenced vars from the parameters new known value. Modified: trunk/gcc/ChangeLog trunk/gcc/tree-inline.c
Author: rguenth Date: Mon May 7 13:00:39 2012 New Revision: 187237 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187237 Log: 2012-05-07 Richard Guenther <rguenther@suse.de> PR tree-optimization/53195 * tree-inline.c (setup_one_parameter): Properly add referenced vars from the parameters new known value. Modified: branches/gcc-4_7-branch/gcc/ChangeLog branches/gcc-4_7-branch/gcc/tree-inline.c
Fixed.
*** Bug 52776 has been marked as a duplicate of this bug. ***