I get the following ICE with gcc 6 from trunk (20160117) and LTO: g++ -o STAR -flto -flto -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -O3 -pipe -std=c++11 -Wall -Wextra -fopenmp -D'COMPILATION_TIME_PLACE="Wed Jan 20 18:24:39 UTC 2016 :/home/tbm/gcc6/rna-star-2.5.0a+dfsg/source"' SharedMemory.o PackedArray.o SuffixArrayFuns.o STAR.o Parameters.o InOutStreams.o SequenceFuns.o Genome.o Stats.o Transcript.o Transcript_alignScore.o ReadAlign.o ReadAlign_storeAligns.o ReadAlign_stitchPieces.o ReadAlign_multMapSelect.o ReadAlign_mapOneRead.o readLoad.o ReadAlignChunk.o ReadAlignChunk_processChunks.o ReadAlignChunk_mapChunk.o OutSJ.o outputSJ.o blocksOverlap.o ThreadControl.o sysRemoveDir.o ReadAlign_maxMappableLength2strands.o binarySearch2.o ReadAlign_outputAlignments.o ReadAlign_outputTranscriptSAM.o ReadAlign_outputTranscriptSJ.o ReadAlign_outputTranscriptCIGARp.o ReadAlign_createExtendWindowsWithAlign.o ReadAlign_assignAlignToWindow.o ReadAlign_oneRead.o ReadAlign_stitchWindowSeeds.o ReadAlign_chimericDetection.o stitchWindowAligns.o extendAlign.o stitchAlignToTranscript.o alignSmithWaterman.o genomeGenerate.o genomeParametersWrite.o genomeScanFastaFiles.o genomeSAindex.o Genome_insertSequences.o insertSeqSA.o funCompareUintAndSuffixes.o TimeFunctions.o ErrorWarning.o loadGTF.o streamFuns.o stringSubstituteAll.o Transcriptome.o Transcriptome_quantAlign.o ReadAlign_quantTranscriptome.o Quantifications.o Transcriptome_geneCountsAddAlign.o sjdbLoadFromFiles.o sjdbLoadFromStream.o sjdbPrepare.o sjdbBuildIndex.o sjdbInsertJunctions.o mapThreadsSpawn.o Parameters_openReadsFiles.cpp Parameters_closeReadsFiles.cpp BAMoutput.o BAMfunctions.o ReadAlign_alignBAM.o BAMbinSortByCoordinate.o signalFromBAM.o bamRemoveDuplicates.o BAMbinSortUnmapped.o bam_cat.o GlobalVariables.cpp -pthread -Bstatic -lhts -Bdynamic lto1: internal compiler error: in dwarf2out_finish, at dwarf2out.c:27175 0x6a2e00 dwarf2out_finish ../../src/gcc/dwarf2out.c:27175 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. Unfortunately I'm not sure how to submit a test case. I tried to follow https://gcc.gnu.org/wiki/A_guide_to_testcase_reduction#Reducing_LTO_bugs and I got it down to: /usr/lib/gcc/x86_64-linux-gnu/6/lto1 -quiet -dumpdir ./ -dumpbase STAR.ltrans1 -auxbase-strip STAR.ltrans1.ltrans.o -g -O2 -fopenmp -fltrans STAR.ltrans1.o -o STAR.ltrans1.s lto1: internal compiler error: in dwarf2out_finish, at dwarf2out.c:27175 0x6a2e00 dwarf2out_finish ../../src/gcc/dwarf2out.c:27175 Please submit a full bug report, with preprocessed source if appropriate. But I'm not sure which sources are used for STAR.ltrans1.o. The wiki says "Then use delta on that file" but that file is STAR.ltrans1.o, not source. Can someone give me some hints on how to get a testcase?
Sounds possibly related to PR69137 as that has changes to deferred_asm_name creation points (you can try confirming this by reverting the change). You reduce the testcase by adding -r -nostdlib to the link line and "bisect" the object files needed to trigger the bug. If -flto-partition=1to1 reproduces the bug as well then do the reduction with that option active. Then if you reached a minimal set substitute preprocessed source for the object file inputs and attach those (those you can then reduce further if you like). Thus waiting for a testcase.
Ok, I can reproduce this issue like this: g++-6 -o STAR -flto -flto -g -O2 -fopenmp STAR.ii Genome.ii Stats.ii genomeGenerate.ii I've attached the preprocessed source.
Created attachment 37424 [details] Preprocessed source
Created attachment 37425 [details] Preprocessed source
Created attachment 37426 [details] Preprocessed source
Created attachment 37427 [details] Preprocessed source
I should note that I don't see this with -r -nostdlib, as described in the wiki. (sid)604:tbm@dl580gen9-02: ~/a] g++-6 -r -nostdlib STAR.ii Genome.ii Stats.ii genomeGenerate.ii -g -O2 -fopenmp -flto -flto (sid)605:tbm@dl580gen9-02: ~/a] g++-6 -o STAR -flto -flto -g -O2 -fopenmp STAR.ii Genome.ii Stats.ii genomeGenerate.ii lto1: internal compiler error: in dwarf2out_finish, at dwarf2out.c:27175 0x6a2e00 dwarf2out_finish ../../src/gcc/dwarf2out.c:27175 Please submit a full bug report, with preprocessed source if appropriate. Please include the complete backtrace with any bug report. This is with 6.0.0 20160117 on x86_64-linux-gnu.
Ok, I can reproduce the ICE. (gdb) p deferred_asm_name->created_for $4 = (tree) 0x7ffff64fc980 (gdb) p debug_generic_expr ($4) .omp_data_s.34 aha and that's indeed a TYPE_DECL which is DECL_ARTIFICIAL but ! DECL_IGNORED. Jakub - is debug info intended for this TYPE_DECL? Honza, do the TYPE_DECL asm-names make sense here? /* This is a GNU Extension. We are adding a DW_AT_linkage_name attribute to the DIE of the anonymous struct TYPE. The value of that attribute is the name of the typedef decl naming the anonymous struct. This greatly eases the work of consumers of this debug info. */ add_linkage_name_raw (lookup_type_die (type), decl); (gdb) p debug_tree ($4) <type_decl 0x7ffff64fc980 .omp_data_s.34 type <record_type 0x7ffff64fad20 .omp_data_s.34 asm_written BLK size <integer_cst 0x7ffff688bf18 constant 256> unit size <integer_cst 0x7ffff68a8018 constant 32> align 64 symtab -162595952 alias set 77 canonical type 0x7ffff64fad20 fields <field_decl 0x7ffff64fc8e8 P type <pointer_type 0x7ffff682f930> unsigned DI file STAR.cpp line 56 col 17 size <integer_cst 0x7ffff688bbb8 constant 64> unit size <integer_cst 0x7ffff688bbd0 constant 8> align 64 offset_align 128 offset <integer_cst 0x7ffff688bbe8 constant 0> bit offset <integer_cst 0x7ffff688bc30 constant 0> context <record_type 0x7ffff64fad20 .omp_data_s.34> chain <field_decl 0x7ffff64fc850 totalMem>> pointer_to_this <pointer_type 0x7ffff6511888>> asm_written VOID file STAR.cpp line 353 col 9 align 1> That said - we either need to make sure to compute and stream DECL_ASSEMBLER_NAME for the above or avoid emitting late debug for this (for example via adjusting is_naming_typedef_decl). Note that it looks like free-lang-data misses to traverse fn->static_chain_decl, but fixing that doesn't fix this PR. The DWARF for the above decl is created via #4 0x00000000008bfadc in dwarf2out_type_decl (decl=0x7ffff64fc980, local=0) at /space/rguenther/src/svn/trunk3/gcc/dwarf2out.c:23536 #5 0x000000000076535f in lto_read_decls (decl_data=0x7ffff7fed000, data=0x7ffff7ef3a00, resolutions=...) at /space/rguenther/src/svn/trunk3/gcc/lto/lto.c:1761 So back to why this hasn't been assigned an assembler name in free-lang-data. FLD has static inline bool need_assembler_name_p (tree decl) { ... if (flag_lto_odr_type_mering && TREE_CODE (decl) == TYPE_DECL && DECL_NAME (decl) && decl == TYPE_NAME (TREE_TYPE (decl)) && !TYPE_ARTIFICIAL (TREE_TYPE (decl)) && (type_with_linkage_p (TREE_TYPE (decl)) || TREE_CODE (TREE_TYPE (decl)) == INTEGER_TYPE) && !variably_modified_type_p (TREE_TYPE (decl), NULL_TREE)) return !DECL_ASSEMBLER_NAME_SET_P (decl); /* Only FUNCTION_DECLs and VAR_DECLs are considered. */ if (TREE_CODE (decl) != FUNCTION_DECL && TREE_CODE (decl) != VAR_DECL) return false; but TYPE_ARTIFICIAL (TREE_TYPE (decl)) is true. Guarding the above with flag_lto_odr_type_merging also looks suspicious - seems the code doesn't consider debug info for TYPE_DECLs at all? dwarf2out guards the assembler-name use with if (DECL_ORIGINAL_TYPE (decl)) ... else { type = TREE_TYPE (decl); ... if (is_naming_typedef_decl (TYPE_NAME (type))) { it seems to me we can't really use debug_info_level at compile-time to guard things here so we'd have to unconditionally assign assembler names to TYPE_DECLs under the above condition? Or arrange so that is_naming_typedef_decl doesn't apply to those artificial OMP type-decls? (why do we have type-decls for this at all...?)
Yes, the type is meant to go into the debug info. But it is DECL_NAMELESS, so the debug info should not contain DW_AT_name or linkage name for it.
On Fri, 22 Jan 2016, jakub at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69393 > > --- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> --- > Yes, the type is meant to go into the debug info. But it is DECL_NAMELESS, so > the debug info should not contain DW_AT_name or linkage name for it. So is_naming_typedef_decl should check DECL_NAMELESS? Like so? Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 232717) +++ gcc/dwarf2out.c (working copy) @@ -22970,6 +22970,7 @@ is_naming_typedef_decl (const_tree decl) { if (decl == NULL_TREE || TREE_CODE (decl) != TYPE_DECL + || DECL_NAMELESS (decl) || !is_tagged_type (TREE_TYPE (decl)) || DECL_IS_BUILTIN (decl) || is_redundant_typedef (decl) this unfortunately doesn't fix the ICE for me because we don't stream DECL_NAMELESS it seems. If I fix that the fix above works. The lack of consistency between where free-lang-data forces a assembler name and the debug expectation is disturbing (I suppose with -fno-lto-odr-type-merging it would ICE all over the place)
trippels@CFARM-IUT-TLSE3 ~ % cat STAR.ii class A { public: int runThreadN, outBAMsortingThreadNactual; }; class B { public: long *binTotalN; }; class C { public: B *chunkOutBAMcoord; }; main() { A *P; C *a[P->runThreadN]; #pragma omp parallel num_threads(P->outBAMsortingThreadNactual) int b = a[0]->chunkOutBAMcoord->binTotalN[0]; } trippels@CFARM-IUT-TLSE3 ~ % g++ -r -nostdlib -flto -g -O2 -fopenmp STAR.ii lto1: internal compiler error: in dwarf2out_finish, at dwarf2out.c:27200
Perhaps "-shared -fPIC" instead of "-r -nostdlib" should be used for the testsuite.
More reduced testcase: int e = 5; int main () { int a[e]; a[0] = 6; #pragma omp parallel if (a[0] != 6) __builtin_abort (); return 0; } Or it can be put into libgomp/testsuite/libgomp.c++/ and just have // { dg-do run } // { dg-options "-flto -g -fopenmp" } ?
Fixed.
Author: rguenth Date: Mon Jan 25 09:31:47 2016 New Revision: 232787 URL: https://gcc.gnu.org/viewcvs?rev=232787&root=gcc&view=rev Log: 2016-01-25 Richard Biener <rguenther@suse.de> PR lto/69393 * dwarf2out.c (is_naming_typedef_decl): Not when DECL_NAMELESS. * tree-streamer-out.c (pack_ts_base_value_fields): Stream DECL_NAMELESS. * tree-streamer-in.c (unpack_ts_base_value_fields): Likewise. * testsuite/libgomp.c++/pr69393.C: New testcase. Added: trunk/libgomp/testsuite/libgomp.c++/pr69393.C Modified: trunk/gcc/ChangeLog trunk/gcc/dwarf2out.c trunk/gcc/tree-streamer-in.c trunk/gcc/tree-streamer-out.c trunk/libgomp/ChangeLog