https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106305
Bug ID: 106305 Summary: ICE on valid code at -O1 with -funreachable-traps: verify_cgraph_node failed Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: zhendong.su at inf dot ethz.ch CC: marxin at gcc dot gnu.org Target Milestone: --- Compiler Explorer: https://godbolt.org/z/WdMsGaG3b [525] % gcctk -v Using built-in specs. COLLECT_GCC=gcctk COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: ../gcc-trunk/configure --disable-bootstrap --prefix=/local/suz-local/software/local/gcc-trunk --enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib --with-system-zlib Thread model: posix Supported LTO compression algorithms: zlib gcc version 13.0.0 20220714 (experimental) [master r13-1696-g29f40a8047f] (GCC) [526] % [526] % gcctk -O1 -funreachable-traps small.c small.c:10:1: error: edge points to wrong declaration: 10 | } | ^ <function_decl 0x7f6e71180e00 __builtin_trap type <function_type 0x7f6e710c75e8 type <void_type 0x7f6e710b7f18 void VOID align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f6e710b7f18 pointer_to_this <pointer_type 0x7f6e710bf000>> QI size <integer_cst 0x7f6e7109be40 constant 8> unit-size <integer_cst 0x7f6e7109be58 constant 1> align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f6e710c75e8 arg-types <tree_list 0x7f6e710b3b18 value <void_type 0x7f6e710b7f18 void>>> volatile nothrow public external built-in decl_6 QI <built-in>:0:0 align:8 warn_if_not_align:0 built-in: BUILT_IN_NORMAL:BUILT_IN_TRAP context <translation_unit_decl 0x7f6e710a9c30 small.c> attributes <tree_list 0x7f6e7117eeb0 purpose <identifier_node 0x7f6e710c3be0 nothrow> chain <tree_list 0x7f6e7117ee88 purpose <identifier_node 0x7f6e710c3c30 leaf> chain <tree_list 0x7f6e7117ee60 purpose <identifier_node 0x7f6e710c3b90 noreturn> chain <tree_list 0x7f6e7117ee38 purpose <identifier_node 0x7f6e710c3a00 cold>>>>> chain <function_decl 0x7f6e71180f00 __builtin_unreachable>> Instead of: <function_decl 0x7f6e7115f000 printf type <function_type 0x7f6e7115d348 type <integer_type 0x7f6e710b75e8 int public SI size <integer_cst 0x7f6e7109bf90 constant 32> unit-size <integer_cst 0x7f6e7109bfa8 constant 4> align:32 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f6e710b75e8 precision:32 min <integer_cst 0x7f6e7109bf48 -2147483648> max <integer_cst 0x7f6e7109bf60 2147483647> pointer_to_this <pointer_type 0x7f6e710bfa80>> QI size <integer_cst 0x7f6e7109be40 constant 8> unit-size <integer_cst 0x7f6e7109be58 constant 1> align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type 0x7f6e710e0498 attributes <tree_list 0x7f6e7115c7d0 purpose <identifier_node 0x7f6e710c3b40 nonnull> value <tree_list 0x7f6e710dff78 value <integer_cst 0x7f6e710bb108 constant 1>> chain <tree_list 0x7f6e7115c7a8 purpose <identifier_node 0x7f6e710c3a50 format> value <tree_list 0x7f6e710e3e38 value <identifier_node 0x7f6e710c3cd0 printf> chain <tree_list 0x7f6e710e3118 value <integer_cst 0x7f6e710bb108 1> chain <tree_list 0x7f6e710dffa0 value <integer_cst 0x7f6e710bb498 2>>>>>> arg-types <tree_list 0x7f6e710df168 value <pointer_type 0x7f6e710c65e8>> pointer_to_this <pointer_type 0x7f6e711fd1f8>> addressable used public external built-in decl_3 decl_5 QI small.c:1:5 align:8 warn_if_not_align:0 built-in: BUILT_IN_NORMAL:BUILT_IN_PRINTF context <translation_unit_decl 0x7f6e710a9c30 small.c> chain <function_decl 0x7f6e7115f100 __builtin_printf_unlocked>> b/4 (b) @0x7f6e71200330 Type: function definition analyzed Visibility: semantic_interposition public next sharing asm name: 1 References: a/0 (read) Referring: Function b/4 is inline copy in main/2 Clone of b/1 Availability: local Function flags: count:1073741824 (estimated locally) body local executed_once Called by: main/2 (inlined) (1073741824 (estimated locally),1.00 per call) Calls: __builtin_trap/5 (0 (precise),0.00 per call) during IPA pass: inline small.c:10:1: internal compiler error: verify_cgraph_node failed 0xa224a8 cgraph_node::verify_node() ../../gcc-trunk/gcc/cgraph.cc:3881 0xa112c4 symtab_node::verify() ../../gcc-trunk/gcc/symtab.cc:1359 0xa12507 symtab_node::verify_symtab_nodes() ../../gcc-trunk/gcc/symtab.cc:1387 0xcce301 symtab_node::checking_verify_symtab_nodes() ../../gcc-trunk/gcc/cgraph.h:682 0xcce301 symbol_table::remove_unreachable_nodes(_IO_FILE*) ../../gcc-trunk/gcc/ipa.cc:678 0xde8781 execute_todo ../../gcc-trunk/gcc/passes.cc:2159 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. [527] % [527] % cat small.c int printf(const char *, ...); char *a = "hello"; void b(int c) { if (c) printf(a); } int main() { b(0); return 0; }