summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/LLVMContext.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-08-11 06:31:57 +0000
committerDevang Patel <dpatel@apple.com>2009-08-11 06:31:57 +0000
commitc5aa8c6d29ab8ebfe508e61d01e91022a9cd7200 (patch)
treea80b33815d69e1c3897bbe3154f7b6d38c08880a /llvm/lib/VMCore/LLVMContext.cpp
parentb39a5aa794d449d009585c16af21fa811c08b170 (diff)
downloadbcm5719-llvm-c5aa8c6d29ab8ebfe508e61d01e91022a9cd7200.tar.gz
bcm5719-llvm-c5aa8c6d29ab8ebfe508e61d01e91022a9cd7200.zip
Remove dead metadata.
llvm-svn: 78651
Diffstat (limited to 'llvm/lib/VMCore/LLVMContext.cpp')
-rw-r--r--llvm/lib/VMCore/LLVMContext.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/LLVMContext.cpp b/llvm/lib/VMCore/LLVMContext.cpp
index 22882711a06..3ca1b0afca4 100644
--- a/llvm/lib/VMCore/LLVMContext.cpp
+++ b/llvm/lib/VMCore/LLVMContext.cpp
@@ -20,6 +20,7 @@
#include "llvm/Support/ManagedStatic.h"
#include "LLVMContextImpl.h"
#include <cstdarg>
+#include <set>
using namespace llvm;
@@ -44,3 +45,27 @@ GetElementPtrConstantExpr::GetElementPtrConstantExpr
for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
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;
+}
OpenPOWER on IntegriCloud