diff options
author | Fraser Cormack <fraser@codeplay.com> | 2021-01-26 11:36:56 +0000 |
---|---|---|
committer | Fraser Cormack <fraser@codeplay.com> | 2021-01-27 10:22:54 +0000 |
commit | 9a75a808c27f2d7a3ef4880be5f3febc97d5dcd2 (patch) | |
tree | 47ad254f2597cfc5902f6abe806e245586a13e5f /llvm/lib | |
parent | a8f51ea2120bc454e3e3ece6995febe47fbb98d1 (diff) | |
download | llvm-9a75a808c27f2d7a3ef4880be5f3febc97d5dcd2.zip llvm-9a75a808c27f2d7a3ef4880be5f3febc97d5dcd2.tar.gz llvm-9a75a808c27f2d7a3ef4880be5f3febc97d5dcd2.tar.bz2 |
[RISCV] Fix a codegen crash in getSetCCResultType
This patch fixes some crashes coming from
`RISCVISelLowering::getSetCCResultType`, which would occasionally return
an EVT constructed from an invalid MVT, which has a null Type pointer.
The attached test shows this happening currently for some fixed-length
vectors, which hit this issue when the V extension was enabled, even
though they're not legal types under the V extension. The fix was also
pre-emptively extended to scalable vectors which can't be represented as
an MVT, even though a test case couldn't be found for them.
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D95434
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp index 97f46d9..9bf1d70 100644 --- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -481,12 +481,13 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM, } } -EVT RISCVTargetLowering::getSetCCResultType(const DataLayout &DL, LLVMContext &, +EVT RISCVTargetLowering::getSetCCResultType(const DataLayout &DL, + LLVMContext &Context, EVT VT) const { if (!VT.isVector()) return getPointerTy(DL); - if (Subtarget.hasStdExtV()) - return MVT::getVectorVT(MVT::i1, VT.getVectorElementCount()); + if (Subtarget.hasStdExtV() && VT.isScalableVector()) + return EVT::getVectorVT(Context, MVT::i1, VT.getVectorElementCount()); return VT.changeVectorElementTypeToInteger(); } |