This is an archive of the discontinued LLVM Phabricator instance.

GlobalISel: Add utilty for getting function argument live ins
ClosedPublic

Authored by arsenm on Jul 20 2020, 2:01 PM.

Details

Summary

Get the argument register and ensure there's a copy to the virtual
register. AMDGPU and AArch64 have similarish code to get the livein
value, and I also want to use this in multiple places.

This is a bit more aggressive about setting the register class than
the original function, but that's probably OK.

I think we're missing a few verifier checks for function live ins. I
noticed AArch64's calling convention code is not actually adding
liveins to functions, only the entry block (which apparently might
not matter that much?). There should probably be a verifier
check that entry block live ins are also live into the function. We
also might need a verifier check that the copy to the livein virtual
register is in the entry block.

Diff Detail

Event Timeline

arsenm created this revision.Jul 20 2020, 2:01 PM
paquette added inline comments.
llvm/lib/CodeGen/GlobalISel/Utils.cpp
501

Should this be RegTy to match Utils.h?

(Or should it be Ty in Utils.h?)

502

@aprantl, what do you think about this?

524

Why not MachineIRBuilder?

arsenm marked an inline comment as done.Jul 21 2020, 2:17 PM
arsenm added inline comments.
llvm/lib/CodeGen/GlobalISel/Utils.cpp
524

I think single use MachineIRBuilders are a bad idea since they maintain observers and CSEinfo etc. I could have it pass in one, but then it would have to change the insert block / insert point and restore it which is more complicated.

hsmhsm added inline comments.Jul 22 2020, 2:03 AM
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
4713

Is not it, the function name supposed to be - getFunctionLiveInVirtualReg?

hsmhsm accepted this revision.Jul 22 2020, 2:07 AM

IMHO, it is a good idea to add a generic utility support to get a virtual live-in register for a given physical register. Otherwise, each target land-up implementing it as I had done it for AMDGPU target sometime back. Thanks for cleaning it up. Except for my above minor comment, it is LGTM from my side unless other reviewers have any additional comments.

This revision is now accepted and ready to land.Jul 22 2020, 2:07 AM

IMHO, it is a good idea to add a generic utility support to get a virtual live-in register for a given physical register. Otherwise, each target land-up implementing it as I had done it for AMDGPU target sometime back. Thanks for cleaning it up. Except for my above minor comment, it is LGTM from my side unless other reviewers have any additional comments.

The intent is to get the value for the physical register

aemerson added inline comments.Jul 24 2020, 5:32 PM
llvm/lib/CodeGen/GlobalISel/Utils.cpp
502

I think this is probably fine since it's just a copy from an argument.,