This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Base implementation for sret demotion.
ClosedPublic

Authored by cdevadas on Dec 9 2020, 11:07 AM.

Details

Summary

If the return values can't be lowered to registers
SelectionDAG perform the sret demotion. This patch
contains the basic implementation for the same in
the GlobalISel pipeline.

Furthermore, targets should bring relevant changes
during lowerFormalArguments, lowerReturn and
lowerCall to make use of this feature.

Diff Detail

Event Timeline

cdevadas created this revision.Dec 9 2020, 11:07 AM
cdevadas requested review of this revision.Dec 9 2020, 11:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2020, 11:07 AM

Thanks for working on this!

Can you include a testcase for this?

Not sure I can have one at this point.
There is a follow-up patch I am making to enable it for AMDGPU. I will have some tests along with that.

arsenm added inline comments.Dec 14 2020, 3:12 PM
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
575–584

I think something is off here because this shouldn't depend on the NumRegistersForCallingConv code

llvm/tools/llvm-exegesis/lib/Assembler.cpp
124–138

I'm surprised this is here

cdevadas added inline comments.Dec 15 2020, 4:10 AM
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
575–584

Why do you think so?
getNumRegistersForCallingConv helps here to get the actual number of target registers required for the return type.

arsenm added inline comments.Dec 16 2020, 7:58 AM
llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
575–584

Nevermind, I have this backwards

arsenm added inline comments.Jan 4 2021, 10:07 AM
llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
318–320

s/handle/insert/?

Should this return DemoteReg rather than accept it as an argument?

arsenm accepted this revision.Jan 5 2021, 7:48 AM
This revision is now accepted and ready to land.Jan 5 2021, 7:48 AM
This revision was landed with ongoing or failed builds.Jan 5 2021, 9:07 PM
This revision was automatically updated to reflect the committed changes.