https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112601
Bug ID: 112601 Summary: ICE in cgraph_node::verify_node(): error: invalid calls_comdat_local flag Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at gcc dot gnu.org CC: marxin at gcc dot gnu.org Target Milestone: --- Encountered the bug when tried to build llvm-17.0.5 with -O1 optimization flags. Looks like all the gcc versions I tried fail starting from gcc-10 including current gcc-master r14-5563-gbc274b8d677212. Extracted reproducer: // $ cat a.cpp bool neq(int, int); int begin(); int end(); void deref(int); struct Twine { Twine(const char *); }; int &out(int, Twine); void out6(int, Twine); static void printChar(int &, char) {} int emitStringLiteralDef_OS, emit_OS, emit_I; char emit___trans_tmp_1; struct SequenceToOffsetTable { void emitStringLiteralDef(Twine Decl) { emit(printChar); int __trans_tmp_6 = out(emitStringLiteralDef_OS, ""), __trans_tmp_5 = out(__trans_tmp_6, ""), __trans_tmp_4 = out(__trans_tmp_5, ""), __trans_tmp_3 = out(__trans_tmp_4, ""), __trans_tmp_2 = out(__trans_tmp_3, Decl); out6(__trans_tmp_2, ""); } void emit(void Print(int &, char)) { for (int E = 0; neq(emit_I, E);) for (int SI = (deref(emit_I), begin)(), SE = (deref(emit_I), end)(); neq(SI, SE);) Print(emit_OS, emit___trans_tmp_1); } }; void run() { SequenceToOffsetTable RegStrings; RegStrings.emitStringLiteralDef(0); } Crashing: $ gcc/xg++ -B./gcc -O1 -fchecking=2 -c a.cpp -o a.o a.cpp: In member function 'void SequenceToOffsetTable::emitStringLiteralDef(Twine)': a.cpp:14:8: error: invalid calls_comdat_local flag 14 | void emitStringLiteralDef(Twine Decl) { | ^~~~~~~~~~~~~~~~~~~~ _ZN21SequenceToOffsetTable20emitStringLiteralDefE5Twine/5 (void SequenceToOffsetTable::emitStringLiteralDef(Twine)) Type: function definition analyzed Visibility: externally_visible semantic_interposition public weak comdat comdat_group:_ZN21SequenceToOffsetTable20emitStringLiteralDefE5Twine one_only Same comdat group as: _ZL9printCharRic/0 References: Referring: Availability: available Function flags: count:1073741824 (estimated locally) body Called by: _Z3runv/7 (1073741824 (estimated locally),1.00 per call) (can throw external) Calls: _Z3neqii/15 (9761289262 (estimated locally),9.09 per call) (can throw external) _Z3neqii/15 (78977704412 (estimated locally),73.55 per call) (can throw external) _ZL9printCharRic/0 (70290156974 (estimated locally),65.46 per call) (can throw external) _Z3endv/14 (8687547438 (estimated locally),8.09 per call) (can throw external) _Z5derefi/12 (8687547438 (estimated locally),8.09 per call) (can throw external) _Z5beginv/13 (8687547438 (estimated locally),8.09 per call) (can throw external) _Z5derefi/12 (8687547438 (estimated locally),8.09 per call) (can throw external) _Z4out6i5Twine/11 (1073741824 (estimated locally),1.00 per call) (can throw external) _ZN5TwineC1EPKc/8 (1073741824 (estimated locally),1.00 per call) (can throw external) _Z3outi5Twine/10 (1073741824 (estimated locally),1.00 per call) (can throw external) _Z3outi5Twine/10 (1073741824 (estimated locally),1.00 per call) (can throw external) _ZN5TwineC1EPKc/8 (1073741824 (estimated locally),1.00 per call) (can throw external) _Z3outi5Twine/10 (1073741824 (estimated locally),1.00 per call) (can throw external) _ZN5TwineC1EPKc/8 (1073741824 (estimated locally),1.00 per call) (can throw external) _Z3outi5Twine/10 (1073741824 (estimated locally),1.00 per call) (can throw external) _ZN5TwineC1EPKc/8 (1073741824 (estimated locally),1.00 per call) (can throw external) _Z3outi5Twine/10 (1073741824 (estimated locally),1.00 per call) (can throw external) _ZN5TwineC1EPKc/8 (1073741824 (estimated locally),1.00 per call) (can throw external) during IPA pass: inline a.cpp:14:8: internal compiler error: verify_cgraph_node failed 0x258970b diagnostic_impl(rich_location*, diagnostic_metadata const*, int, char const*, __va_list_tag (*) [1], diagnostic_t) ???:0 0x258a52e internal_error(char const*, ...) ???:0 0xc767c2 cgraph_node::verify_node() ???:0 0xc64d11 symtab_node::verify() ???:0 0x1276003 optimize_inline_calls(tree_node*) ???:0 0xf10813 inline_transform(cgraph_node*) ???:0 0x10a320e execute_all_ipa_transforms(bool) ???:0 0xc7b6e8 cgraph_node::expand() ???:0 0xc7d219 symbol_table::compile() ???:0 0xc7fce4 symbol_table::finalize_compilation_unit() ???:0 $ gcc/xg++ -B./gcc -v Reading specs from ./gcc/specs COLLECT_GCC=./gcc/xg++ COLLECT_LTO_WRAPPER=./gcc/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /home/slyfox/dev/git/gcc/configure --disable-multilib --disable-bootstrap --disable-lto --disable-libsanitizer --disable-libstdcxx-pch --enable-languages=c,c++ --disable-libgomp --disable-libquadmath --disable-libvtv CFLAGS='-O1 -g0' CXXFLAGS='-O1 -g0' LDFLAGS='-O1 -g0' Thread model: posix Supported LTO compression algorithms: zlib gcc version 14.0.0 20231117 (experimental) (GCC)