[PATCH] D97070: [ValueTypes] Assert if changeVectorElementType is called on a simple type with an extended element type.
Craig Topper via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 19 11:30:29 PST 2021
craig.topper created this revision.
craig.topper added reviewers: RKSimon, frasercrmck, pengfei, spatel, efriedma.
Herald added a subscriber: hiraditya.
craig.topper requested review of this revision.
Herald added a project: LLVM.
Previously we would use the extended implementation, but
the extended implementation requires the vector type to be extended
so that we can access the LLVMContext. In theory we could
detect this case and use the context from the element type instead,
but since I know of no cases hitting this in practice today
I've done the simplest thing.
Also add asserts to several extended EVT functions that assume
LLVMTy is non-null.
Follow from discussion in D97036 <https://reviews.llvm.org/D97036>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97070
Files:
llvm/include/llvm/CodeGen/ValueTypes.h
llvm/lib/CodeGen/ValueTypes.cpp
Index: llvm/lib/CodeGen/ValueTypes.cpp
===================================================================
--- llvm/lib/CodeGen/ValueTypes.cpp
+++ llvm/lib/CodeGen/ValueTypes.cpp
@@ -15,11 +15,13 @@
using namespace llvm;
EVT EVT::changeExtendedTypeToInteger() const {
+ assert(isExtended() && "Type is not extended!");
LLVMContext &Context = LLVMTy->getContext();
return getIntegerVT(Context, getSizeInBits());
}
EVT EVT::changeExtendedVectorElementTypeToInteger() const {
+ assert(isExtended() && "Type is not extended!");
LLVMContext &Context = LLVMTy->getContext();
EVT IntTy = getIntegerVT(Context, getScalarSizeInBits());
return getVectorVT(Context, IntTy, getVectorNumElements(),
@@ -27,6 +29,7 @@
}
EVT EVT::changeExtendedVectorElementType(EVT EltVT) const {
+ assert(isExtended() && "Type is not extended!");
LLVMContext &Context = LLVMTy->getContext();
return getVectorVT(Context, EltVT, getVectorElementCount());
}
Index: llvm/include/llvm/CodeGen/ValueTypes.h
===================================================================
--- llvm/include/llvm/CodeGen/ValueTypes.h
+++ llvm/include/llvm/CodeGen/ValueTypes.h
@@ -100,8 +100,11 @@
/// Return a VT for a vector type whose attributes match ourselves
/// with the exception of the element type that is chosen by the caller.
EVT changeVectorElementType(EVT EltVT) const {
- if (isSimple() && EltVT.isSimple())
+ if (isSimple()) {
+ assert(EltVT.isSimple() &&
+ "Can't change simple vector VT to have extended element VT");
return getSimpleVT().changeVectorElementType(EltVT.getSimpleVT());
+ }
return changeExtendedVectorElementType(EltVT);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97070.325049.patch
Type: text/x-patch
Size: 1715 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210219/4cd612a5/attachment.bin>
More information about the llvm-commits
mailing list