Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IR][CodeGen] Add new SizedCapabilityType for use in CodeGen #737

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

jrtc27
Copy link
Member

@jrtc27 jrtc27 commented May 18, 2024

EVT::getTypeForEVT currently returns a PointerType for MVT::cN, but this
has a couple of issues. The first issue is we have to hard-code the
address space, though that's not such a big deal given we do that
elsewhere too. The bigger issue is that, when we later pass that to
MVT::getVT or EVT::getEVT, it doesn't know what the right size is, so
returns MVT::cPTR instead, which is not a true value type, and is
supposed to only be used by TableGen. This has been seen to confuse
TargetLoweringBase::getTypeConversion, as when presented with a vector
of capability pointers it can end up trying to recreate a smaller vector
of the same type, but this trips up various assertions for the MVT::cPTR
as both the IR methods and the code here are expecting to be dealing
with actual value types.

Borrowing the idea of TypedPointerType (DXILPointerTyID) a bit,
introduce a new IR type, SizedCapabilityType, to represent a fixed-size
capability during CodeGen, which allows lossless roundtripping from MVT
to Type and back.

This fixes building cheritest, which has crashed since the introduction
of cPTR due to cPTR not being a value type, mirroring iPTR, unlike the
old iFATPTRAny which was its own weird beast, but wouldn't have tripped
up these assertions. It probably didn't do the most sensible things
though.

Fixes: 7aa7f2e ("[CodeGen] Rework MVT representation of capabilities and add type inference")

@jrtc27 jrtc27 requested a review from arichardson June 4, 2024 15:08
Copy link
Member

@arichardson arichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay here, too many GitHub notifications while I was out of office so somehow missed this one.

llvm/lib/IR/LLVMContextImpl.h Outdated Show resolved Hide resolved
llvm/lib/IR/AsmWriter.cpp Show resolved Hide resolved
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp Show resolved Hide resolved
@jrtc27 jrtc27 force-pushed the SizedCapabilityType branch 2 times, most recently from 5e65240 to 8c05d73 Compare June 4, 2024 22:33
EVT::getTypeForEVT currently returns a PointerType for MVT::cN, but this
has a couple of issues. The first issue is we have to hard-code the
address space, though that's not such a big deal given we do that
elsewhere too. The bigger issue is that, when we later pass that to
MVT::getVT or EVT::getEVT, it doesn't know what the right size is, so
returns MVT::cPTR instead, which is not a true value type, and is
supposed to only be used by TableGen. This has been seen to confuse
TargetLoweringBase::getTypeConversion, as when presented with a vector
of capability pointers it can end up trying to recreate a smaller vector
of the same type, but this trips up various assertions for the MVT::cPTR
as both the IR methods and the code here are expecting to be dealing
with actual value types.

Borrowing the idea of TypedPointerType (DXILPointerTyID) a bit,
introduce a new IR type, SizedCapabilityType, to represent a fixed-size
capability during CodeGen, which allows lossless roundtripping from MVT
to Type and back.

This fixes building cheritest, which has crashed since the introduction
of cPTR due to cPTR not being a value type, mirroring iPTR, unlike the
old iFATPTRAny which was its own weird beast, but wouldn't have tripped
up these assertions. It probably didn't do the most sensible things
though.

Fixes: 7aa7f2e ("[CodeGen] Rework MVT representation of capabilities and add type inference")
@jrtc27 jrtc27 force-pushed the SizedCapabilityType branch from 8c05d73 to f15bb20 Compare June 4, 2024 22:57
@jrtc27 jrtc27 merged commit 7dbdb0e into dev Jun 5, 2024
5 of 6 checks passed
@jrtc27 jrtc27 deleted the SizedCapabilityType branch June 5, 2024 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants