Skip to content

Add instrumentation for constructors #4

Description

@momvart

Constructors can appear in the final program when they are passed as function pointers. Example:

use leaf::annotations::Symbolizable;

fn main() {
    let x = call_x(X);
    if x.0 == 20 {
        core::hint::black_box(0);
    }
}

struct X(i32);

fn call_x(x: fn(i32) -> X) -> X {
    x(5.mark_symbolic())
}

However, as mir_for_ctfe is used to obtain their MIR, they are not instrumented and consequently treated as external functions. Also, overriding mir_for_ctfe is presumably problematic as it is used for constant evaluation as well. It may be possible to avoid the problem using const_eval_select.

rust-lang/rust#131650 seems to make MIR overriding possible at the codegen phase. We can wait for that to add support for everything.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-compilerArea: The compiler and instrumentationenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions