https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120881

--- Comment #29 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by H.J. Lu <[email protected]>:

https://gcc.gnu.org/g:07d8de9174c421d719649639a1452b8b9f2eee32

commit r16-2232-g07d8de9174c421d719649639a1452b8b9f2eee32
Author: H.J. Lu <[email protected]>
Date:   Wed Jul 2 08:58:23 2025 +0800

    x86-64: Add --enable-x86-64-mfentry

    When profiling is enabled with shrink wrapping, the mcount call may not
    be placed at the function entry after

            pushq %rbp
            movq %rsp,%rbp

    As the result, the profile data may be skewed which makes PGO less
    effective.

    Add --enable-x86-64-mfentry to enable -mfentry by default to use
    __fentry__, added to glibc in 2010 by:

    commit d22e4cc9397ed41534c9422d0b0ffef8c77bfa53
    Author: Andi Kleen <[email protected]>
    Date:   Sat Aug 7 21:24:05 2010 -0700

        x86: Add support for frame pointer less mcount

    instead of mcount, which is placed before the prologue so that -pg can
    be used with -fshrink-wrap-separate enabled at -O1.  This option is
    64-bit only because __fentry__ doesn't support PIC in 32-bit mode.  The
    default it to enable -mfentry when targeting glibc.

    Also warn -pg without -mfentry with shrink wrapping enabled.  The warning
    is disable for PIC in 32-bit mode.

    gcc/

            PR target/120881
            * config.in: Regenerated.
            * configure: Likewise.
            * configure.ac: Add --enable-x86-64-mfentry.
            * config/i386/i386-options.cc (ix86_option_override_internal):
            Enable __fentry__ in 64-bit mode if ENABLE_X86_64_MFENTRY is set
            to 1.  Warn -pg without -mfentry with shrink wrapping enabled.
            * doc/install.texi: Document --enable-x86-64-mfentry.

    gcc/testsuite/

            PR target/120881
            * gcc.dg/20021014-1.c: Add additional -mfentry -fno-pic options
            for x86.
            * gcc.dg/aru-2.c: Likewise.
            * gcc.dg/nest.c: Likewise.
            * gcc.dg/pr32450.c: Likewise.
            * gcc.dg/pr43643.c: Likewise.
            * gcc.target/i386/pr104447.c: Likewise.
            * gcc.target/i386/pr113122-3.c: Likewise.
            * gcc.target/i386/pr119386-1.c: Add additional -mfentry if not
            ia32.
            * gcc.target/i386/pr119386-2.c: Likewise.
            * gcc.target/i386/pr120881-1a.c: New test.
            * gcc.target/i386/pr120881-1b.c: Likewise.
            * gcc.target/i386/pr120881-1c.c: Likewise.
            * gcc.target/i386/pr120881-1d.c: Likewise.
            * gcc.target/i386/pr120881-2a.c: Likewise.
            * gcc.target/i386/pr120881-2b.c: Likewise.
            * gcc.target/i386/pr82699-1.c: Add additional -mfentry.
            * lib/target-supports.exp (check_effective_target_fentry): New.

    Signed-off-by: H.J. Lu <[email protected]>

Reply via email to