Replace uses of the deprecated std::auto_ptr with OwningPtr.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179373 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andy Gibbs
2013-04-12 10:56:28 +00:00
parent 71c1b22855
commit 200241e4de
12 changed files with 48 additions and 50 deletions

View File

@@ -17,6 +17,7 @@
#define LLVM_CODEGEN_REGALLOCPBQP_H #define LLVM_CODEGEN_REGALLOCPBQP_H
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/PBQP/Graph.h" #include "llvm/CodeGen/PBQP/Graph.h"
#include "llvm/CodeGen/PBQP/Solution.h" #include "llvm/CodeGen/PBQP/Solution.h"
@@ -123,8 +124,7 @@ namespace llvm {
/// Build a PBQP instance to represent the register allocation problem for /// Build a PBQP instance to represent the register allocation problem for
/// the given MachineFunction. /// the given MachineFunction.
virtual std::auto_ptr<PBQPRAProblem> build( virtual OwningPtr<PBQPRAProblem> build(MachineFunction *mf,
MachineFunction *mf,
const LiveIntervals *lis, const LiveIntervals *lis,
const MachineLoopInfo *loopInfo, const MachineLoopInfo *loopInfo,
const RegSet &vregs); const RegSet &vregs);
@@ -144,8 +144,7 @@ namespace llvm {
/// Build a PBQP instance to represent the register allocation problem for /// Build a PBQP instance to represent the register allocation problem for
/// the given MachineFunction. /// the given MachineFunction.
virtual std::auto_ptr<PBQPRAProblem> build( virtual OwningPtr<PBQPRAProblem> build(MachineFunction *mf,
MachineFunction *mf,
const LiveIntervals *lis, const LiveIntervals *lis,
const MachineLoopInfo *loopInfo, const MachineLoopInfo *loopInfo,
const RegSet &vregs); const RegSet &vregs);
@@ -161,7 +160,7 @@ namespace llvm {
PBQP::PBQPNum benefit); PBQP::PBQPNum benefit);
}; };
FunctionPass* createPBQPRegisterAllocator(std::auto_ptr<PBQPBuilder> builder, FunctionPass* createPBQPRegisterAllocator(OwningPtr<PBQPBuilder> builder,
char *customPassID=0); char *customPassID=0);
} }

View File

@@ -63,7 +63,7 @@ class RABasic : public MachineFunctionPass, public RegAllocBase
MachineFunction *MF; MachineFunction *MF;
// state // state
std::auto_ptr<Spiller> SpillerInstance; OwningPtr<Spiller> SpillerInstance;
std::priority_queue<LiveInterval*, std::vector<LiveInterval*>, std::priority_queue<LiveInterval*, std::vector<LiveInterval*>,
CompSpillWeight> Queue; CompSpillWeight> Queue;

View File

@@ -78,7 +78,7 @@ class RAGreedy : public MachineFunctionPass,
LiveDebugVariables *DebugVars; LiveDebugVariables *DebugVars;
// state // state
std::auto_ptr<Spiller> SpillerInstance; OwningPtr<Spiller> SpillerInstance;
std::priority_queue<std::pair<unsigned, unsigned> > Queue; std::priority_queue<std::pair<unsigned, unsigned> > Queue;
unsigned NextCascade; unsigned NextCascade;
@@ -166,8 +166,8 @@ class RAGreedy : public MachineFunctionPass,
}; };
// splitting state. // splitting state.
std::auto_ptr<SplitAnalysis> SA; OwningPtr<SplitAnalysis> SA;
std::auto_ptr<SplitEditor> SE; OwningPtr<SplitEditor> SE;
/// Cached per-block interference maps /// Cached per-block interference maps
InterferenceCache IntfCache; InterferenceCache IntfCache;

View File

@@ -89,8 +89,8 @@ public:
static char ID; static char ID;
/// Construct a PBQP register allocator. /// Construct a PBQP register allocator.
RegAllocPBQP(std::auto_ptr<PBQPBuilder> b, char *cPassID=0) RegAllocPBQP(OwningPtr<PBQPBuilder> b, char *cPassID=0)
: MachineFunctionPass(ID), builder(b), customPassID(cPassID) { : MachineFunctionPass(ID), builder(b.take()), customPassID(cPassID) {
initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
initializeLiveIntervalsPass(*PassRegistry::getPassRegistry()); initializeLiveIntervalsPass(*PassRegistry::getPassRegistry());
initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry()); initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry());
@@ -121,7 +121,7 @@ private:
typedef std::set<unsigned> RegSet; typedef std::set<unsigned> RegSet;
std::auto_ptr<PBQPBuilder> builder; OwningPtr<PBQPBuilder> builder;
char *customPassID; char *customPassID;
@@ -132,7 +132,7 @@ private:
const MachineLoopInfo *loopInfo; const MachineLoopInfo *loopInfo;
MachineRegisterInfo *mri; MachineRegisterInfo *mri;
std::auto_ptr<Spiller> spiller; OwningPtr<Spiller> spiller;
LiveIntervals *lis; LiveIntervals *lis;
LiveStacks *lss; LiveStacks *lss;
VirtRegMap *vrm; VirtRegMap *vrm;
@@ -186,7 +186,7 @@ unsigned PBQPRAProblem::getPRegForOption(unsigned vreg, unsigned option) const {
return allowedSet[option - 1]; return allowedSet[option - 1];
} }
std::auto_ptr<PBQPRAProblem> PBQPBuilder::build(MachineFunction *mf, OwningPtr<PBQPRAProblem> PBQPBuilder::build(MachineFunction *mf,
const LiveIntervals *lis, const LiveIntervals *lis,
const MachineLoopInfo *loopInfo, const MachineLoopInfo *loopInfo,
const RegSet &vregs) { const RegSet &vregs) {
@@ -195,7 +195,7 @@ std::auto_ptr<PBQPRAProblem> PBQPBuilder::build(MachineFunction *mf,
MachineRegisterInfo *mri = &mf->getRegInfo(); MachineRegisterInfo *mri = &mf->getRegInfo();
const TargetRegisterInfo *tri = mf->getTarget().getRegisterInfo(); const TargetRegisterInfo *tri = mf->getTarget().getRegisterInfo();
std::auto_ptr<PBQPRAProblem> p(new PBQPRAProblem()); OwningPtr<PBQPRAProblem> p(new PBQPRAProblem());
PBQP::Graph &g = p->getGraph(); PBQP::Graph &g = p->getGraph();
RegSet pregs; RegSet pregs;
@@ -311,13 +311,13 @@ void PBQPBuilder::addInterferenceCosts(
} }
} }
std::auto_ptr<PBQPRAProblem> PBQPBuilderWithCoalescing::build( OwningPtr<PBQPRAProblem> PBQPBuilderWithCoalescing::build(
MachineFunction *mf, MachineFunction *mf,
const LiveIntervals *lis, const LiveIntervals *lis,
const MachineLoopInfo *loopInfo, const MachineLoopInfo *loopInfo,
const RegSet &vregs) { const RegSet &vregs) {
std::auto_ptr<PBQPRAProblem> p = PBQPBuilder::build(mf, lis, loopInfo, vregs); OwningPtr<PBQPRAProblem> p = PBQPBuilder::build(mf, lis, loopInfo, vregs);
PBQP::Graph &g = p->getGraph(); PBQP::Graph &g = p->getGraph();
const TargetMachine &tm = mf->getTarget(); const TargetMachine &tm = mf->getTarget();
@@ -584,7 +584,7 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) {
while (!pbqpAllocComplete) { while (!pbqpAllocComplete) {
DEBUG(dbgs() << " PBQP Regalloc round " << round << ":\n"); DEBUG(dbgs() << " PBQP Regalloc round " << round << ":\n");
std::auto_ptr<PBQPRAProblem> problem = OwningPtr<PBQPRAProblem> problem =
builder->build(mf, lis, loopInfo, vregsToAlloc); builder->build(mf, lis, loopInfo, vregsToAlloc);
#ifndef NDEBUG #ifndef NDEBUG
@@ -621,18 +621,18 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) {
} }
FunctionPass* llvm::createPBQPRegisterAllocator( FunctionPass* llvm::createPBQPRegisterAllocator(
std::auto_ptr<PBQPBuilder> builder, OwningPtr<PBQPBuilder> builder,
char *customPassID) { char *customPassID) {
return new RegAllocPBQP(builder, customPassID); return new RegAllocPBQP(OwningPtr<PBQPBuilder>(builder.take()), customPassID);
} }
FunctionPass* llvm::createDefaultPBQPRegisterAllocator() { FunctionPass* llvm::createDefaultPBQPRegisterAllocator() {
if (pbqpCoalescing) { if (pbqpCoalescing) {
return createPBQPRegisterAllocator( return createPBQPRegisterAllocator(
std::auto_ptr<PBQPBuilder>(new PBQPBuilderWithCoalescing())); OwningPtr<PBQPBuilder>(new PBQPBuilderWithCoalescing()));
} // else } // else
return createPBQPRegisterAllocator( return createPBQPRegisterAllocator(
std::auto_ptr<PBQPBuilder>(new PBQPBuilder())); OwningPtr<PBQPBuilder>(new PBQPBuilder()));
} }
#undef DEBUG_TYPE #undef DEBUG_TYPE

View File

@@ -122,7 +122,7 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
outs() << "Read input file : '" << Filenames[0] << "'\n"; outs() << "Read input file : '" << Filenames[0] << "'\n";
for (unsigned i = 1, e = Filenames.size(); i != e; ++i) { for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
std::auto_ptr<Module> M(ParseInputFile(Filenames[i], Context)); OwningPtr<Module> M(ParseInputFile(Filenames[i], Context));
if (M.get() == 0) return true; if (M.get() == 0) return true;
outs() << "Linking in input file: '" << Filenames[i] << "'\n"; outs() << "Linking in input file: '" << Filenames[i] << "'\n";

View File

@@ -200,7 +200,7 @@ int main(int argc, char **argv) {
static int compileModule(char **argv, LLVMContext &Context) { static int compileModule(char **argv, LLVMContext &Context) {
// Load the module to be compiled... // Load the module to be compiled...
SMDiagnostic Err; SMDiagnostic Err;
std::auto_ptr<Module> M; OwningPtr<Module> M;
Module *mod = 0; Module *mod = 0;
Triple TheTriple; Triple TheTriple;
@@ -281,7 +281,7 @@ static int compileModule(char **argv, LLVMContext &Context) {
Options.UseInitArray = UseInitArray; Options.UseInitArray = UseInitArray;
Options.SSPBufferSize = SSPBufferSize; Options.SSPBufferSize = SSPBufferSize;
std::auto_ptr<TargetMachine> OwningPtr<TargetMachine>
target(TheTarget->createTargetMachine(TheTriple.getTriple(), target(TheTarget->createTargetMachine(TheTriple.getTriple(),
MCPU, FeaturesStr, Options, MCPU, FeaturesStr, Options,
RelocModel, CMModel, OLvl)); RelocModel, CMModel, OLvl));

View File

@@ -94,7 +94,7 @@ int main(int argc, char **argv) {
// Parse the file now... // Parse the file now...
SMDiagnostic Err; SMDiagnostic Err;
std::auto_ptr<Module> M(ParseAssemblyFile(InputFilename, Err, Context)); OwningPtr<Module> M(ParseAssemblyFile(InputFilename, Err, Context));
if (M.get() == 0) { if (M.get() == 0) {
Err.print(argv[0], errs()); Err.print(argv[0], errs());
return 1; return 1;

View File

@@ -123,7 +123,7 @@ int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .ll disassembler\n"); cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .ll disassembler\n");
std::string ErrorMessage; std::string ErrorMessage;
std::auto_ptr<Module> M; OwningPtr<Module> M;
// Use the bitcode streaming interface // Use the bitcode streaming interface
DataStreamer *streamer = getDataFileStreamer(InputFilename, &ErrorMessage); DataStreamer *streamer = getDataFileStreamer(InputFilename, &ErrorMessage);

View File

@@ -100,7 +100,7 @@ int main(int argc, char **argv) {
// Use lazy loading, since we only care about selected global values. // Use lazy loading, since we only care about selected global values.
SMDiagnostic Err; SMDiagnostic Err;
std::auto_ptr<Module> M; OwningPtr<Module> M;
M.reset(getLazyIRFileModule(InputFilename, Err, Context)); M.reset(getLazyIRFileModule(InputFilename, Err, Context));
if (M.get() == 0) { if (M.get() == 0) {

View File

@@ -53,13 +53,13 @@ DumpAsm("d", cl::desc("Print assembly as linked"), cl::Hidden);
// LoadFile - Read the specified bitcode file in and return it. This routine // LoadFile - Read the specified bitcode file in and return it. This routine
// searches the link path for the specified file to try to find it... // searches the link path for the specified file to try to find it...
// //
static inline std::auto_ptr<Module> LoadFile(const char *argv0, static inline OwningPtr<Module> LoadFile(const char *argv0,
const std::string &FN, const std::string &FN,
LLVMContext& Context) { LLVMContext& Context) {
sys::Path Filename; sys::Path Filename;
if (!Filename.set(FN)) { if (!Filename.set(FN)) {
errs() << "Invalid file name: '" << FN << "'\n"; errs() << "Invalid file name: '" << FN << "'\n";
return std::auto_ptr<Module>(); return OwningPtr<Module>();
} }
SMDiagnostic Err; SMDiagnostic Err;
@@ -68,10 +68,10 @@ static inline std::auto_ptr<Module> LoadFile(const char *argv0,
const std::string &FNStr = Filename.str(); const std::string &FNStr = Filename.str();
Result = ParseIRFile(FNStr, Err, Context); Result = ParseIRFile(FNStr, Err, Context);
if (Result) return std::auto_ptr<Module>(Result); // Load successful! if (Result) return OwningPtr<Module>(Result); // Load successful!
Err.print(argv0, errs()); Err.print(argv0, errs());
return std::auto_ptr<Module>(); return OwningPtr<Module>();
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
@@ -86,7 +86,7 @@ int main(int argc, char **argv) {
unsigned BaseArg = 0; unsigned BaseArg = 0;
std::string ErrorMessage; std::string ErrorMessage;
std::auto_ptr<Module> Composite(LoadFile(argv[0], OwningPtr<Module> Composite(LoadFile(argv[0],
InputFilenames[BaseArg], Context)); InputFilenames[BaseArg], Context));
if (Composite.get() == 0) { if (Composite.get() == 0) {
errs() << argv[0] << ": error loading file '" errs() << argv[0] << ": error loading file '"
@@ -95,8 +95,7 @@ int main(int argc, char **argv) {
} }
for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) { for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) {
std::auto_ptr<Module> M(LoadFile(argv[0], OwningPtr<Module> M(LoadFile(argv[0], InputFilenames[i], Context));
InputFilenames[i], Context));
if (M.get() == 0) { if (M.get() == 0) {
errs() << argv[0] << ": error loading file '" <<InputFilenames[i]<< "'\n"; errs() << argv[0] << ": error loading file '" <<InputFilenames[i]<< "'\n";
return 1; return 1;

View File

@@ -78,7 +78,7 @@ int main(int argc, char **argv) {
} }
std::string err_msg; std::string err_msg;
std::auto_ptr<Archive> OwningPtr<Archive>
AutoArchive(Archive::OpenAndLoad(ArchivePath, Context, &err_msg)); AutoArchive(Archive::OpenAndLoad(ArchivePath, Context, &err_msg));
Archive* TheArchive = AutoArchive.get(); Archive* TheArchive = AutoArchive.get();
if (!TheArchive) { if (!TheArchive) {

View File

@@ -589,7 +589,7 @@ int main(int argc, char **argv) {
SMDiagnostic Err; SMDiagnostic Err;
// Load the input module... // Load the input module...
std::auto_ptr<Module> M; OwningPtr<Module> M;
M.reset(ParseIRFile(InputFilename, Err, Context)); M.reset(ParseIRFile(InputFilename, Err, Context));
if (M.get() == 0) { if (M.get() == 0) {
@@ -656,7 +656,7 @@ int main(int argc, char **argv) {
TargetMachine *Machine = 0; TargetMachine *Machine = 0;
if (ModuleTriple.getArch()) if (ModuleTriple.getArch())
Machine = GetTargetMachine(Triple(ModuleTriple)); Machine = GetTargetMachine(Triple(ModuleTriple));
std::auto_ptr<TargetMachine> TM(Machine); OwningPtr<TargetMachine> TM(Machine);
// Add internal analysis passes from the target machine. // Add internal analysis passes from the target machine.
if (TM.get()) if (TM.get())