[llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Mar 4 22:35:45 PST 2005



Changes in directory llvm-poolalloc/lib/PoolAllocate:

PointerCompress.cpp updated: 1.50 -> 1.51
---
Log message:

handle memset, printf, and use the *COMPRESSED* type when transforming
subscripts, not the ORIGINAL type.  Bork.

This fixes Olden/power and several others.


---
Diffs of the changes:  (+23 -1)

 PointerCompress.cpp |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletion(-)


Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp
diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.50 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.51
--- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.50	Fri Mar  4 21:46:19 2005
+++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp	Sat Mar  5 00:35:30 2005
@@ -673,7 +673,7 @@
       const SequentialType *STy = cast<SequentialType>(*GTI);
       if (!isa<Constant>(Idx) || !cast<Constant>(Idx)->isNullValue()) {
         // Add Idx*sizeof(NewElementType) to the index.
-        const Type *ElTy = STy->getElementType();
+        const Type *ElTy = cast<SequentialType>(NTy)->getElementType();
         if (Idx->getType() != SCALARUINTTYPE)
           Idx = new CastInst(Idx, SCALARUINTTYPE, Idx->getName(), &GEPI);
 
@@ -908,6 +908,28 @@
     std::vector<Value*> Operands;
     Operands.reserve(CI.getNumOperands()-1);
 
+    // If this is one of the functions we know about, just materialize the
+    // compressed pointer as a real pointer, and pass it.
+    if (Callee->getName() == "printf") {
+      for (unsigned i = 1, e = CI.getNumOperands(); i != e; ++i)
+        if (isa<PointerType>(CI.getOperand(i)->getType()) &&
+            getPoolInfo(CI.getOperand(i)))
+          CI.setOperand(i, getTransformedValue(CI.getOperand(i)));
+      return;
+    } else if (Callee->getName() == "llvm.memset") {
+      if (const CompressedPoolInfo *DestPI = getPoolInfo(CI.getOperand(1))) {
+        std::vector<Value*> Ops;
+        Ops.push_back(getTransformedValue(CI.getOperand(1)));
+        Value *BasePtr = DestPI->EmitPoolBaseLoad(CI);
+        Value *SrcPtr = new GetElementPtrInst(BasePtr, Ops,
+                                       CI.getOperand(1)->getName()+".pp", &CI);
+        SrcPtr = new CastInst(SrcPtr, CI.getOperand(1)->getType(), "", &CI);
+        CI.setOperand(1, SrcPtr);
+        return;
+      }
+    }
+
+
     std::vector<unsigned> CompressedArgs;
     if (isa<PointerType>(CI.getType()) && getPoolInfo(&CI))
       CompressedArgs.push_back(0);  // Compress retval.






More information about the llvm-commits mailing list