mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-04 21:31:03 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126218 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6023efb45d
commit
5567869637
@ -16,6 +16,7 @@
|
|||||||
#ifndef LLVM_CODEGEN_MACHINECONSTANTPOOL_H
|
#ifndef LLVM_CODEGEN_MACHINECONSTANTPOOL_H
|
||||||
#define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
|
#define LLVM_CODEGEN_MACHINECONSTANTPOOL_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/DenseSet.h"
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -130,6 +131,8 @@ class MachineConstantPool {
|
|||||||
const TargetData *TD; ///< The machine's TargetData.
|
const TargetData *TD; ///< The machine's TargetData.
|
||||||
unsigned PoolAlignment; ///< The alignment for the pool.
|
unsigned PoolAlignment; ///< The alignment for the pool.
|
||||||
std::vector<MachineConstantPoolEntry> Constants; ///< The pool of constants.
|
std::vector<MachineConstantPoolEntry> Constants; ///< The pool of constants.
|
||||||
|
/// MachineConstantPoolValues that use an existing MachineConstantPoolEntry.
|
||||||
|
DenseSet<MachineConstantPoolValue*> MachineCPVsSharingEntries;
|
||||||
public:
|
public:
|
||||||
/// @brief The only constructor.
|
/// @brief The only constructor.
|
||||||
explicit MachineConstantPool(const TargetData *td)
|
explicit MachineConstantPool(const TargetData *td)
|
||||||
|
@ -644,6 +644,10 @@ MachineConstantPool::~MachineConstantPool() {
|
|||||||
for (unsigned i = 0, e = Constants.size(); i != e; ++i)
|
for (unsigned i = 0, e = Constants.size(); i != e; ++i)
|
||||||
if (Constants[i].isMachineConstantPoolEntry())
|
if (Constants[i].isMachineConstantPoolEntry())
|
||||||
delete Constants[i].Val.MachineCPVal;
|
delete Constants[i].Val.MachineCPVal;
|
||||||
|
for (DenseSet<MachineConstantPoolValue*>::iterator I =
|
||||||
|
MachineCPVsSharingEntries.begin(), E = MachineCPVsSharingEntries.end();
|
||||||
|
I != E; ++I)
|
||||||
|
delete *I;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CanShareConstantPoolEntry - Test whether the given two constants
|
/// 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.
|
// FIXME, this could be made much more efficient for large constant pools.
|
||||||
int Idx = V->getExistingMachineCPValue(this, Alignment);
|
int Idx = V->getExistingMachineCPValue(this, Alignment);
|
||||||
if (Idx != -1)
|
if (Idx != -1) {
|
||||||
|
MachineCPVsSharingEntries.insert(V);
|
||||||
return (unsigned)Idx;
|
return (unsigned)Idx;
|
||||||
|
}
|
||||||
|
|
||||||
Constants.push_back(MachineConstantPoolEntry(V, Alignment));
|
Constants.push_back(MachineConstantPoolEntry(V, Alignment));
|
||||||
return Constants.size()-1;
|
return Constants.size()-1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user