llvm.org GIT mirror llvm / 200241e
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 Andy Gibbs 6 years ago
12 changed file(s) with 48 addition(s) and 50 deletion(s). Raw diff Collapse all Expand all
1616 #define LLVM_CODEGEN_REGALLOCPBQP_H
1717
1818 #include "llvm/ADT/DenseMap.h"
19 #include "llvm/ADT/OwningPtr.h"
1920 #include "llvm/CodeGen/MachineFunctionPass.h"
2021 #include "llvm/CodeGen/PBQP/Graph.h"
2122 #include "llvm/CodeGen/PBQP/Solution.h"
122123
123124 /// Build a PBQP instance to represent the register allocation problem for
124125 /// the given MachineFunction.
125 virtual std::auto_ptr build(
126 MachineFunction *mf,
127 const LiveIntervals *lis,
128 const MachineLoopInfo *loopInfo,
129 const RegSet &vregs);
126 virtual OwningPtr build(MachineFunction *mf,
127 const LiveIntervals *lis,
128 const MachineLoopInfo *loopInfo,
129 const RegSet &vregs);
130130 private:
131131
132132 void addSpillCosts(PBQP::Vector &costVec, PBQP::PBQPNum spillCost);
143143
144144 /// Build a PBQP instance to represent the register allocation problem for
145145 /// the given MachineFunction.
146 virtual std::auto_ptr build(
147 MachineFunction *mf,
148 const LiveIntervals *lis,
149 const MachineLoopInfo *loopInfo,
150 const RegSet &vregs);
146 virtual OwningPtr build(MachineFunction *mf,
147 const LiveIntervals *lis,
148 const MachineLoopInfo *loopInfo,
149 const RegSet &vregs);
151150
152151 private:
153152
160159 PBQP::PBQPNum benefit);
161160 };
162161
163 FunctionPass* createPBQPRegisterAllocator(std::auto_ptr builder,
162 FunctionPass* createPBQPRegisterAllocator(OwningPtr builder,
164163 char *customPassID=0);
165164 }
166165
6262 MachineFunction *MF;
6363
6464 // state
65 std::auto_ptr SpillerInstance;
65 OwningPtr SpillerInstance;
6666 std::priority_queue,
6767 CompSpillWeight> Queue;
6868
7777 LiveDebugVariables *DebugVars;
7878
7979 // state
80 std::auto_ptr SpillerInstance;
80 OwningPtr SpillerInstance;
8181 std::priority_queue > Queue;
8282 unsigned NextCascade;
8383
165165 };
166166
167167 // splitting state.
168 std::auto_ptr SA;
169 std::auto_ptr SE;
168 OwningPtr SA;
169 OwningPtr SE;
170170
171171 /// Cached per-block interference maps
172172 InterferenceCache IntfCache;
8888 static char ID;
8989
9090 /// Construct a PBQP register allocator.
91 RegAllocPBQP(std::auto_ptr b, char *cPassID=0)
92 : MachineFunctionPass(ID), builder(b), customPassID(cPassID) {
91 RegAllocPBQP(OwningPtr b, char *cPassID=0)
92 : MachineFunctionPass(ID), builder(b.take()), customPassID(cPassID) {
9393 initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
9494 initializeLiveIntervalsPass(*PassRegistry::getPassRegistry());
9595 initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry());
120120 typedef std::set RegSet;
121121
122122
123 std::auto_ptr builder;
123 OwningPtr builder;
124124
125125 char *customPassID;
126126
131131 const MachineLoopInfo *loopInfo;
132132 MachineRegisterInfo *mri;
133133
134 std::auto_ptr spiller;
134 OwningPtr spiller;
135135 LiveIntervals *lis;
136136 LiveStacks *lss;
137137 VirtRegMap *vrm;
185185 return allowedSet[option - 1];
186186 }
187187
188 std::auto_ptr PBQPBuilder::build(MachineFunction *mf,
189 const LiveIntervals *lis,
190 const MachineLoopInfo *loopInfo,
191 const RegSet &vregs) {
188 OwningPtr PBQPBuilder::build(MachineFunction *mf,
189 const LiveIntervals *lis,
190 const MachineLoopInfo *loopInfo,
191 const RegSet &vregs) {
192192
193193 LiveIntervals *LIS = const_cast(lis);
194194 MachineRegisterInfo *mri = &mf->getRegInfo();
195195 const TargetRegisterInfo *tri = mf->getTarget().getRegisterInfo();
196196
197 std::auto_ptr p(new PBQPRAProblem());
197 OwningPtr p(new PBQPRAProblem());
198198 PBQP::Graph &g = p->getGraph();
199199 RegSet pregs;
200200
310310 }
311311 }
312312
313 std::auto_ptr PBQPBuilderWithCoalescing::build(
313 OwningPtr PBQPBuilderWithCoalescing::build(
314314 MachineFunction *mf,
315315 const LiveIntervals *lis,
316316 const MachineLoopInfo *loopInfo,
317317 const RegSet &vregs) {
318318
319 std::auto_ptr p = PBQPBuilder::build(mf, lis, loopInfo, vregs);
319 OwningPtr p = PBQPBuilder::build(mf, lis, loopInfo, vregs);
320320 PBQP::Graph &g = p->getGraph();
321321
322322 const TargetMachine &tm = mf->getTarget();
583583 while (!pbqpAllocComplete) {
584584 DEBUG(dbgs() << " PBQP Regalloc round " << round << ":\n");
585585
586 std::auto_ptr problem =
586 OwningPtr problem =
587587 builder->build(mf, lis, loopInfo, vregsToAlloc);
588588
589589 #ifndef NDEBUG
620620 }
621621
622622 FunctionPass* llvm::createPBQPRegisterAllocator(
623 std::auto_ptr builder,
623 OwningPtr builder,
624624 char *customPassID) {
625 return new RegAllocPBQP(builder, customPassID);
625 return new RegAllocPBQP(OwningPtr(builder.take()), customPassID);
626626 }
627627
628628 FunctionPass* llvm::createDefaultPBQPRegisterAllocator() {
629629 if (pbqpCoalescing) {
630630 return createPBQPRegisterAllocator(
631 std::auto_ptr(new PBQPBuilderWithCoalescing()));
631 OwningPtr(new PBQPBuilderWithCoalescing()));
632632 } // else
633633 return createPBQPRegisterAllocator(
634 std::auto_ptr(new PBQPBuilder()));
634 OwningPtr(new PBQPBuilder()));
635635 }
636636
637637 #undef DEBUG_TYPE
121121 outs() << "Read input file : '" << Filenames[0] << "'\n";
122122
123123 for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
124 std::auto_ptr M(ParseInputFile(Filenames[i], Context));
124 OwningPtr M(ParseInputFile(Filenames[i], Context));
125125 if (M.get() == 0) return true;
126126
127127 outs() << "Linking in input file: '" << Filenames[i] << "'\n";
199199 static int compileModule(char **argv, LLVMContext &Context) {
200200 // Load the module to be compiled...
201201 SMDiagnostic Err;
202 std::auto_ptr M;
202 OwningPtr M;
203203 Module *mod = 0;
204204 Triple TheTriple;
205205
280280 Options.UseInitArray = UseInitArray;
281281 Options.SSPBufferSize = SSPBufferSize;
282282
283 std::auto_ptr
283 OwningPtr
284284 target(TheTarget->createTargetMachine(TheTriple.getTriple(),
285285 MCPU, FeaturesStr, Options,
286286 RelocModel, CMModel, OLvl));
9393
9494 // Parse the file now...
9595 SMDiagnostic Err;
96 std::auto_ptr M(ParseAssemblyFile(InputFilename, Err, Context));
96 OwningPtr M(ParseAssemblyFile(InputFilename, Err, Context));
9797 if (M.get() == 0) {
9898 Err.print(argv[0], errs());
9999 return 1;
122122 cl::ParseCommandLineOptions(argc, argv, "llvm .bc -> .ll disassembler\n");
123123
124124 std::string ErrorMessage;
125 std::auto_ptr M;
125 OwningPtr M;
126126
127127 // Use the bitcode streaming interface
128128 DataStreamer *streamer = getDataFileStreamer(InputFilename, &ErrorMessage);
9999
100100 // Use lazy loading, since we only care about selected global values.
101101 SMDiagnostic Err;
102 std::auto_ptr M;
102 OwningPtr M;
103103 M.reset(getLazyIRFileModule(InputFilename, Err, Context));
104104
105105 if (M.get() == 0) {
5252 // LoadFile - Read the specified bitcode file in and return it. This routine
5353 // searches the link path for the specified file to try to find it...
5454 //
55 static inline std::auto_ptr LoadFile(const char *argv0,
56 const std::string &FN,
57 LLVMContext& Context) {
55 static inline OwningPtr LoadFile(const char *argv0,
56 const std::string &FN,
57 LLVMContext& Context) {
5858 sys::Path Filename;
5959 if (!Filename.set(FN)) {
6060 errs() << "Invalid file name: '" << FN << "'\n";
61 return std::auto_ptr();
61 return OwningPtr();
6262 }
6363
6464 SMDiagnostic Err;
6767
6868 const std::string &FNStr = Filename.str();
6969 Result = ParseIRFile(FNStr, Err, Context);
70 if (Result) return std::auto_ptr(Result); // Load successful!
70 if (Result) return OwningPtr(Result); // Load successful!
7171
7272 Err.print(argv0, errs());
73 return std::auto_ptr();
73 return OwningPtr();
7474 }
7575
7676 int main(int argc, char **argv) {
8585 unsigned BaseArg = 0;
8686 std::string ErrorMessage;
8787
88 std::auto_ptr Composite(LoadFile(argv[0],
89 InputFilenames[BaseArg], Context));
88 OwningPtr Composite(LoadFile(argv[0],
89 InputFilenames[BaseArg], Context));
9090 if (Composite.get() == 0) {
9191 errs() << argv[0] << ": error loading file '"
9292 << InputFilenames[BaseArg] << "'\n";
9494 }
9595
9696 for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) {
97 std::auto_ptr M(LoadFile(argv[0],
98 InputFilenames[i], Context));
97 OwningPtr M(LoadFile(argv[0], InputFilenames[i], Context));
9998 if (M.get() == 0) {
10099 errs() << argv[0] << ": error loading file '" <
101100 return 1;
7777 }
7878
7979 std::string err_msg;
80 std::auto_ptr
80 OwningPtr
8181 AutoArchive(Archive::OpenAndLoad(ArchivePath, Context, &err_msg));
8282 Archive* TheArchive = AutoArchive.get();
8383 if (!TheArchive) {
588588 SMDiagnostic Err;
589589
590590 // Load the input module...
591 std::auto_ptr M;
591 OwningPtr M;
592592 M.reset(ParseIRFile(InputFilename, Err, Context));
593593
594594 if (M.get() == 0) {
655655 TargetMachine *Machine = 0;
656656 if (ModuleTriple.getArch())
657657 Machine = GetTargetMachine(Triple(ModuleTriple));
658 std::auto_ptr TM(Machine);
658 OwningPtr TM(Machine);
659659
660660 // Add internal analysis passes from the target machine.
661661 if (TM.get())