[PATCH] D28013: [LLParser] Reader vector GEP ConsantExpr correctly
Michael Kuperstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 20 18:18:51 PST 2016
mkuper created this revision.
mkuper added reviewers: davide, delena.
mkuper added a subscriber: llvm-commits.
The CE version was too constrained - it seems like it was not relaxed enough when vector GEPs were introduces.
This relaxes the checks to be similar to the ones for the instruction version.
This fixes PR30816.
https://reviews.llvm.org/D28013
Files:
lib/AsmParser/LLParser.cpp
test/Assembler/getelementptr_vec_ce.ll
Index: test/Assembler/getelementptr_vec_ce.ll
===================================================================
--- test/Assembler/getelementptr_vec_ce.ll
+++ test/Assembler/getelementptr_vec_ce.ll
@@ -0,0 +1,9 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+ at G = global [4 x i32] zeroinitializer
+
+; CHECK-LABEL: @foo
+; CHECK: ret <4 x i32*> getelementptr ([4 x i32], [4 x i32]* @G, <4 x i32> zeroinitializer, <4 x i32> <i32 0, i32 1, i32 2, i32 3>)
+define <4 x i32*> @foo() {
+ ret <4 x i32*> getelementptr ([4 x i32], [4 x i32]* @G, i32 0, <4 x i32> <i32 0, i32 1, i32 2, i32 3>)
+}
Index: lib/AsmParser/LLParser.cpp
===================================================================
--- lib/AsmParser/LLParser.cpp
+++ lib/AsmParser/LLParser.cpp
@@ -3193,17 +3193,17 @@
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");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28013.82191.patch
Type: text/x-patch
Size: 1782 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161221/eded9d6b/attachment.bin>
More information about the llvm-commits
mailing list