optimize strstr, PR5783
[oota-llvm.git] / lib / VMCore / LLVMContext.cpp
index aa9dc3671a089b10ff15c43a8847949c197b4905..3b4a1a3a155402a1498f19a167068823e4275659 100644 (file)
 //===----------------------------------------------------------------------===//
 
 #include "llvm/LLVMContext.h"
+#include "llvm/Metadata.h"
 #include "llvm/Constants.h"
 #include "llvm/Instruction.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/ValueHandle.h"
 #include "LLVMContextImpl.h"
 #include <set>
 
@@ -27,7 +29,7 @@ LLVMContext& llvm::getGlobalContext() {
   return *GlobalContext;
 }
 
-LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl()) { }
+LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { }
 LLVMContext::~LLVMContext() { delete pImpl; }
 
 GetElementPtrConstantExpr::GetElementPtrConstantExpr
@@ -43,26 +45,6 @@ GetElementPtrConstantExpr::GetElementPtrConstantExpr
     OperandList[i+1] = IdxList[i];
 }
 
-bool LLVMContext::RemoveDeadMetadata() {
-  std::vector<const MDNode *> DeadMDNodes;
-  bool Changed = false;
-  while (1) {
-
-    for (LLVMContextImpl::MDNodeMapTy::MapTy::iterator
-           I = pImpl->MDNodes.map_begin(),
-           E = pImpl->MDNodes.map_end(); I != E; ++I) {
-      const MDNode *N = cast<MDNode>(I->second);
-      if (N->use_empty()) 
-        DeadMDNodes.push_back(N);
-    }
-    
-    if (DeadMDNodes.empty())
-      return Changed;
-
-    while (!DeadMDNodes.empty()) {
-      const MDNode *N = DeadMDNodes.back(); DeadMDNodes.pop_back();
-      delete N;
-    }
-  }
-  return Changed;
+MetadataContext &LLVMContext::getMetadata() {
+  return pImpl->TheMetadata;
 }