[llvm-commits] CVS: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp

Chris Lattner sabre at nondot.org
Mon Feb 12 21:59:09 PST 2007



Changes in directory llvm/lib/Transforms/IPO:

SimplifyLibCalls.cpp updated: 1.92 -> 1.93
---
Log message:

eliminate a bunch of vector-related heap traffic


---
Diffs of the changes:  (+53 -47)

 SimplifyLibCalls.cpp |  100 +++++++++++++++++++++++++++------------------------
 1 files changed, 53 insertions(+), 47 deletions(-)


Index: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
diff -u llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.92 llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.93
--- llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.92	Mon Feb  5 17:32:05 2007
+++ llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp	Mon Feb 12 23:58:53 2007
@@ -512,12 +512,12 @@
 
     // We have enough information to now generate the memcpy call to
     // do the concatenation for us.
-    std::vector<Value*> vals;
-    vals.push_back(gep); // destination
-    vals.push_back(ci->getOperand(2)); // source
-    vals.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); // length
-    vals.push_back(ConstantInt::get(Type::Int32Ty,1)); // alignment
-    new CallInst(SLC.get_memcpy(), vals, "", ci);
+    Value *vals[4];
+    vals[0] = gep; // destination
+    vals[1] = ci->getOperand(2); // source
+    vals[2] = ConstantInt::get(SLC.getIntPtrType(),len); // length
+    vals[3] = ConstantInt::get(Type::Int32Ty,1); // alignment
+    new CallInst(SLC.get_memcpy(), vals, 4, "", ci);
 
     // Finally, substitute the first operand of the strcat call for the
     // strcat call itself since strcat returns its first operand; and,
@@ -565,11 +565,12 @@
       // The second operand is not constant, or not signed. Just lower this to 
       // memchr since we know the length of the string since it is constant.
       Constant *f = SLC.get_memchr();
-      std::vector<Value*> args;
-      args.push_back(ci->getOperand(1));
-      args.push_back(ci->getOperand(2));
-      args.push_back(ConstantInt::get(SLC.getIntPtrType(), len));
-      ci->replaceAllUsesWith(new CallInst(f, args, ci->getName(), ci));
+      Value* args[3] = {
+        ci->getOperand(1),
+        ci->getOperand(2),
+        ConstantInt::get(SLC.getIntPtrType(), len)
+      };
+      ci->replaceAllUsesWith(new CallInst(f, args, 3, ci->getName(), ci));
       ci->eraseFromParent();
       return true;
     }
@@ -841,12 +842,12 @@
 
     // We have enough information to now generate the memcpy call to
     // do the concatenation for us.
-    std::vector<Value*> vals;
-    vals.push_back(dest); // destination
-    vals.push_back(src); // source
-    vals.push_back(ConstantInt::get(SLC.getIntPtrType(),len)); // length
-    vals.push_back(ConstantInt::get(Type::Int32Ty,1)); // alignment
-    new CallInst(SLC.get_memcpy(), vals, "", ci);
+    Value *vals[4] = {
+      dest, src,
+      ConstantInt::get(SLC.getIntPtrType(),len), // length
+      ConstantInt::get(Type::Int32Ty, 1) // alignment
+    };
+    new CallInst(SLC.get_memcpy(), vals, 4, "", ci);
 
     // Finally, substitute the first operand of the strcat call for the
     // strcat call itself since strcat returns its first operand; and,
@@ -1423,12 +1424,13 @@
       if (ci->getOperand(2)->getType() != PointerType::get(Type::Int8Ty))
         return false;
 
-      std::vector<Value*> args;
-      args.push_back(ci->getOperand(2));
-      args.push_back(ConstantInt::get(SLC.getIntPtrType(),len));
-      args.push_back(ConstantInt::get(SLC.getIntPtrType(),1));
-      args.push_back(ci->getOperand(1));
-      new CallInst(SLC.get_fwrite(FILEptr_type), args, ci->getName(), ci);
+      Value* args[4] = {
+        ci->getOperand(2),
+        ConstantInt::get(SLC.getIntPtrType(),len),
+        ConstantInt::get(SLC.getIntPtrType(),1),
+        ci->getOperand(1)
+      };
+      new CallInst(SLC.get_fwrite(FILEptr_type), args, 4, ci->getName(), ci);
       ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,len));
       ci->eraseFromParent();
       return true;
@@ -1454,12 +1456,13 @@
         if (getConstantStringLength(ci->getOperand(3), len, &CA)) {
           // fprintf(file,"%s",str) -> fwrite(str,strlen(str),1,file)
           const Type* FILEptr_type = ci->getOperand(1)->getType();
-          std::vector<Value*> args;
-          args.push_back(CastToCStr(ci->getOperand(3), *ci));
-          args.push_back(ConstantInt::get(SLC.getIntPtrType(), len));
-          args.push_back(ConstantInt::get(SLC.getIntPtrType(), 1));
-          args.push_back(ci->getOperand(1));
-          new CallInst(SLC.get_fwrite(FILEptr_type), args, ci->getName(), ci);
+          Value* args[4] = {
+            CastToCStr(ci->getOperand(3), *ci),
+            ConstantInt::get(SLC.getIntPtrType(), len),
+            ConstantInt::get(SLC.getIntPtrType(), 1),
+            ci->getOperand(1)
+          };
+          new CallInst(SLC.get_fwrite(FILEptr_type), args, 4,ci->getName(), ci);
           ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty, len));
         } else {
           // fprintf(file,"%s",str) -> fputs(str,file)
@@ -1542,12 +1545,13 @@
       len++;
 
       // sprintf(str,fmt) -> llvm.memcpy(str,fmt,strlen(fmt),1)
-      std::vector<Value*> args;
-      args.push_back(ci->getOperand(1));
-      args.push_back(ci->getOperand(2));
-      args.push_back(ConstantInt::get(SLC.getIntPtrType(),len));
-      args.push_back(ConstantInt::get(Type::Int32Ty,1));
-      new CallInst(SLC.get_memcpy(), args, "", ci);
+      Value *args[4] = {
+        ci->getOperand(1),
+        ci->getOperand(2),
+        ConstantInt::get(SLC.getIntPtrType(),len),
+        ConstantInt::get(Type::Int32Ty, 1)
+      };
+      new CallInst(SLC.get_memcpy(), args, 4, "", ci);
       ci->replaceAllUsesWith(ConstantInt::get(Type::Int32Ty,len));
       ci->eraseFromParent();
       return true;
@@ -1577,12 +1581,13 @@
       if (Len1->getType() != SLC.getIntPtrType())
         Len1 = CastInst::createIntegerCast(Len1, SLC.getIntPtrType(), false,
                                            Len1->getName(), ci);
-      std::vector<Value*> args;
-      args.push_back(CastToCStr(ci->getOperand(1), *ci));
-      args.push_back(CastToCStr(ci->getOperand(3), *ci));
-      args.push_back(Len1);
-      args.push_back(ConstantInt::get(Type::Int32Ty,1));
-      new CallInst(SLC.get_memcpy(), args, "", ci);
+      Value *args[4] = {
+        CastToCStr(ci->getOperand(1), *ci),
+        CastToCStr(ci->getOperand(3), *ci),
+        Len1,
+        ConstantInt::get(Type::Int32Ty,1)
+      };
+      new CallInst(SLC.get_memcpy(), args, 4, "", ci);
       
       // The strlen result is the unincremented number of bytes in the string.
       if (!ci->use_empty()) {
@@ -1660,12 +1665,13 @@
       {
         // fputs(s,F)  -> fwrite(s,1,len,F) (if s is constant and strlen(s) > 1)
         const Type* FILEptr_type = ci->getOperand(2)->getType();
-        std::vector<Value*> parms;
-        parms.push_back(ci->getOperand(1));
-        parms.push_back(ConstantInt::get(SLC.getIntPtrType(),len));
-        parms.push_back(ConstantInt::get(SLC.getIntPtrType(),1));
-        parms.push_back(ci->getOperand(2));
-        new CallInst(SLC.get_fwrite(FILEptr_type), parms, "", ci);
+        Value *parms[4] = {
+          ci->getOperand(1),
+          ConstantInt::get(SLC.getIntPtrType(),len),
+          ConstantInt::get(SLC.getIntPtrType(),1),
+          ci->getOperand(2)
+        };
+        new CallInst(SLC.get_fwrite(FILEptr_type), parms, 4, "", ci);
         break;
       }
     }






More information about the llvm-commits mailing list