Skip to content

[BOLT] Frame pointers break instrumentation #148595

@peterwaller-arm

Description

@peterwaller-arm

This issue is split from #147569, which is now thought to be an independent problem.

With frame pointers enabled in the bolt runtimes, bolt instrumentation causes the workload to crash due to stack corruption. A fix is available in #148009. Notably this happened in nixpkgs recently when they turned on frame pointers across the whole package set.

The cause is thought to be the use of -mno-omit-leaf-frame-pointer, which causes GCC to emit a prolog/epilogue on some functions implemented in assembly even if they are marked __attribute((naked)), per https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77882.

extern "C" __attribute((naked)) void __bolt_instr_indirect_call()

Example generated code:

0000000000000000 <__bolt_instr_indirect_call>:
       0:       a9bf7bfd        stp     x29, x30, [sp, #-16]!
       4:       910003fd        mov     x29, sp
       8:       a9bf07e0        stp     x0, x1, [sp, #-16]!
       c:       a9bf0fe2        stp     x2, x3, [sp, #-16]!
      10:       a9bf17e4        stp     x4, x5, [sp, #-16]!
      14:       a9bf1fe6        stp     x6, x7, [sp, #-16]!
      18:       a9bf27e8        stp     x8, x9, [sp, #-16]!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions