From f21f7146a32d5c83eaea28eec6164102bdaa9dcf Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 6 Jun 2012 13:53:41 +0000 Subject: [PATCH] Stop leaking RegScavengers from TailDuplication. llvm-svn: 158069 --- lib/CodeGen/TailDuplication.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/TailDuplication.cpp b/lib/CodeGen/TailDuplication.cpp index d077b091937..a813fa65ac5 100644 --- a/lib/CodeGen/TailDuplication.cpp +++ b/lib/CodeGen/TailDuplication.cpp @@ -28,6 +28,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SetVector.h" #include "llvm/ADT/Statistic.h" @@ -62,7 +63,7 @@ namespace { const TargetRegisterInfo *TRI; MachineModuleInfo *MMI; MachineRegisterInfo *MRI; - RegScavenger *RS; + OwningPtr RS; bool PreRegAlloc; // SSAUpdateVRs - A list of virtual registers for which to update SSA form. @@ -132,9 +133,9 @@ bool TailDuplicatePass::runOnMachineFunction(MachineFunction &MF) { MRI = &MF.getRegInfo(); MMI = getAnalysisIfAvailable(); PreRegAlloc = MRI->isSSA(); - RS = NULL; + RS.reset(); if (MRI->tracksLiveness() && TRI->trackLivenessAfterRegAlloc(MF)) - RS = new RegScavenger(); + RS.reset(new RegScavenger()); bool MadeChange = false; while (TailDuplicateBlocks(MF))