We use hard coded Int32Ty while converting aggregate copy to a memmove,
which is wrong in case of PIC16.(PIC16 has int type as i16).

I have attached a patch to address this. Please let me know if it is ok
to commit. 


- Sanjiv

Index: CGExprAgg.cpp
===================================================================
--- CGExprAgg.cpp	(revision 59613)
+++ CGExprAgg.cpp	(working copy)
@@ -467,10 +467,17 @@
   // FIXME: Handle variable sized types.
   const llvm::Type *IntPtr = llvm::IntegerType::get(LLVMPointerWidth);
   
+  // Get the right int type.
+  const llvm::Type *IntTy;
+  switch (LLVMPointerWidth) {
+  default : assert (0 && "Unknown pointer size"); break;
+  case 16 : IntTy = llvm::Type::Int16Ty; break;
+  case 32 : IntTy = llvm::Type::Int32Ty; break;  
+  }
+
   Builder.CreateCall4(CGM.getMemMoveFn(),
                       DestPtr, SrcPtr,
                       // TypeInfo.first describes size in bits.
                       llvm::ConstantInt::get(IntPtr, TypeInfo.first/8),
-                      llvm::ConstantInt::get(llvm::Type::Int32Ty, 
-                                             TypeInfo.second/8));
+                      llvm::ConstantInt::get(IntTy, TypeInfo.second/8));
 }
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to