[llvm-commits] CVS: llvm/lib/CodeGen/IntrinsicLowering.cpp

Reid Spencer reid at x10sys.com
Sun Jan 28 14:28:16 PST 2007



Changes in directory llvm/lib/CodeGen:

IntrinsicLowering.cpp updated: 1.59 -> 1.60
---
Log message:

For PR1138: http://llvm.org/PR1138 :
Force memcpy to be the 32-bit variant. Since this is only used with
CBE and lli which both target 32-bit machines, this should be okay.


---
Diffs of the changes:  (+11 -4)

 IntrinsicLowering.cpp |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)


Index: llvm/lib/CodeGen/IntrinsicLowering.cpp
diff -u llvm/lib/CodeGen/IntrinsicLowering.cpp:1.59 llvm/lib/CodeGen/IntrinsicLowering.cpp:1.60
--- llvm/lib/CodeGen/IntrinsicLowering.cpp:1.59	Sun Jan 14 20:27:26 2007
+++ llvm/lib/CodeGen/IntrinsicLowering.cpp	Sun Jan 28 16:28:00 2007
@@ -77,13 +77,17 @@
         break;
       case Intrinsic::memcpy_i32:
       case Intrinsic::memcpy_i64:
-        EnsureFunctionExists(M, "memcpy", I->arg_begin(), --I->arg_end(),
-                             I->arg_begin()->getType());
+        M.getOrInsertFunction("memcpy", PointerType::get(Type::Int8Ty),
+                              PointerType::get(Type::Int8Ty), 
+                              PointerType::get(Type::Int8Ty), Type::Int32Ty,
+                              (Type *)0);
         break;
       case Intrinsic::memmove_i32:
       case Intrinsic::memmove_i64:
-        EnsureFunctionExists(M, "memmove", I->arg_begin(), --I->arg_end(),
-                             I->arg_begin()->getType());
+        M.getOrInsertFunction("memmove", PointerType::get(Type::Int8Ty),
+                              PointerType::get(Type::Int8Ty), 
+                              PointerType::get(Type::Int8Ty), Type::Int32Ty,
+                              (Type *)0);
         break;
       case Intrinsic::memset_i32:
       case Intrinsic::memset_i64:
@@ -360,6 +364,9 @@
   }
   case Intrinsic::memcpy_i64: {
     static Constant *MemcpyFCache = 0;
+    Value * Size = cast<Value>(CI->op_end()-1);
+    if (Size->getType() != Type::Int32Ty)
+      Size->replaceAllUsesWith(new TruncInst(Size, Type::Int32Ty));
     ReplaceCallWith("memcpy", CI, CI->op_begin()+1, CI->op_end()-1,
                      (*(CI->op_begin()+1))->getType(), MemcpyFCache);
     break;






More information about the llvm-commits mailing list