From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id ECA073858D35; Tue, 7 Feb 2023 10:04:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECA073858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675764285; bh=o+9+H+THDiro/nBPaxqD+mCdxhA9iIMsBjY0OarU0g0=; h=From:To:Subject:Date:From; b=XYfkh0y9n3U30xjBDKRcjSGu5MF0QJlbvgbEa2g9adr4N0zm+70U8lf1ITCYCeRFV 5oTUdREQ0sXC51lr7VjN4RyJu7/qMq4MOzzJEg0tybqJ2vGt/bsVBQCdyQwDUWKck0 Mqp9obQg4M7KazmvDMTOxEQO6/3NPhwxrLK1sI60= From: "david.spickett at linaro dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/108691] New: ICE when compiling for AArch64 with BTI protection at -O1 Date: Tue, 07 Feb 2023 10:04:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: david.spickett at linaro dot org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D108691 Bug ID: 108691 Summary: ICE when compiling for AArch64 with BTI protection at -O1 Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: david.spickett at linaro dot org Target Milestone: --- Created attachment 54416 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D54416&action=3Dedit Output from -freport-bug This code: ``` extern int __attribute__((returns_twice)) setjmp(void*); void bbb(void) { int (*fnptr)(void*) =3D setjmp; fnptr(0); } ``` Causes an ICE when compiled with gcc trunk. ``` during GIMPLE pass: cddce : In function 'bbb': :6:1: internal compiler error: in eliminate_unnecessary_stmts, at tree-ssa-dce.cc:1512 6 | } | ^ Please submit a full bug report, with preprocessed source (by using -freport-bug). See for instructions. Compiler returned: 1 ``` https://godbolt.org/z/6dEMEbEG8 Compiling at -O0, or calling setjmp directly avoids the crash. There is no crash with gcc 12.2. Also calling setjmp directly after using the function pointer avoids the cr= ash. One thing that is happening here is that gcc is converting the indirect call into a direct one. Perhaps when that is the only call in the function, that= 's the problematic situation. For context, this is not from real code. It's a clang test case for bti protection of returns twice calls. Either way, the compiler shouldn't crash= and if there's something wrong with the source it should say so.=