diff -urN ./llvm-3.1.src/tools/clang/lib/CodeGen/CodeGenTypes.cpp ./mod_llvm-3.1.src/tools/clang/lib/CodeGen/CodeGenTypes.cpp
--- ./llvm-3.1.src/tools/clang/lib/CodeGen/CodeGenTypes.cpp	2012-11-07 16:33:19.434309359 +0900
+++ ./mod_llvm-3.1.src/tools/clang/lib/CodeGen/CodeGenTypes.cpp	2012-11-07 16:40:45.119308650 +0900
@@ -86,6 +86,10 @@
 llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T){
   llvm::Type *R = ConvertType(T);
 
+  // Now, T can't be converted to llvm type because of cycled types.
+  if (R == 0)
+    return 0;
+
   // If this is a non-bool type, don't map it.
   if (!R->isIntegerTy(1))
     return R;
@@ -143,9 +147,14 @@
   // If this type would require laying out members that are currently being laid
   // out, don't do it.
   for (RecordDecl::field_iterator I = RD->field_begin(),
-       E = RD->field_end(); I != E; ++I)
+       E = RD->field_end(); I != E; ++I) {
     if (!isSafeToConvert(I->getType(), CGT, AlreadyChecked))
       return false;
+    // This code checks that field's type can be converted to llvm type.
+    // If this type is a cycled type, this returns false.
+    if (!CGT.ConvertTypeForMem(I->getType()))
+      return false;
+  }
   
   // If there are no problems, lets do it.
   return true;
@@ -394,6 +403,11 @@
     const PointerType *PTy = cast<PointerType>(Ty);
     QualType ETy = PTy->getPointeeType();
     llvm::Type *PointeeType = ConvertTypeForMem(ETy);
+
+    // Now, PointeeType can't be converted to llvm type because of cycled types.
+    if (PointeeType == 0)
+      return 0;
+
     if (PointeeType->isVoidTy())
       PointeeType = llvm::Type::getInt8Ty(getLLVMContext());
     unsigned AS = Context.getTargetAddressSpace(ETy);
@@ -453,21 +467,17 @@
     // cannot lower the function type.
     if (!isFuncTypeConvertible(FT)) {
       // This function's type depends on an incomplete tag type.
-      // Return a placeholder type.
-      ResultType = llvm::StructType::get(getLLVMContext());
-      
+      // Return zero.
       SkippedLayout = true;
-      break;
+      return 0;
     }
 
     // While we're converting the argument types for a function, we don't want
     // to recursively convert any pointed-to structs.  Converting directly-used
     // structs is ok though.
     if (!RecordsBeingLaidOut.insert(Ty)) {
-      ResultType = llvm::StructType::get(getLLVMContext());
-      
       SkippedLayout = true;
-      break;
+      return 0;
     }
     
     // The function type can be built; call the appropriate routines to
@@ -485,9 +495,8 @@
     // If there is something higher level prodding our CGFunctionInfo, then
     // don't recurse into it again.
     if (FunctionsBeingProcessed.count(FI)) {
-
-      ResultType = llvm::StructType::get(getLLVMContext());
       SkippedLayout = true;
+      return 0;
     } else {
 
       // Otherwise, we're good to go, go ahead and convert it.
