Skip to content

Definite last use for in parameters when passing to another function. #32

@happycr

Description

@happycr

If I understand Appendix 1 correctly, a function of the form:

// Where B is a large type.
void f(in B b) {
    use(b);
}

generates the following code for the moment (ignoring bit flags):

void _generated_f(const B* b, bool __b_arg_is_nonconst_rvalue ) {
    if (__b_arg_is_nonconst_rvalue) {
        use(std::move(*b));
    }
    else {
        use(b);
    }
}

Assuming the function use takes b by an in parameter ( what else would it be? ) why doesn't the generated code look like this:

void _generated_f(const B* b, bool __b_arg_is_nonconst_rvalue) {
   use(b, __b_arg_is_nonconst_rvalue);
}

That way we remove one unnecessary branch and the function use can optimize for r values...
Is there something I am not understanding correctly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions