This is an archive of the discontinued LLVM Phabricator instance.

[LLParser] Remove special handling for call address space
ClosedPublic

Authored by nikic on Jun 22 2021, 2:40 PM.

Details

Summary

Spin-off from D104740: I don't think this special handling is needed at all. Calls in textual IR are annotated with addrspace(N) (which defaults to the program address space from data layout) and specifies the expected pointer address space of the callee. There is no need to special-case the program address space on top of that, as it already is the default expected address space, and we shouldn't allow use of the program address space if the call was explicitly annotated with some other address space.

No tests fail with this special handling removed.

Diff Detail

Event Timeline

nikic created this revision.Jun 22 2021, 2:40 PM
nikic requested review of this revision.Jun 22 2021, 2:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2021, 2:40 PM

I'm confused by "The pointer address space of the callee should always match the specified addrspace". The addrspace on the call sounds like it's basically the "expected" addrspace and could affect lower of the call instruction itself. But the call operand might not be of that addrspace, whether it's a direct call's callee, or an indirect call's function pointer.

llvm/lib/AsmParser/LLParser.cpp
1472

IsCall isn't being used anymore

I'm confused by "The pointer address space of the callee should always match the specified addrspace". The addrspace on the call sounds like it's basically the "expected" addrspace and could affect lower of the call instruction itself. But the call operand might not be of that addrspace, whether it's a direct call's callee, or an indirect call's function pointer.

LangRef says:

The optional addrspace attribute can be used to indicate the address space of the called function. If it is not specified, the program address space from the datalayout string will be used.

My reading here is that the call addrspace and the callee addrspace must be the same.

Looking back over D47541, I think this code is an artifact from an earlier version of the patch that did not have addrspace on calls.

llvm/lib/AsmParser/LLParser.cpp
1472

It will be used by D104740 again, so I don't want to remove the parameter. I can comment the name though.

nikic updated this revision to Diff 353877.Jun 23 2021, 1:38 AM
nikic edited the summary of this revision. (Show Details)

Comment temporarily unused parameter name to make sure it doesn't warn.

One more thing to note here, because it probably wasn't clear from my original description: The call addrspace is a pure textural IR concept and is only used to determine the expected address space of the callee pointer type. There is no concept of a call addrspace for in-memory IR, just the addrspace of the callee pointer type.

I'm confused by "The pointer address space of the callee should always match the specified addrspace". The addrspace on the call sounds like it's basically the "expected" addrspace and could affect lower of the call instruction itself. But the call operand might not be of that addrspace, whether it's a direct call's callee, or an indirect call's function pointer.

LangRef says:

The optional addrspace attribute can be used to indicate the address space of the called function. If it is not specified, the program address space from the datalayout string will be used.

My reading here is that the call addrspace and the callee addrspace must be the same.

Looking back over D47541, I think this code is an artifact from an earlier version of the patch that did not have addrspace on calls.

It's been a long time since I looked at that code, but it was originally needed to avoid adding addrspace(200) to every call instruction. I just tried removing this from our downstream CHERI LLParser.cpp and all tests are still passing so it is clearly no longer needed.

arichardson accepted this revision.Jun 23 2021, 2:35 AM
This revision is now accepted and ready to land.Jun 23 2021, 2:35 AM
nikic added a comment.Jun 23 2021, 3:02 AM

It's been a long time since I looked at that code, but it was originally needed to avoid adding addrspace(200) to every call instruction. I just tried removing this from our downstream CHERI LLParser.cpp and all tests are still passing so it is clearly no longer needed.

Thanks for checking!

This revision was landed with ongoing or failed builds.Jun 23 2021, 3:08 AM
This revision was automatically updated to reflect the committed changes.