[llvm-commits] [llvm] r80928 - /llvm/trunk/lib/VMCore/LLVMContext.cpp
Devang Patel
dpatel at apple.com
Thu Sep 3 10:03:48 PDT 2009
Author: dpatel
Date: Thu Sep 3 12:03:47 2009
New Revision: 80928
URL: http://llvm.org/viewvc/llvm-project?rev=80928&view=rev
Log:
Use WeakVH to hold dead mdnodes. Check use_empty() before deleting a node.
Modified:
llvm/trunk/lib/VMCore/LLVMContext.cpp
Modified: llvm/trunk/lib/VMCore/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContext.cpp?rev=80928&r1=80927&r2=80928&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContext.cpp (original)
+++ llvm/trunk/lib/VMCore/LLVMContext.cpp Thu Sep 3 12:03:47 2009
@@ -17,6 +17,7 @@
#include "llvm/Constants.h"
#include "llvm/Instruction.h"
#include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/ValueHandle.h"
#include "LLVMContextImpl.h"
#include <set>
@@ -45,24 +46,25 @@
}
bool LLVMContext::RemoveDeadMetadata() {
- std::vector<const MDNode *> DeadMDNodes;
+ std::vector<WeakVH> DeadMDNodes;
bool Changed = false;
while (1) {
for (FoldingSet<MDNode>::iterator
I = pImpl->MDNodeSet.begin(),
E = pImpl->MDNodeSet.end(); I != E; ++I) {
- const MDNode *N = &(*I);
+ MDNode *N = &(*I);
if (N->use_empty())
- DeadMDNodes.push_back(N);
+ DeadMDNodes.push_back(WeakVH(N));
}
if (DeadMDNodes.empty())
return Changed;
while (!DeadMDNodes.empty()) {
- const MDNode *N = DeadMDNodes.back(); DeadMDNodes.pop_back();
- delete N;
+ const MDNode *N = cast<MDNode>(DeadMDNodes.back()); DeadMDNodes.pop_back();
+ if (N->use_empty())
+ delete N;
}
}
return Changed;
More information about the llvm-commits
mailing list