Skip to content

Commit 46bc3f9

Browse files
committed
remove custom deleter and use out of line definitions
1 parent 4295911 commit 46bc3f9

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

llvm/include/llvm/CodeGen/SpillPlacement.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ class SpillPlacement {
5252
const EdgeBundles *bundles = nullptr;
5353
const MachineBlockFrequencyInfo *MBFI = nullptr;
5454

55-
static void arrayDeleter(Node *N);
56-
std::unique_ptr<Node[], decltype(&arrayDeleter)> nodes;
55+
std::unique_ptr<Node[]> nodes;
5756

5857
// Nodes that are active in the current computation. Owned by the prepare()
5958
// caller.
@@ -161,13 +160,15 @@ class SpillPlacement {
161160
bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA,
162161
MachineFunctionAnalysisManager::Invalidator &Inv);
163162

163+
// Move the default definitions to the implementation
164+
// so the full definition of Node is available.
165+
SpillPlacement(SpillPlacement &&);
166+
~SpillPlacement();
167+
164168
private:
165-
SpillPlacement() : nodes(nullptr, &arrayDeleter) {};
169+
SpillPlacement();
166170

167-
void releaseMemory() {
168-
nodes.reset();
169-
TodoList.clear();
170-
}
171+
void releaseMemory();
171172

172173
void run(MachineFunction &MF, EdgeBundles *Bundles,
173174
MachineBlockFrequencyInfo *MBFI);

llvm/lib/CodeGen/SpillPlacement.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,13 @@ bool SpillPlacementAnalysis::Result::invalidate(
219219
Inv.invalidate<MachineBlockFrequencyAnalysis>(MF, PA);
220220
}
221221

222-
void SpillPlacement::arrayDeleter(Node *N) {
223-
if (N)
224-
delete[] N;
222+
SpillPlacement::SpillPlacement() = default;
223+
SpillPlacement::~SpillPlacement() = default;
224+
SpillPlacement::SpillPlacement(SpillPlacement &&) = default;
225+
226+
void SpillPlacement::releaseMemory() {
227+
nodes.reset();
228+
TodoList.clear();
225229
}
226230

227231
void SpillPlacement::run(MachineFunction &mf, EdgeBundles *Bundles,

0 commit comments

Comments
 (0)