Skip to content

Instrumentation before ret may break on musttail calls #196

Description

@Yejashi

Description:
The current instrumentation logic for insertAfter inserts a call right before every ret or resume. This is unsafe when the return is immediately preceded by a musttail call.

LLVM requires that a musttail call be followed immediately by the return, with no intervening instructions. Inserting instrumentation there violates the verifier rules and produces invalid IR.

Steps to Reproduce:

Write a function with [[clang::musttail]] in C++ (or use another frontend that emits musttail).

Run the pass.

The verifier would potentiall fail because the injected call appears between the musttail and the ret.

Impact:
Rare in plain C++, but possible in code that explicitly uses [[clang::musttail]] or when working with frontends that emit musttail.

This is probable a very minor nitpick that will most likely never present itself, but i thought i might mention it just in case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions