This is an archive of the discontinued LLVM Phabricator instance.

[X86] Fix a codegen crash in getSetCCResultType
ClosedPublic

Authored by pengfei on Feb 19 2021, 12:50 AM.

Details

Summary

This patch fixes some crashes coming from
X86ISelLowering::getSetCCResultType, which would occasionally return
an EVT constructed from an invalid MVT, which has a null Type pointer.

This patch refers to D95434.

Diff Detail

Event Timeline

pengfei created this revision.Feb 19 2021, 12:50 AM
pengfei requested review of this revision.Feb 19 2021, 12:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 19 2021, 12:50 AM

I don’t think I understand. VT is an EVT. Why does changeVectorElementType involve MVT?

craig.topper accepted this revision.Feb 19 2021, 1:23 AM

Oh I see. changeVectorElementType assumes that if the type is simple and type to change to is simple it will succeed in MVT. That seems like a poor implementation. Maybe it should check the result and fallback to the extended implementation of it fails on MVT?

This patch seems fine though. LGTM

This revision is now accepted and ready to land.Feb 19 2021, 1:23 AM
frasercrmck accepted this revision.Feb 19 2021, 1:26 AM

Oh I see. changeVectorElementType assumes that if the type is simple and type to change to is simple it will succeed in MVT. That seems like a poor implementation. Maybe it should check the result and fallback to the extended implementation of it fails on MVT?

Yeah that's.. questionable. I'd +1 that change.

This change, though, LGTM.

If I'm not mistaken, changeTypeToInteger and changeVectorElementTypeToInteger could in theory suffer from the same problem. Though less likely, as any MVT is most likely going to have an MVT with the same-sized integer type.

This revision was landed with ongoing or failed builds.Feb 19 2021, 1:30 AM
This revision was automatically updated to reflect the committed changes.

Thanks Craig and Fraser.

Oh I see. changeVectorElementType assumes that if the type is simple and type to change to is simple it will succeed in MVT. That seems like a poor implementation. Maybe it should check the result and fallback to the extended implementation of it fails on MVT?

Yeah that's.. questionable. I'd +1 that change.

This change, though, LGTM.

Grrr. We can't make this change. The extended implementation relies on there being an LLVMTy to get context from. I think there's a bug in EVT::changeVectorElementType if the vector type is simple, but the element type is not. We'll fall into extended implementation, but LLVMTy is null.

yubing added a subscriber: yubing.Feb 19 2021, 8:56 PM