[all-commits] [llvm/llvm-project] 263bbd: clang/ARM: Derive -pg mcount name from the triple ...

Matt Arsenault via All-commits all-commits at lists.llvm.org
Tue Sep 15 03:19:33 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 263bbd476c9fce30acb9c70d5dae556dd994b08b
      https://github.com/llvm/llvm-project/commit/263bbd476c9fce30acb9c70d5dae556dd994b08b
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2026-09-15 (Tue, 15 Sep 2026)

  Changed paths:
    M clang/lib/Basic/Targets/AArch64.cpp
    M clang/lib/Basic/Targets/ARM.cpp
    M clang/test/Frontend/gnu-mcount.c

  Log Message:
  -----------
  clang/ARM: Derive -pg mcount name from the triple environment (#220822)

For a glibc/gnueabi ARM and AArch64 targets, GCC's -pg instrumentation
always calls __gnu_mcount_nc (with the caller pushing LR, per the "nc"
no-LR-clobber ABI). clang only produced this when -meabi=gnu was passed
explicitly; a separate gnueabi triple wrongly called plain "mcount".

On ARM, glibc's EABI profiling entry point is __gnu_mcount_nc
(sysdeps/arm/arm-mcount.S, exported since GLIBC_2.8). It does provide
plain mcount/_mcount, but only as a legacy APCS compat alias
(__mcount_arm_compat, gated on GCC_COMPAT(4,3)/SHLIB_COMPAT) 
that reads an APCS frame-pointer record rather than following the EABI push-LR 
convention. Calling it from EABI -pg code is thus an ABI mismatch, not the intended 
entry point.

Derive the GNU-vs-plain mcount name from the triple environment in
addition to the explicit -meabi=gnu, so a gnueabi target gets the correct
__gnu_mcount_nc call by default, matching GCC:

    push    {lr}
    bl      __gnu_mcount_nc

clang vs. gcc mismatch: https://godbolt.org/z/erEqfxs3s

Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list