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

Chris Lattner lattner at cs.uiuc.edu
Fri Mar 4 14:46:51 PST 2005



Changes in directory llvm-poolalloc/lib/PoolAllocate:

PointerCompress.cpp updated: 1.45 -> 1.46
---
Log message:

Two fixes: only print info about compressed pools in the function they are homed in

Second, don't match up args-to-args exactly.  If a parameter passed isn't being compressed, but something it points to is, we used to miscompile stuff.


---
Diffs of the changes:  (+14 -12)

 PointerCompress.cpp |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)


Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp
diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.45 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.46
--- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.45	Fri Mar  4 14:53:36 2005
+++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp	Fri Mar  4 16:46:35 2005
@@ -913,29 +913,21 @@
   DSGraph::NodeMapTy CalleeCallerMap;
   
   // Do we need to compress the return value?
-  if (isa<PointerType>(CI.getType()) && getNodeIfCompressed(&CI)) {
+  if (isa<PointerType>(CI.getType()))
     DSGraph::computeNodeMapping(CG->getReturnNodeFor(FI->F),
                                 getMappedNodeHandle(&CI), CalleeCallerMap);
-    PoolsToCompress.insert(CG->getReturnNodeFor(FI->F).getNode());
-  }
     
   // Find the arguments we need to compress.
   unsigned NumPoolArgs = FI ? FI->ArgNodes.size() : 0;
   for (unsigned i = 1, e = CI.getNumOperands(); i != e; ++i)
-    if (isa<PointerType>(CI.getOperand(i)->getType()) &&
-        getNodeIfCompressed(CI.getOperand(i))) {
+    if (isa<PointerType>(CI.getOperand(i)->getType()) && i > NumPoolArgs) {
       Argument *FormalArg = next(FI->F.abegin(), i-1-NumPoolArgs);
         
       DSGraph::computeNodeMapping(CG->getNodeForValue(FormalArg),
                                   getMappedNodeHandle(CI.getOperand(i)),
                                   CalleeCallerMap);
-        
-      PoolsToCompress.insert(CG->getNodeForValue(FormalArg).getNode());
     }
 
-  // If this function doesn't require compression, there is nothing to do!
-  if (PoolsToCompress.empty()) return;
-
   // Now that we know the basic pools passed/returned through the
   // argument/retval of the call, add the compressed pools that are reachable
   // from them.  The CalleeCallerMap contains a mapping from callee nodes to the
@@ -946,6 +938,9 @@
     if (PoolInfo.count(I->second.getNode()))
       PoolsToCompress.insert(I->first);
   }
+
+  // If this function doesn't require compression, there is nothing to do!
+  if (PoolsToCompress.empty()) return;
     
   // Get the clone of this function that uses compressed pointers instead of
   // normal pointers.
@@ -1168,9 +1163,16 @@
   std::cerr << "In function '" << F.getName() << "':\n";
   for (std::map<const DSNode*, CompressedPoolInfo>::iterator
          I = PoolsToCompress.begin(), E = PoolsToCompress.end(); I != E; ++I) {
+
     I->second.Initialize(PoolsToCompress, TD);
-    std::cerr << "  COMPRESSING POOL:\nPCS:";
-    I->second.dump();
+
+    // Only dump info about a compressed pool if this is the home for it.
+    if (isa<AllocaInst>(I->second.getPoolDesc()) ||
+        (isa<GlobalValue>(I->second.getPoolDesc()) &&
+         F.hasExternalLinkage() && F.getName() == "main")) {
+      std::cerr << "  COMPRESSING POOL:\nPCS:";
+      I->second.dump();
+    }
   }
   
   // Finally, rewrite the function body to use compressed pointers!






More information about the llvm-commits mailing list