This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU: Initial, crude support for indirect calls
ClosedPublic

Authored by arsenm on Mar 16 2020, 7:02 PM.

Details

Summary

This isn't really usable, and requires using the
-amdgpu-fixed-function-abi flag to work.

Assumes a uniform call target, and will hit a verifier error if the
call target ends up in a VGPR. Also doesn't attempt to do anything
sensible for the reported register/stack usage.

Diff Detail

Event Timeline

arsenm created this revision.Mar 16 2020, 7:02 PM

Here's what I understood what this change is doing, based on just interpreting the names in the code for their English meaning: with this change, it is possible to call a function pointer. You can see a valid swappc in the caller, and the in/out arguments will be setup properly.

I understand that the register/stack usage for the callee is ignored. But assuming it happens to be valid, what else is required to declare that the call will actually work?

llvm/lib/Target/AMDGPU/SIISelLowering.cpp
2942–2944

I might be mistaken: Is this just emitting a call to nul if the symbol is not found? Does GSD here potentially represent a function pointer??

llvm/test/CodeGen/AMDGPU/indirect-call.ll
198

Should have one more test where the parameter passed to the callee is not an immediate.

arsenm marked an inline comment as done.Mar 17 2020, 8:12 AM
arsenm added inline comments.
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
2942–2944

No, the call target is passed below. This is a dummy parameter used to find the callee IR function to analyze the register/stack usage of the callee. It isn't used for the call itself

sameerds accepted this revision.Mar 17 2020, 9:06 AM
sameerds added inline comments.
llvm/test/CodeGen/AMDGPU/indirect-call.ll
198

I suppose there is nothing special about the parameter handling for this change. So I'll leave it to @arsenm to decide if such a test is necessary.

This revision is now accepted and ready to land.Mar 17 2020, 9:06 AM
nhaehnle accepted this revision.Mar 18 2020, 7:31 AM

I'm okay with landing this.