https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101941
Bug ID: 101941 Summary: Linux kernel build failure due to retaining fnsplit fragment with __attribute__((__error__)) Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: dmalcolm at gcc dot gnu.org CC: marxin at gcc dot gnu.org Target Milestone: --- I'm attaching a reduced reproducer for an issue seen when attempting to build a recent linux kernel with gcc trunk (x86_64 gcc 12). With: "-O2 -fconserve-stack", the attached fails with: $ ~/gcc-install/bin/gcc -S -O2 -fconserve-stack aesni-intel_glue.c In function ‘memset’, inlined from ‘rfc4106_set_hash_subkey.part.0’ at aesni-intel_glue.c:58:3: aesni-intel_glue.c:30:5: error: call to ‘__write_overflow’ declared with attribute error: detected write beyond size of object passed as 1st parame\ ter 30 | __write_overflow(); | ^~~~~~~~~~~~~~~~~~ Looking at -fdump-tree-all, I see that a "void rfc4106_set_hash_subkey.part.0 ()" is created in .050t.fnsplit, containing: void rfc4106_set_hash_subkey.part.0 () { int D.2043; struct crypto_aes_ctx ctx; int ret; size_t p_size; u8 * hash_subkey; const u8 * key; unsigned int key_len; int _1; <bb 3> [local count: 1073741824]: <bb 2> [local count: 1073741824]: __write_overflow (); fortify_panic (&__func__); } and is called by rfc4106_set_hash_subkey. However after .104t.phiprop, the call to rfc4106_set_hash_subkey.part.0 is optimized away, but the function fragment is retained, leading to the build failure in "expand", where at .247t.optimized it has: ;; Function rfc4106_set_hash_subkey.part.0 (rfc4106_set_hash_subkey.part.0, funcdef_no=3, decl_uid=2035, cgraph_uid=14, symbol_order=14) void rfc4106_set_hash_subkey.part.0 () { <bb 2> [local count: 1073741824]: __write_overflow (); fortify_panic (&__func__); } where __write_overflow is marked with __attribute__((__error__)) Reproducer on godbolt.org: https://godbolt.org/z/15oehqjGP Presumably if all calls to a fn "part" are optimized away, that fn part should also be optimized away.