From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8624B3858C31; Mon, 6 May 2024 17:29:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8624B3858C31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1715016548; bh=is2PqbnWEg7aCbZ6FUVahVcM6LE/CM9xW3Z9zSoVp9s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=bLsjnDeY9g4AdPQDJl0QJ0bnB3D7yOby/QziLw15xiS5yr6+1dvKYHjs78US5qpqA c0Ckvi08PKRPjzIDnA63HZsbWba+QwjHofgJLKxoHlaEMGu2sMagzc1Eg+KLs0wdzc oA/UGKeuDqJSJF2c9GpYKhIrRaPDRBxNViOXRJmM= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114872] [13/14/15 Regression] Miscompilation with -O2 after commit r13-8037 Date: Mon, 06 May 2024 17:29:07 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.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: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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=3D114872 --- Comment #15 from Jakub Jelinek --- (In reply to Dmitrii Pasechnik from comment #12) > A colleague disassembled, using ghidra (https://ghidra-sre.org/), the > results of the compilations with, respectively, -O2 and with -O0 flags. > Comparing the results, in the broken (built with -O2) case one sees a > miscompilation of a call to GAP_CallFunc3Args - it is called with one > argument less than it should, three instead of four! >=20 > broken (-O2): >=20 > > plVar9 =3D (long *)GAP_CallFunc3Args(*(undefined8 *)(para= m_1 + 0x20),local_a0[4], > > local_a8[4]); >=20 > vs. good (-O0): >=20 > < LAB_0013cbd9: > < plVar10 =3D (long *)GAP_CallFunc3Args(*(undefined8 *)(param= _1 + > 0x20),local_a8[4], > < local_a0[4],plVar16[4]); >=20 > And this is despite the prototype for calling GAP_CallFunc3Args() is > found in "gap/libgap-api.h", which is included in example.c as #include > "gap/libgap-api.h", meant to be respected during the compilation.=20 >=20 > I hope this helps in chasing down the obvious compiler bug. Perhaps it can > be also seen without disassembling, simply on the intermediate data > generated by the compiler. Both calls pass 4 arguments, both in optimized -O2 -fPIC GCC 13.2.1 dump an= d in assembly: movq -88(%rbp), %rdx movq %r12, %rcx movq %r13, %rsi movq %rax, %rdi call GAP_CallFunc3Args@PLT ... movq -88(%rbp), %rdx movq %r12, %rcx movq %r13, %rsi movq %rax, %rdi call GAP_CallFunc3Args@PLT and GAP_CallFunc3Args (_53, _47, __pyx_v_func_54(D), _49); ... _441 =3D GAP_CallFunc3Args (_98, _97, _96, _95);=