From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4CC3638582A5; Thu, 1 Feb 2024 12:27:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4CC3638582A5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706790443; bh=lwSJEYobNQ90/NOrLOskDkJzIKiPNeCsqf2eBMSkh2A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=TNXxWDTpsS1JMKhFZ3Zh0R69r/QB5xWp8h+YvuV17hlEqwR6q0EBxLwdKCiUWphWG edbe2G8TWIa9fZPZLM3HEwIWEDkHIl4k9eLUUrv5Lb8DG7N/jVn5tUvJMk+6Qj2n1w +eo3SrZ2wbmH/6TWPeSDFtK/25ix8R3lBZlgXuR4= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/113689] [11/12/13/14 Regression] wrong code with -fprofile -mcmodel=large when needing drap register since r11-6548 Date: Thu, 01 Feb 2024 12:27:21 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc priority target_milestone short_desc 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=3D113689 Jakub Jelinek changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hjl.tools at gmail dot com, | |hubicka at gcc dot gnu.org, | |jakub at gcc dot gnu.org, | |uros at gcc dot gnu.org Priority|P3 |P2 Target Milestone|--- |11.5 Summary|wrong code with unused |[11/12/13/14 Regression] |_BitInt() division with -O2 |wrong code with -fprofile |-fprofile -mcmodel=3Dlarge |-mcmodel=3Dlarge when ne= eding |-mavx |drap register since | |r11-6548 --- Comment #2 from Jakub Jelinek --- Seems like a backend bug to me, collision between function profiler after prologue and drap. I see foo: leaq 8(%rsp), %r10 andq $-32, %rsp pushq -8(%r10) pushq %rbp movq %rsp, %rbp pushq %r14 pushq %r13 pushq %r12 pushq %r10 pushq %rbx subq $200, %rsp 1: movabsq $mcount, %r10 call *%r10 xorl %eax, %eax xorl %edx, %edx movl $-511, %r9d addb $-1, %dl movq %rax, %rdx sbbq (%r10), %rdx This function is stack_realign_drap, find_drap_reg returns R10_REG and so ix86_get_drap_rtx uses %r10 as drap register. Later on pro_and_epilogue initializes the drap register in the prologue. And, final.cc when seeing NOTE_INSN_PROLOGUE_END emits the late FUNCTION_PROFILER, which seems to have clobbering of %r10 (and/or %r11) hardcoded in it, so it overwrites the drap value. One doesn't need _BitInt to reproduce: /* { dg-do run { target lp64 } } */ /* { dg-options "-O2 -fprofile -mcmodel=3Dlarge" } */ __attribute__((noipa)) void bar (char *x, char *y, int *z) { x[0] =3D 42; y[0] =3D 42; if (z[0] !=3D 16) __builtin_abort (); } __attribute__((noipa)) void=20 foo (int c, int d, int e, int f, int g, int h, int z) { typedef char B[32]; B b __attribute__((aligned (32))); bar (&b[0], __builtin_alloca (z), &z); } int main () { foo (0, 0, 0, 0, 0, 0, 16); } Started with r11-6548-g1b885264a48dcd71b7aeb26c0abeb91246724897=