Skip to content

return_address intrinsic problematic with MIR and hard/impossible to use safely. #34227

Closed
servo/servo
#11872
@eddyb

Description

@eddyb

Servo currently can't compile with -Zorbit (see servo/servo#11706) and my suspect is return_address.

Even if that wasn't the reason, Servo's usage of return_address to create a rooting cycle only ever worked because it happened to get the final destination of the call, but with MIR, the call destination might be a temporary, so it's not the final destination anymore.
Servo has a lint for disallowing moves on the types that are being returned, but that analysis is wrong unless performed on exactly the MIR we translate.

We also could change the ABI at any time, so the indirect returns becomes direct (we can do this for any pair of pointer-sized values) which would also break Servo.
I'm not even sure how LLVM doesn't miscompile what Servo is doing, capturing an sret argument seems quite dubious to me, and some architectures also have an intermediary copy.

AFAIK, the eventual solution is to have proper stack map support, however that might be a long ways off and I don't want to block removing old trans on it.

cc @jdm @pcwalton @Manishearth @rust-lang/compiler

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlP-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions