[llvm] r232143 - Fix an infinite recursion in the verifier caused by calling isSized on a recursive type.

Owen Anderson resistor at mac.com
Thu Mar 12 23:41:26 PDT 2015


Author: resistor
Date: Fri Mar 13 01:41:26 2015
New Revision: 232143

URL: http://llvm.org/viewvc/llvm-project?rev=232143&view=rev
Log:
Fix an infinite recursion in the verifier caused by calling isSized on a recursive type.

Added:
    llvm/trunk/test/Verifier/recursive-struct-param.ll
Modified:
    llvm/trunk/lib/IR/Verifier.cpp

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=232143&r1=232142&r2=232143&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Fri Mar 13 01:41:26 2015
@@ -1014,7 +1014,8 @@ void Verifier::VerifyParameterAttrs(Attr
          V);
 
   if (PointerType *PTy = dyn_cast<PointerType>(Ty)) {
-    if (!PTy->getElementType()->isSized()) {
+    SmallPtrSet<const Type*, 4> Visited;
+    if (!PTy->getElementType()->isSized(&Visited)) {
       Assert(!Attrs.hasAttribute(Idx, Attribute::ByVal) &&
                  !Attrs.hasAttribute(Idx, Attribute::InAlloca),
              "Attributes 'byval' and 'inalloca' do not support unsized types!",

Added: llvm/trunk/test/Verifier/recursive-struct-param.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/recursive-struct-param.ll?rev=232143&view=auto
==============================================================================
--- llvm/trunk/test/Verifier/recursive-struct-param.ll (added)
+++ llvm/trunk/test/Verifier/recursive-struct-param.ll Fri Mar 13 01:41:26 2015
@@ -0,0 +1,15 @@
+; RUN: opt -verify < %s
+
+%struct.__sFILE = type { %struct.__sFILE }
+
+ at .str = private unnamed_addr constant [13 x i8] c"Hello world\0A\00", align 1
+
+; Function Attrs: nounwind ssp
+define void @test(%struct.__sFILE* %stream, i8* %str) {
+  %fputs = call i32 @fputs(i8* %str, %struct.__sFILE* %stream)
+  ret void
+}
+
+; Function Attrs: nounwind
+declare i32 @fputs(i8* nocapture, %struct.__sFILE* nocapture)
+





More information about the llvm-commits mailing list