summaryrefslogtreecommitdiffstats
path: root/llvm/lib/AsmParser
diff options
context:
space:
mode:
authorMichael Kuperstein <mkuper@google.com>2016-12-21 18:29:47 +0000
committerMichael Kuperstein <mkuper@google.com>2016-12-21 18:29:47 +0000
commit88f15eedbbf49c88f4386e0400936b8874fd5717 (patch)
tree11d9754154f8ebe160c60bc3a38022c611c0ec16 /llvm/lib/AsmParser
parentdd92c78669da0c3e0c285b0723ee5ecba12ca1df (diff)
downloadbcm5719-llvm-88f15eedbbf49c88f4386e0400936b8874fd5717.tar.gz
bcm5719-llvm-88f15eedbbf49c88f4386e0400936b8874fd5717.zip
[LLParser] Parse vector GEP constant expression correctly
The constantexpr parsing was too constrained and rejected legal vector GEPs. This relaxes it to be similar to the ones for instruction parsing. This fixes PR30816. Differential Revision: https://reviews.llvm.org/D28013 llvm-svn: 290261
Diffstat (limited to 'llvm/lib/AsmParser')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 712a2c6762d..d1891b7feb0 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -3193,20 +3193,23 @@ bool LLParser::ParseValID(ValID &ID, PerFunctionState *PFS) {
ExplicitTypeLoc,
"explicit pointee type doesn't match operand's pointee type");
+ unsigned GEPWidth =
+ BaseType->isVectorTy() ? BaseType->getVectorNumElements() : 0;
+
ArrayRef<Constant *> Indices(Elts.begin() + 1, Elts.end());
for (Constant *Val : Indices) {
Type *ValTy = Val->getType();
if (!ValTy->getScalarType()->isIntegerTy())
return Error(ID.Loc, "getelementptr index must be an integer");
- if (ValTy->isVectorTy() != BaseType->isVectorTy())
- return Error(ID.Loc, "getelementptr index type missmatch");
if (ValTy->isVectorTy()) {
unsigned ValNumEl = ValTy->getVectorNumElements();
- unsigned PtrNumEl = BaseType->getVectorNumElements();
- if (ValNumEl != PtrNumEl)
+ if (GEPWidth && (ValNumEl != GEPWidth))
return Error(
ID.Loc,
"getelementptr vector index has a wrong number of elements");
+ // GEPWidth may have been unknown because the base is a scalar,
+ // but it is known now.
+ GEPWidth = ValNumEl;
}
}
OpenPOWER on IntegriCloud