[llvm-commits] [llvm] r59612 - /llvm/trunk/include/llvm/Intrinsics.td

Chris Lattner clattner at apple.com
Thu Nov 20 10:45:52 PST 2008


On Nov 20, 2008, at 2:21 AM, sanjiv gupta wrote:

> Please find the attached patch. Let me know if it looks okay.

Very nice, this is a great cleanup.  One minor bug:

+++ lib/Transforms/Utils/InlineFunction.cpp	(working copy)
@@ -258,7 +258,7 @@
                                            Caller->begin()->begin());
          // Emit a memcpy.
          Function *MemCpyFn = Intrinsic::getDeclaration(Caller- 
 >getParent(),
+                                                        
Intrinsic::memcpy);

This needs to pass in Int64Ty to getDeclaration.  Something like this  
should work:

const Type *Tys[] = { Type::Int64Ty };

... Intrinsic::getDeclaration(Caller->getParent(), Intrinsic::memcpy,
                               Tys, 1);

+++ lib/Transforms/Scalar/InstructionCombining.cpp	(working copy)
@@ -9177,11 +9177,7 @@
        if (GlobalVariable *GVSrc = dyn_cast<GlobalVariable>(MMI- 
 >getSource()))
          if (GVSrc->isConstant()) {
            Module *M = CI.getParent()->getParent()->getParent();
+          Intrinsic::ID MemCpyID = Intrinsic::memcpy;
            CI.setOperand(0, Intrinsic::getDeclaration(M, MemCpyID));


Likewise, this needs to pass in CI.getOperand(3)->getType().

+++ lib/Transforms/Scalar/SimplifyLibCalls.cpp	(working copy)
@@ -130,8 +130,7 @@
  Value *LibCallOptimization::EmitMemCpy(Value *Dst, Value *Src, Value  
*Len,
                                         unsigned Align, IRBuilder<>  
&B) {
    Module *M = Caller->getParent();
-  Intrinsic::ID IID = Len->getType() == Type::Int32Ty ?
-                           Intrinsic::memcpy_i32 :  
Intrinsic::memcpy_i64;
+  Intrinsic::ID IID = Intrinsic::memcpy;
    Value *MemCpy = Intrinsic::getDeclaration(M, IID);
    return B.CreateCall4(MemCpy, CastToCStr(Dst, B), CastToCStr(Src,  
B), Len,
                         ConstantInt::get(Type::Int32Ty, Align));

This needs to pass in Len->getType()

+++ lib/Transforms/Scalar/MemCpyOptimizer.cpp	(working copy)
@@ -429,7 +429,7 @@

      if (MemSetF == 0)
        MemSetF = Intrinsic::getDeclaration(SI->getParent()->getParent()
-                                          ->getParent(),  
Intrinsic::memset_i64);
+                                          ->getParent(),  
Intrinsic::memset);

This needs Int64_t.


===================================================================
--- examples/BrainF/BrainF.cpp	(revision 59621)
+++ examples/BrainF/BrainF.cpp	(working copy)
@@ -53,7 +53,7 @@
    //Function prototypes

    //declare void @llvm.memset.i32(i8 *, i8, i32, i32)
-  Function *memset_func = Intrinsic::getDeclaration(module,  
Intrinsic::memset_i32);
+  Function *memset_func = Intrinsic::getDeclaration(module,  
Intrinsic::memset);

This needs Int32Ty.







More information about the llvm-commits mailing list