[llvm] r231760 - Fix a stack overflow in the assembler when checking that GEPs must be over sized types.
Owen Anderson
resistor at mac.com
Mon Mar 9 23:34:57 PDT 2015
Author: resistor
Date: Tue Mar 10 01:34:57 2015
New Revision: 231760
URL: http://llvm.org/viewvc/llvm-project?rev=231760&view=rev
Log:
Fix a stack overflow in the assembler when checking that GEPs must be over sized types.
We failed to use a marking set to properly handle recursive types, which caused use
to recurse infinitely and eventually overflow the stack.
Added:
llvm/trunk/test/Assembler/unsized-recursive-type.ll
Modified:
llvm/trunk/lib/AsmParser/LLParser.cpp
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=231760&r1=231759&r2=231760&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Tue Mar 10 01:34:57 2015
@@ -2810,7 +2810,9 @@ bool LLParser::ParseValID(ValID &ID, Per
}
}
- if (!Indices.empty() && !BasePointerType->getElementType()->isSized())
+ SmallPtrSet<const Type*, 4> Visited;
+ if (!Indices.empty() &&
+ !BasePointerType->getElementType()->isSized(&Visited))
return Error(ID.Loc, "base element of getelementptr must be sized");
if (!GetElementPtrInst::getIndexedType(Elts[0]->getType(), Indices))
@@ -5496,7 +5498,9 @@ int LLParser::ParseGetElementPtr(Instruc
Indices.push_back(Val);
}
- if (!Indices.empty() && !BasePointerType->getElementType()->isSized())
+ SmallPtrSet<const Type*, 4> Visited;
+ if (!Indices.empty() &&
+ !BasePointerType->getElementType()->isSized(&Visited))
return Error(Loc, "base element of getelementptr must be sized");
if (!GetElementPtrInst::getIndexedType(BaseType, Indices))
Added: llvm/trunk/test/Assembler/unsized-recursive-type.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/unsized-recursive-type.ll?rev=231760&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/unsized-recursive-type.ll (added)
+++ llvm/trunk/test/Assembler/unsized-recursive-type.ll Tue Mar 10 01:34:57 2015
@@ -0,0 +1,9 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+
+; CHECK: base element of getelementptr must be sized
+
+%myTy = type { %myTy }
+define void @foo(%myTy* %p){
+ %0 = getelementptr %myTy, %myTy* %p, i32 0
+ ret void
+}
More information about the llvm-commits
mailing list