[llvm-commits] [see] CVS: llvm-poolalloc/lib/DSA/Local.cpp

Andrew Lenharth alenhar2 at cs.uiuc.edu
Mon Mar 12 09:41:45 PDT 2007



Changes in directory llvm-poolalloc/lib/DSA:

Local.cpp updated: 1.158.2.4.2.4 -> 1.158.2.4.2.5
---
Log message:

this could be bad, but it doesn't trigger

---
Diffs of the changes:  (+27 -0)

 Local.cpp |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+)


Index: llvm-poolalloc/lib/DSA/Local.cpp
diff -u llvm-poolalloc/lib/DSA/Local.cpp:1.158.2.4.2.4 llvm-poolalloc/lib/DSA/Local.cpp:1.158.2.4.2.5
--- llvm-poolalloc/lib/DSA/Local.cpp:1.158.2.4.2.4	Fri Mar  9 11:27:51 2007
+++ llvm-poolalloc/lib/DSA/Local.cpp	Mon Mar 12 11:41:06 2007
@@ -1451,6 +1451,33 @@
       EliminateUsesOfECGlobals(*I->second, ECGlobals);
   }
 
+#ifdef LLVA_KERNEL
+
+  // Ugly hack.  kmem_cache_allocs are in the same pool also if the kmem_cache_t's are the same
+  // this only works on global kmem_cache_ts
+  Function* KMA = M.getNamedFunction("kmem_cache_alloc");
+  if (KMA) {
+    for (Value::use_iterator ii = KMA->use_begin(), ee = KMA->use_end();
+         ii != ee; ++ii) {
+      std::map<Value*, MetaPool*> locs;
+      if (CallInst* CI = dyn_cast<CallInst>(*ii)) {
+        if (CI->getCalledFunction() == KMA && isa<GlobalValue>(CI->getOperand(1))) {
+          Value* V = CI->getOperand(1); //the kmem_cache_alloc
+          DSNodeHandle DSH = DSInfo[CI->getParent()->getParent()]->getNodeForValue(CI);
+          MetaPoolHandle L(locs[V]), N(DSH.getNode()->getMP());
+          if (L.getPool() != N.getPool()) {
+            std::cerr << "kmem_cache_alloc recovered merge\n";
+            MetaPoolHandle L(locs[V]), N(DSH.getNode()->getMP());
+            locs[V]->merge(DSH.getNode()->getMP());
+          }
+          locs[V] = DSH.getNode()->getMP();
+        }
+      }
+    }
+  }
+
+#endif
+
   return false;
 }
 






More information about the llvm-commits mailing list