Skip to content

[clang] __is_trivially_relocatable isn't correct on Windows #69394

Open
@rnk

Description

@rnk

As implemented in https://reviews.llvm.org/D119017 and https://reviews.llvm.org/D114732, the __is_trivially_relocatable type trait is built on top of canPassInRegisters, which was never meant to implement this type trait:

return RD->canPassInRegisters();

canPassInRegisters is full of various size checks that have nothing to do with trivial relocatability:

bool isAArch64 = S.Context.getTargetInfo().getTriple().isAArch64();
uint64_t TypeSize = isAArch64 ? 128 : 64;
if (CopyCtorIsTrivial &&
S.getASTContext().getTypeSize(D->getTypeForDecl()) <= TypeSize)
return true;
return false;

This means __is_trivial_relocatability doesn't work correctly on Windows or PS4.

There are extensive comments on the original review which I haven't read through, but it seems like the proper solution is to track trivial relocatability as a type trait, and then use that to inform whether things get passed in registers.

I think (at risk of misremembering) that I suggested the name of "canPassInRegisters", and what I think I had in mind is that we should name it something intentionally hyper-specific and low-level so that folks don't rely on it for any other purpose, but I guess that didn't work out as planned. I guess it wasn't that great of a plan in the first place.

cc @zygoloid @ssbr @zmodem @danakj

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