llvm.org GIT mirror llvm / 1a6eca2
[C++11] Replace OwningPtr::take() with OwningPtr::release(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202957 91177308-0d34-0410-b5e6-96231b3b80d8 Ahmed Charles 5 years ago
43 changed file(s) with 118 addition(s) and 118 deletion(s). Raw diff Collapse all Expand all
6767 /// somewhere not accessible in the object file.
6868 /// This is used for dynamic disassembly (see RawMemoryObject).
6969 void setFallbackRegion(OwningPtr &Region) {
70 FallbackRegion.reset(Region.take());
70 FallbackRegion.reset(Region.release());
7171 }
7272
7373 /// \brief Set the symbolizer to use to get information on external functions.
3636 OwningPtr M2(new Module(F->getBufferIdentifier(), Context));
3737 if (LLParser(F, SM, Err, M2.get()).Run())
3838 return 0;
39 return M2.take();
39 return M2.release();
4040 }
4141
4242 Module *llvm::ParseAssemblyFile(const std::string &Filename, SMDiagnostic &Err,
4848 return 0;
4949 }
5050
51 return ParseAssembly(File.take(), 0, Err, Context);
51 return ParseAssembly(File.release(), 0, Err, Context);
5252 }
5353
5454 Module *llvm::ParseAssemblyString(const char *AsmString, Module *M,
226226 return true;
227227
228228 // If successful, createAsmPrinter took ownership of AsmStreamer.
229 AsmStreamer.take();
229 AsmStreamer.release();
230230
231231 PM.add(Printer);
232232
291291 return true;
292292
293293 // If successful, createAsmPrinter took ownership of AsmStreamer.
294 AsmStreamer.take();
294 AsmStreamer.release();
295295
296296 PM.add(Printer);
297297
8888
8989 /// Construct a PBQP register allocator.
9090 RegAllocPBQP(OwningPtr &b, char *cPassID=0)
91 : MachineFunctionPass(ID), builder(b.take()), customPassID(cPassID) {
91 : MachineFunctionPass(ID), builder(b.release()), customPassID(cPassID) {
9292 initializeSlotIndexesPass(*PassRegistry::getPassRegistry());
9393 initializeLiveIntervalsPass(*PassRegistry::getPassRegistry());
9494 initializeLiveStacksPass(*PassRegistry::getPassRegistry());
279279 }
280280 }
281281
282 return p.take();
282 return p.release();
283283 }
284284
285285 void PBQPBuilder::addSpillCosts(PBQP::Vector &costVec,
390390 }
391391 }
392392
393 return p.take();
393 return p.release();
394394 }
395395
396396 void PBQPBuilderWithCoalescing::addPhysRegCoalesce(PBQP::Vector &costVec,
307307 if (!CU->extract(DIData, &offset)) {
308308 break;
309309 }
310 CUs.push_back(CU.take());
310 CUs.push_back(CU.release());
311311 offset = CUs.back()->getNextUnitOffset();
312312 }
313313 }
326326 &I->second.Relocs, isLittleEndian()));
327327 if (!TU->extract(DIData, &offset))
328328 break;
329 TUs.push_back(TU.take());
329 TUs.push_back(TU.release());
330330 offset = TUs.back()->getNextUnitOffset();
331331 }
332332 }
345345 if (!DWOCU->extract(DIData, &offset)) {
346346 break;
347347 }
348 DWOCUs.push_back(DWOCU.take());
348 DWOCUs.push_back(DWOCU.release());
349349 offset = DWOCUs.back()->getNextUnitOffset();
350350 }
351351 }
365365 isLittleEndian()));
366366 if (!TU->extract(DIData, &offset))
367367 break;
368 DWOTUs.push_back(TU.take());
368 DWOTUs.push_back(TU.release());
369369 offset = DWOTUs.back()->getNextUnitOffset();
370370 }
371371 }
635635 // Make data point to uncompressed section contents and save its contents.
636636 name = name.substr(1);
637637 data = UncompressedSection->getBuffer();
638 UncompressedSections.push_back(UncompressedSection.take());
638 UncompressedSections.push_back(UncompressedSection.release());
639639 }
640640
641641 StringRef *Section =
485485 if (UseMCJIT && ExecutionEngine::MCJITCtor) {
486486 ExecutionEngine *EE =
487487 ExecutionEngine::MCJITCtor(M, ErrorStr, MCJMM ? MCJMM : JMM,
488 AllocateGVsWithCode, TheTM.take());
488 AllocateGVsWithCode, TheTM.release());
489489 if (EE) return EE;
490490 } else if (ExecutionEngine::JITCtor) {
491491 ExecutionEngine *EE =
492492 ExecutionEngine::JITCtor(M, ErrorStr, JMM,
493 AllocateGVsWithCode, TheTM.take());
493 AllocateGVsWithCode, TheTM.release());
494494 if (EE) return EE;
495495 }
496496 }
167167 ObjCache->notifyObjectCompiled(M, MB.get());
168168 }
169169
170 return CompiledObject.take();
170 return CompiledObject.release();
171171 }
172172
173173 void MCJIT::generateCodeForModule(Module *M) {
187187 if (0 != ObjCache) {
188188 OwningPtr PreCompiledObject(ObjCache->getObject(M));
189189 if (0 != PreCompiledObject.get())
190 ObjectToLoad.reset(new ObjectBuffer(PreCompiledObject.take()));
190 ObjectToLoad.reset(new ObjectBuffer(PreCompiledObject.release()));
191191 }
192192
193193 // If the cache did not contain a suitable object, compile the object
198198
199199 // Load the object into the dynamic linker.
200200 // MCJIT now owns the ObjectImage pointer (via its LoadedObjects list).
201 ObjectImage *LoadedObject = Dyld.loadObject(ObjectToLoad.take());
201 ObjectImage *LoadedObject = Dyld.loadObject(ObjectToLoad.release());
202202 LoadedObjects.push_back(LoadedObject);
203203 if (!LoadedObject)
204204 report_fatal_error(Dyld.getErrorString());
307307 // FIXME: Support nested archives?
308308 if (!ChildIt->getAsBinary(ChildBin) && ChildBin->isObject()) {
309309 object::ObjectFile *OF = reinterpret_cast(
310 ChildBin.take());
310 ChildBin.release());
311311 // This causes the object file to be loaded.
312312 addObjectFile(OF);
313313 // The address should be here now.
204204 // Give the subclasses a chance to tie-up any loose ends.
205205 finalizeLoad(LocalSections);
206206
207 return Obj.take();
207 return Obj.release();
208208 }
209209
210210 // A helper method for computeTotalAllocSize.
25382538 OwningPtr MB;
25392539 error_code ec;
25402540 if (!(ec = MemoryBuffer::getFile(Path, MB))) {
2541 *OutMemBuf = wrap(MB.take());
2541 *OutMemBuf = wrap(MB.release());
25422542 return 0;
25432543 }
25442544
25512551 OwningPtr MB;
25522552 error_code ec;
25532553 if (!(ec = MemoryBuffer::getSTDIN(MB))) {
2554 *OutMemBuf = wrap(MB.take());
2554 *OutMemBuf = wrap(MB.release());
25552555 return 0;
25562556 }
25572557
5959 return 0;
6060 }
6161
62 return getLazyIRModule(File.take(), Err, Context);
62 return getLazyIRModule(File.release(), Err, Context);
6363 }
6464
6565 Module *llvm::ParseIR(MemoryBuffer *Buffer, SMDiagnostic &Err,
9292 return 0;
9393 }
9494
95 return ParseIR(File.take(), Err, Context);
95 return ParseIR(File.release(), Err, Context);
9696 }
9797
9898 //===----------------------------------------------------------------------===//
269269 sys::fs::remove(NativeObjectPath);
270270 return NULL;
271271 }
272 NativeObjectFile = BuffPtr.take();
272 NativeObjectFile = BuffPtr.release();
273273
274274 // remove temp files
275275 sys::fs::remove(NativeObjectPath);
8282 OwningPtr buffer;
8383 if (MemoryBuffer::getFile(path, buffer))
8484 return false;
85 return isTargetMatch(buffer.take(), triplePrefix);
85 return isTargetMatch(buffer.release(), triplePrefix);
8686 }
8787
8888 /// isTargetMatch - Returns 'true' if the memory buffer is for the specified
102102 errMsg = ec.message();
103103 return NULL;
104104 }
105 return makeLTOModule(buffer.take(), options, errMsg);
105 return makeLTOModule(buffer.release(), options, errMsg);
106106 }
107107
108108 LTOModule *LTOModule::makeLTOModule(int fd, const char *path,
122122 errMsg = ec.message();
123123 return NULL;
124124 }
125 return makeLTOModule(buffer.take(), options, errMsg);
125 return makeLTOModule(buffer.release(), options, errMsg);
126126 }
127127
128128 LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length,
131131 OwningPtr buffer(makeBuffer(mem, length, path));
132132 if (!buffer)
133133 return NULL;
134 return makeLTOModule(buffer.take(), options, errMsg);
134 return makeLTOModule(buffer.release(), options, errMsg);
135135 }
136136
137137 LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer,
174174 options);
175175 m->materializeAllPermanently();
176176
177 LTOModule *Ret = new LTOModule(m.take(), target);
177 LTOModule *Ret = new LTOModule(m.release(), target);
178178
179179 // We need a MCContext set up in order to get mangled names of private
180180 // symbols. It is a bit odd that we need to report uses and definitions
8383
8484 OwningPtr Symbolizer(
8585 TheTarget->createMCSymbolizer(Triple, GetOpInfo, SymbolLookUp, DisInfo,
86 Ctx, RelInfo.take()));
86 Ctx, RelInfo.release()));
8787 DisAsm->setSymbolizer(Symbolizer);
8888 DisAsm->setupForSymbolicDisassembly(GetOpInfo, SymbolLookUp, DisInfo,
8989 Ctx, RelInfo);
5151 }
5252
5353 void MCDisassembler::setSymbolizer(OwningPtr &Symzer) {
54 Symbolizer.reset(Symzer.take());
54 Symbolizer.reset(Symzer.release());
5555 }
1212 using namespace llvm;
1313
1414 MCSymbolizer::MCSymbolizer(MCContext &Ctx, OwningPtr &RelInfo)
15 : Ctx(Ctx), RelInfo(RelInfo.take()) {
15 : Ctx(Ctx), RelInfo(RelInfo.release()) {
1616 }
1717
1818 MCSymbolizer::~MCSymbolizer() {
4747
4848 switch (Type) {
4949 case sys::fs::file_magic::archive:
50 return Archive::create(scopedSource.take());
50 return Archive::create(scopedSource.release());
5151 case sys::fs::file_magic::elf_relocatable:
5252 case sys::fs::file_magic::elf_executable:
5353 case sys::fs::file_magic::elf_shared_object:
6666 case sys::fs::file_magic::coff_import_library:
6767 case sys::fs::file_magic::pecoff_executable:
6868 case sys::fs::file_magic::bitcode:
69 return ObjectFile::createSymbolicFile(scopedSource.take(), true, Type,
69 return ObjectFile::createSymbolicFile(scopedSource.release(), true, Type,
7070 Context);
7171 case sys::fs::file_magic::macho_universal_binary:
72 return MachOUniversalBinary::create(scopedSource.take());
72 return MachOUniversalBinary::create(scopedSource.release());
7373 case sys::fs::file_magic::unknown:
7474 case sys::fs::file_magic::windows_resource:
7575 // Unrecognized object file format.
8282 OwningPtr File;
8383 if (error_code EC = MemoryBuffer::getFileOrSTDIN(Path, File))
8484 return EC;
85 return createBinary(File.take());
85 return createBinary(File.release());
8686 }
10701070 OwningPtr Ret(new COFFObjectFile(Object, EC, BufferOwned));
10711071 if (EC)
10721072 return EC;
1073 return Ret.take();
1074 }
1073 return Ret.release();
1074 }
7878
7979 if (EC)
8080 return EC;
81 return R.take();
81 return R.release();
8282 }
8383
8484 } // end namespace llvm
147147 new IRObjectFile(Object, EC, Context, BufferOwned));
148148 if (EC)
149149 return EC;
150 return Ret.take();
150 return Ret.release();
151151 }
15641564
15651565 if (EC)
15661566 return EC;
1567 return Ret.take();
1567 return Ret.release();
15681568 }
15691569
15701570 } // end namespace object
9797 OwningPtr Ret(new MachOUniversalBinary(Source, EC));
9898 if (EC)
9999 return EC;
100 return Ret.take();
100 return Ret.release();
101101 }
102102
103103 MachOUniversalBinary::MachOUniversalBinary(MemoryBuffer *Source,
8989 OwningPtr File;
9090 if (error_code EC = MemoryBuffer::getFile(ObjectPath, File))
9191 return EC;
92 return createObjectFile(File.take());
92 return createObjectFile(File.release());
9393 }
6666
6767 if (!NewBuf) return ~0U;
6868
69 return AddNewSourceBuffer(NewBuf.take(), IncludeLoc);
69 return AddNewSourceBuffer(NewBuf.release(), IncludeLoc);
7070 }
7171
7272
8787 << ec.message() <<"\n";
8888 return 1;
8989 }
90 MemoryBuffer *F = File.take();
90 MemoryBuffer *F = File.release();
9191
9292 // Tell SrcMgr about this buffer, which is what TGParser will pick up.
9393 SrcMgr.AddNewSourceBuffer(F, SMLoc());
6767 OwningPtr SCL(new SpecialCaseList());
6868 if (!SCL->parse(MB, Error))
6969 return 0;
70 return SCL.take();
70 return SCL.release();
7171 }
7272
7373 SpecialCaseList *SpecialCaseList::createOrDie(const StringRef Path) {
144144 << "' passes compile correctly after the '"
145145 << getPassesString(Prefix) << "' passes: ";
146146
147 OwningPtr OriginalInput(BD.swapProgramIn(PrefixOutput.take()));
147 OwningPtr OriginalInput(BD.swapProgramIn(PrefixOutput.release()));
148148 if (BD.runPasses(BD.getProgram(), Suffix, BitcodeResult, false/*delete*/,
149149 true/*quiet*/)) {
150150 errs() << " Error running this sequence of passes"
167167 // Otherwise, we must not be running the bad pass anymore.
168168 outs() << " yup.\n"; // No miscompilation!
169169 // Restore orig program & free test.
170 delete BD.swapProgramIn(OriginalInput.take());
170 delete BD.swapProgramIn(OriginalInput.release());
171171 return NoFailure;
172172 }
173173
543543 Err.print(argv[0], errs());
544544 return 1;
545545 }
546 object::Archive *Ar = new object::Archive(ArBuf.take(), ec);
546 object::Archive *Ar = new object::Archive(ArBuf.release(), ec);
547547 if (ec || !Ar) {
548548 Err.print(argv[0], errs());
549549 return 1;
784784 object::Archive::child_iterator OldMember = Member.getOld();
785785 failIfError(OldMember->getMemoryBuffer(MemberBuffer));
786786 }
787 MemberBuffers[I] = MemberBuffer.take();
787 MemberBuffers[I] = MemberBuffer.release();
788788 }
789789
790790 if (Symtab) {
946946 }
947947
948948 if (!EC) {
949 object::Archive Archive(Buf.take(), EC);
949 object::Archive Archive(Buf.release(), EC);
950950
951951 if (EC) {
952952 errs() << ToolName << ": error loading '" << ArchiveName
9393 return;
9494 }
9595
96 ErrorOr ObjOrErr(ObjectFile::createObjectFile(Buff.take()));
96 ErrorOr ObjOrErr(ObjectFile::createObjectFile(Buff.release()));
9797 if (error_code EC = ObjOrErr.getError()) {
9898 errs() << Filename << ": " << EC.message() << '\n';
9999 return;
367367 errs() << ProgName << ": " << ec.message() << '\n';
368368 return 1;
369369 }
370 MemoryBuffer *Buffer = BufferPtr.take();
370 MemoryBuffer *Buffer = BufferPtr.release();
371371
372372 SourceMgr SrcMgr;
373373
140140 errs() << ToolName << ": " << ec.message() << '\n';
141141 return;
142142 }
143 MemoryBuffer *Buffer = BufferPtr.take();
143 MemoryBuffer *Buffer = BufferPtr.release();
144144
145145 SourceMgr SrcMgr;
146146
522522 return;
523523
524524 LLVMContext &Context = getGlobalContext();
525 ErrorOr BinaryOrErr = createBinary(Buffer.take(), &Context);
525 ErrorOr BinaryOrErr = createBinary(Buffer.release(), &Context);
526526 if (error(BinaryOrErr.getError(), Filename))
527527 return;
528528 OwningPtr Bin(BinaryOrErr.get());
208208 }
209209
210210 OwningPtr MachOOF(static_cast(
211 ObjectFile::createMachOObjectFile(Buff.take()).get()));
211 ObjectFile::createMachOObjectFile(Buff.release()).get()));
212212
213213 DisassembleInputMachO2(Filename, MachOOF.get());
214214 }
296296 errs() << "llvm-objdump: " << Filename << ": " << ec.message() << '\n';
297297 return;
298298 }
299 DbgObj = ObjectFile::createMachOObjectFile(Buf.take()).get();
299 DbgObj = ObjectFile::createMachOObjectFile(Buf.release()).get();
300300 }
301301
302302 // Setup the DIContext
139139 return Error("unable to read input: '" + ec.message() + "'");
140140
141141 // Load the object file
142 LoadedObject.reset(Dyld.loadObject(new ObjectBuffer(InputBuffer.take())));
142 LoadedObject.reset(Dyld.loadObject(new ObjectBuffer(InputBuffer.release())));
143143 if (!LoadedObject) {
144144 return Error(Dyld.getErrorString());
145145 }
197197 return Error("unable to read input: '" + ec.message() + "'");
198198
199199 // Load the object file
200 LoadedObject.reset(Dyld.loadObject(new ObjectBuffer(InputBuffer.take())));
200 LoadedObject.reset(Dyld.loadObject(new ObjectBuffer(InputBuffer.release())));
201201 if (!LoadedObject) {
202202 return Error(Dyld.getErrorString());
203203 }
314314 if (!error(BinaryOrErr.getError())) {
315315 OwningPtr ParsedBinary(BinaryOrErr.get());
316316 // Check if it's a universal binary.
317 Bin = ParsedBinary.take();
317 Bin = ParsedBinary.release();
318318 ParsedBinariesAndObjects.push_back(Bin);
319319 if (Bin->isMachO() || Bin->isMachOUniversalBinary()) {
320320 // On Darwin we may find DWARF in separate object file in
362362 return I->second;
363363 OwningPtr ParsedObj;
364364 if (!UB->getObjectForArch(Triple(ArchName).getArch(), ParsedObj)) {
365 Res = ParsedObj.take();
365 Res = ParsedObj.release();
366366 ParsedBinariesAndObjects.push_back(Res);
367367 }
368368 ObjectFileForArch[std::make_pair(UB, ArchName)] = Res;
4444 errs() << "Error: '" << ec.message() << "' opening file '" << InputFilename
4545 << "'\n";
4646 } else {
47 ec = coff2yaml(outs(), buf.take());
47 ec = coff2yaml(outs(), buf.release());
4848 if (ec)
4949 errs() << "Error: " << ec.message() << " dumping COFF file\n";
5050 }
9393 Function *FA, *FB;
9494 createTwoModuleCase(A, FA, B, FB);
9595
96 createJIT(A.take());
97 TheJIT->addModule(B.take());
96 createJIT(A.release());
97 TheJIT->addModule(B.release());
9898
9999 uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
100100 checkAdd(ptr);
113113 Function *FA, *FB;
114114 createTwoModuleCase(A, FA, B, FB);
115115
116 createJIT(A.take());
117 TheJIT->addModule(B.take());
116 createJIT(A.release());
117 TheJIT->addModule(B.release());
118118
119119 uint64_t ptr = TheJIT->getFunctionAddress(FB->getName().str());
120120 TheJIT->finalizeObject();
134134 Function *FA, *FB;
135135 createTwoModuleExternCase(A, FA, B, FB);
136136
137 createJIT(A.take());
138 TheJIT->addModule(B.take());
137 createJIT(A.release());
138 TheJIT->addModule(B.release());
139139
140140 uint64_t ptr = TheJIT->getFunctionAddress(FB->getName().str());
141141 TheJIT->finalizeObject();
155155 Function *FA, *FB;
156156 createTwoModuleExternCase(A, FA, B, FB);
157157
158 createJIT(A.take());
159 TheJIT->addModule(B.take());
158 createJIT(A.release());
159 TheJIT->addModule(B.release());
160160
161161 uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
162162 checkAdd(ptr);
176176 createTwoModuleExternCase(A, FA1, B, FB);
177177 FA2 = insertSimpleCallFunction(A.get(), FA1);
178178
179 createJIT(A.take());
180 TheJIT->addModule(B.take());
179 createJIT(A.release());
180 TheJIT->addModule(B.release());
181181
182182 uint64_t ptr = TheJIT->getFunctionAddress(FB->getName().str());
183183 TheJIT->finalizeObject();
212212 FB = startFunction(B.get(), "FB");
213213 endFunctionWithRet(FB, Builder.CreateLoad(GVB));
214214
215 createJIT(A.take());
216 TheJIT->addModule(B.take());
215 createJIT(A.release());
216 TheJIT->addModule(B.release());
217217
218218 uint64_t FBPtr = TheJIT->getFunctionAddress(FB->getName().str());
219219 TheJIT->finalizeObject();
240240 Function *FA, *FB, *FC;
241241 createThreeModuleCase(A, FA, B, FB, C, FC);
242242
243 createJIT(A.take());
244 TheJIT->addModule(B.take());
245 TheJIT->addModule(C.take());
243 createJIT(A.release());
244 TheJIT->addModule(B.release());
245 TheJIT->addModule(C.release());
246246
247247 uint64_t ptr = TheJIT->getFunctionAddress(FC->getName().str());
248248 checkAdd(ptr);
265265 Function *FA, *FB, *FC;
266266 createThreeModuleCase(A, FA, B, FB, C, FC);
267267
268 createJIT(A.take());
269 TheJIT->addModule(B.take());
270 TheJIT->addModule(C.take());
268 createJIT(A.release());
269 TheJIT->addModule(B.release());
270 TheJIT->addModule(C.release());
271271
272272 uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
273273 checkAdd(ptr);
290290 Function *FA, *FB, *FC;
291291 createThreeModuleChainedCallsCase(A, FA, B, FB, C, FC);
292292
293 createJIT(A.take());
294 TheJIT->addModule(B.take());
295 TheJIT->addModule(C.take());
293 createJIT(A.release());
294 TheJIT->addModule(B.release());
295 TheJIT->addModule(C.release());
296296
297297 uint64_t ptr = TheJIT->getFunctionAddress(FC->getName().str());
298298 checkAdd(ptr);
315315 Function *FA, *FB, *FC;
316316 createThreeModuleChainedCallsCase(A, FA, B, FB, C, FC);
317317
318 createJIT(A.take());
319 TheJIT->addModule(B.take());
320 TheJIT->addModule(C.take());
318 createJIT(A.release());
319 TheJIT->addModule(B.release());
320 TheJIT->addModule(C.release());
321321
322322 uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
323323 checkAdd(ptr);
340340 Function *FA, *FB1, *FB2;
341341 createCrossModuleRecursiveCase(A, FA, B, FB1, FB2);
342342
343 createJIT(A.take());
344 TheJIT->addModule(B.take());
343 createJIT(A.release());
344 TheJIT->addModule(B.release());
345345
346346 uint64_t ptr = TheJIT->getFunctionAddress(FA->getName().str());
347347 checkAccumulate(ptr);
361361 Function *FA, *FB1, *FB2;
362362 createCrossModuleRecursiveCase(A, FA, B, FB1, FB2);
363363
364 createJIT(A.take());
365 TheJIT->addModule(B.take());
364 createJIT(A.release());
365 TheJIT->addModule(B.release());
366366
367367 uint64_t ptr = TheJIT->getFunctionAddress(FB1->getName().str());
368368 checkAccumulate(ptr);
382382 Function *FA, *FB1, *FB2;
383383 createCrossModuleRecursiveCase(A, FA, B, FB1, FB2);
384384
385 createJIT(A.take());
386 TheJIT->addModule(B.take());
385 createJIT(A.release());
386 TheJIT->addModule(B.release());
387387
388388 uint64_t ptr = TheJIT->getFunctionAddress(FB1->getName().str());
389389 checkAccumulate(ptr);
121121 TEST_F(MCJITObjectCacheTest, SetNullObjectCache) {
122122 SKIP_UNSUPPORTED_PLATFORM;
123123
124 createJIT(M.take());
124 createJIT(M.release());
125125
126126 TheJIT->setObjectCache(NULL);
127127
137137 // Save a copy of the module pointer before handing it off to MCJIT.
138138 const Module * SavedModulePointer = M.get();
139139
140 createJIT(M.take());
140 createJIT(M.release());
141141
142142 TheJIT->setObjectCache(Cache.get());
143143
164164 OwningPtr Cache(new TestObjectCache);
165165
166166 // Compile this module with an MCJIT engine
167 createJIT(M.take());
167 createJIT(M.release());
168168 TheJIT->setObjectCache(Cache.get());
169169 TheJIT->finalizeObject();
170170
181181 const Module * SecondModulePointer = M.get();
182182
183183 // Create a new MCJIT instance to load this module then execute it.
184 createJIT(M.take());
184 createJIT(M.release());
185185 TheJIT->setObjectCache(Cache.get());
186186 compileAndRun();
187187
198198 OwningPtr Cache(new TestObjectCache);
199199
200200 // Compile this module with an MCJIT engine
201 createJIT(M.take());
201 createJIT(M.release());
202202 TheJIT->setObjectCache(Cache.get());
203203 TheJIT->finalizeObject();
204204
216216 const Module * SecondModulePointer = M.get();
217217
218218 // Create a new MCJIT instance to load this module then execute it.
219 createJIT(M.take());
219 createJIT(M.release());
220220 TheJIT->setObjectCache(Cache.get());
221221
222222 // Verify that our object cache does not contain the module yet.
4848
4949 int initialValue = 5;
5050 GlobalValue *Global = insertGlobalInt32(M.get(), "test_global", initialValue);
51 createJIT(M.take());
51 createJIT(M.release());
5252 void *globalPtr = TheJIT->getPointerToGlobal(Global);
5353 EXPECT_TRUE(0 != globalPtr)
5454 << "Unable to get pointer to global value from JIT";
6161 SKIP_UNSUPPORTED_PLATFORM;
6262
6363 Function *F = insertAddFunction(M.get());
64 createJIT(M.take());
64 createJIT(M.release());
6565 uint64_t addPtr = TheJIT->getFunctionAddress(F->getName().str());
6666 EXPECT_TRUE(0 != addPtr)
6767 << "Unable to get pointer to function from JIT";
8282
8383 int rc = 6;
8484 Function *Main = insertMainFunction(M.get(), 6);
85 createJIT(M.take());
85 createJIT(M.release());
8686 uint64_t ptr = TheJIT->getFunctionAddress(Main->getName().str());
8787 EXPECT_TRUE(0 != ptr)
8888 << "Unable to get pointer to main() from JIT";
103103 Value *ReadGlobal = Builder.CreateLoad(GV);
104104 endFunctionWithRet(ReturnGlobal, ReadGlobal);
105105
106 createJIT(M.take());
106 createJIT(M.release());
107107 uint64_t rgvPtr = TheJIT->getFunctionAddress(ReturnGlobal->getName().str());
108108 EXPECT_TRUE(0 != rgvPtr);
109109
174174 Inner = Outer;
175175 }
176176
177 createJIT(M.take());
177 createJIT(M.release());
178178 uint64_t ptr = TheJIT->getFunctionAddress(Outer->getName().str());
179179 EXPECT_TRUE(0 != ptr)
180180 << "Unable to get pointer to outer function from JIT";
831831 // If we want to canonicalize whitespace, strip excess whitespace from the
832832 // buffer containing the CHECK lines. Remove DOS style line endings.
833833 MemoryBuffer *F =
834 CanonicalizeInputFile(File.take(), NoCanonicalizeWhiteSpace);
834 CanonicalizeInputFile(File.release(), NoCanonicalizeWhiteSpace);
835835
836836 SM.AddNewSourceBuffer(F, SMLoc());
837837
12331233 // Remove duplicate spaces in the input file if requested.
12341234 // Remove DOS style line endings.
12351235 MemoryBuffer *F =
1236 CanonicalizeInputFile(File.take(), NoCanonicalizeWhiteSpace);
1236 CanonicalizeInputFile(File.release(), NoCanonicalizeWhiteSpace);
12371237
12381238 SM.AddNewSourceBuffer(F, SMLoc());
12391239
13651365 StringRef(II->TheDef->getName()).endswith("_Int"))
13661366 continue;
13671367
1368 Matchables.push_back(II.take());
1368 Matchables.push_back(II.release());
13691369 }
13701370
13711371 // Parse all of the InstAlias definitions and stick them in the list of
13891389 // Validate the alias definitions.
13901390 II->validate(CommentDelimiter, false);
13911391
1392 Matchables.push_back(II.take());
1392 Matchables.push_back(II.release());
13931393 }
13941394 }
13951395
14601460 AliasII->formTwoOperandAlias(Constraint);
14611461
14621462 // Add the alias to the matchables list.
1463 NewMatchables.push_back(AliasII.take());
1463 NewMatchables.push_back(AliasII.release());
14641464 }
14651465 } else
14661466 II->buildAliasResultOperands();
9797 Matcher *getNext() { return Next.get(); }
9898 const Matcher *getNext() const { return Next.get(); }
9999 void setNext(Matcher *C) { Next.reset(C); }
100 Matcher *takeNext() { return Next.take(); }
100 Matcher *takeNext() { return Next.release(); }
101101
102102 OwningPtr &getNextPtr() { return Next; }
103103
3232 for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) {
3333 OwningPtr Child(Scope->takeChild(i));
3434 ContractNodes(Child, CGP);
35 Scope->resetChild(i, Child.take());
35 Scope->resetChild(i, Child.release());
3636 }
3737 return;
3838 }
6161
6262 if (New) {
6363 // Insert the new node.
64 New->setNext(MatcherPtr.take());
64 New->setNext(MatcherPtr.release());
6565 MatcherPtr.reset(New);
6666 // Remove the old one.
6767 MC->setNext(MC->getNext()->takeNext());
8484 if (isa(N) && isa(N->getNext()) &&
8585 isa(N->getNext()->getNext())) {
8686 // Unlink the two nodes from the list.
87 Matcher *EmitNode = MatcherPtr.take();
87 Matcher *EmitNode = MatcherPtr.release();
8888 Matcher *MFR = EmitNode->takeNext();
8989 Matcher *Tail = MFR->takeNext();
9090
163163 isa(N)) &&
164164 isa(N->getNext())) {
165165 // Unlink the two nodes from the list.
166 Matcher *CheckType = MatcherPtr.take();
166 Matcher *CheckType = MatcherPtr.release();
167167 Matcher *CheckOpcode = CheckType->takeNext();
168168 Matcher *Tail = CheckOpcode->takeNext();
169169
197197 for (unsigned i = 0, e = Scope->getNumChildren(); i != e; ++i) {
198198 OwningPtr Child(Scope->takeChild(i));
199199 SinkPatternPredicates(Child);
200 Scope->resetChild(i, Child.take());
200 Scope->resetChild(i, Child.release());
201201 }
202202 return;
203203 }
216216
217217 // Okay, we know we can sink it past at least one node. Unlink it from the
218218 // chain and scan for the new insertion point.
219 MatcherPtr.take(); // Don't delete CPPM.
219 MatcherPtr.release(); // Don't delete CPPM.
220220 MatcherPtr.reset(CPPM->takeNext());
221221
222222 N = MatcherPtr.get();
271271 OwningPtr Child(Scope->takeChild(i));
272272 FactorNodes(Child);
273273
274 if (Matcher *N = Child.take())
274 if (Matcher *N = Child.release())
275275 OptionsToMatch.push_back(N);
276276 }
277277
515515 ContractNodes(MatcherPtr, CGP);
516516 SinkPatternPredicates(MatcherPtr);
517517 FactorNodes(MatcherPtr);
518 return MatcherPtr.take();
518 return MatcherPtr.release();
519519 }