mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Use WeakVH to hold dead mdnodes. Check use_empty() before deleting a node.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80928 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
dad45ea56e
commit
73b1ee857b
@ -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 @@ GetElementPtrConstantExpr::GetElementPtrConstantExpr
|
||||
}
|
||||
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user