From: Eli Friedman Date: Fri, 24 Jul 2009 21:56:17 +0000 (+0000) Subject: Fix assert assembling zero-argument constant GEP. X-Git-Tag: llvmorg-2.6.0~2411 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5c9cdb3e3a2cd9c6cc8dde8501a68c540d6f308d;p=platform%2Fupstream%2Fllvm.git Fix assert assembling zero-argument constant GEP. There's still a strict-aliasing violation here, but I don't feel like dealing with that right now... llvm-svn: 77005 --- diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 94224a6361c0..45e70c8f9c85 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -2017,10 +2017,11 @@ bool LLParser::ParseValID(ValID &ID) { return Error(ID.Loc, "getelementptr requires pointer operand"); if (!GetElementPtrInst::getIndexedType(Elts[0]->getType(), - (Value**)&Elts[1], Elts.size()-1)) + (Value**)(Elts.data() + 1), + Elts.size() - 1)) return Error(ID.Loc, "invalid indices for getelementptr"); ID.ConstantVal = Context.getConstantExprGetElementPtr(Elts[0], - &Elts[1], Elts.size()-1); + Elts.data() + 1, Elts.size() - 1); } else if (Opc == Instruction::Select) { if (Elts.size() != 3) return Error(ID.Loc, "expected three operands to select"); diff --git a/llvm/test/Assembler/2009-07-24-ZeroArgGEP.ll b/llvm/test/Assembler/2009-07-24-ZeroArgGEP.ll new file mode 100644 index 000000000000..ce4a96148615 --- /dev/null +++ b/llvm/test/Assembler/2009-07-24-ZeroArgGEP.ll @@ -0,0 +1,5 @@ +; RUN: llvm-as %s -o /dev/null -f + +@foo = global i32 0 +@bar = constant i32* getelementptr(i32* @foo) +