This is an archive of the discontinued LLVM Phabricator instance.

Mark SRet argument as pointer in SelectionDAGISel::LowerArguments
Needs ReviewPublic

Authored by JamesNagurne on Jul 1 2021, 12:48 PM.

Details

Summary

Mark SRet argument as pointer in SelectionDAGISel::LowerArguments

When the concept of pointers was added to ArgFlagsTy, lowered SRet
arguments were not marked as pointers.

I don't think this affects any upstream target, but the flag should still
be set for consistency.

Diff Detail

Event Timeline

JamesNagurne created this revision.Jul 1 2021, 12:48 PM
JamesNagurne requested review of this revision.Jul 1 2021, 12:48 PM
JamesNagurne edited the summary of this revision. (Show Details)Jul 1 2021, 12:48 PM
efriedma added a subscriber: efriedma.

I suspect this affects arm64_32, at least in terms of the generated SelectionDAG.

I suspect this affects arm64_32, at least in terms of the generated SelectionDAG.

The upstream targets that use the isPointer field (through CCIfPtr in the calling convention .td files) are AArch64 and X86.

A problem occurs iff a pointer type is handled in a calling convention prior to an explicit SRet being handled. I'm unfortunately not well versed in how those targets' conventions work, and I understand the implications of this change breaking the ABI. Do you know of any experts on the topics for the given targets?

efriedma added a subscriber: pengfei.

For AArch64, I added @t.p.northover as reviewer; he wrote the relevant code.

For x32, adding @pengfei ?

I suspect this is doing what we want, I just want to make sure this is isn't surprising to someone more familiar with the relevant targets.

I think the only thing X86 does for the pointer type is zero extend it to i64. So I think only x32 should be affected by it. Add @hvdijk who is familiar with x32 calling conversion.

hvdijk added a comment.EditedJul 3 2021, 7:07 AM

I think the only thing X86 does for the pointer type is zero extend it to i64. So I think only x32 should be affected by it. Add @hvdijk who is familiar with x32 calling conversion.

That's right. The same registers are used regardless of whether the type is zero extended, 32-bit integers and 32-bit pointers are returned in the same 64-bit registers, the difference is whether the caller is responsible for clearing the high bits of those registers. According to the ABI the caller is responsible for that for all pointer arguments, no exception is made for the implicit pointer argument for return values that cannot be returned in registers, so I think this change is correct for x32.