From 7cf88763e03bc431f7b4ac3abce1d7eb742dbc5a Mon Sep 17 00:00:00 2001 From: Cameron Zwarich Date: Tue, 22 Feb 2011 08:54:30 +0000 Subject: MachineConstantPoolValues are not uniqued, so they need to be freed if they share entries. Add a DenseSet to MachineConstantPool for the MachineCPVs that it owns. This will hopefully fix the MC/ARM/elf-reloc-01.ll failure on the leaks bots. llvm-svn: 126218 --- llvm/lib/CodeGen/MachineFunction.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/MachineFunction.cpp') diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp index 962362761f3..d81e4a1d015 100644 --- a/llvm/lib/CodeGen/MachineFunction.cpp +++ b/llvm/lib/CodeGen/MachineFunction.cpp @@ -644,6 +644,10 @@ MachineConstantPool::~MachineConstantPool() { for (unsigned i = 0, e = Constants.size(); i != e; ++i) if (Constants[i].isMachineConstantPoolEntry()) delete Constants[i].Val.MachineCPVal; + for (DenseSet::iterator I = + MachineCPVsSharingEntries.begin(), E = MachineCPVsSharingEntries.end(); + I != E; ++I) + delete *I; } /// CanShareConstantPoolEntry - Test whether the given two constants @@ -721,8 +725,10 @@ unsigned MachineConstantPool::getConstantPoolIndex(MachineConstantPoolValue *V, // // FIXME, this could be made much more efficient for large constant pools. int Idx = V->getExistingMachineCPValue(this, Alignment); - if (Idx != -1) + if (Idx != -1) { + MachineCPVsSharingEntries.insert(V); return (unsigned)Idx; + } Constants.push_back(MachineConstantPoolEntry(V, Alignment)); return Constants.size()-1; -- cgit v1.2.3