llvm.org GIT mirror llvm / 1dc6608
Return an error_code from materializeAllPermanently. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199275 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 6 years ago
7 changed file(s) with 25 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
453453 /// Make sure all GlobalValues in this Module are fully read.
454454 error_code materializeAll();
455455
456 /// MaterializeAllPermanently - Make sure all GlobalValues in this Module are
457 /// fully read and clear the Materializer. If the module is corrupt, this
458 /// returns true, fills in the optional string with information about the
459 /// problem, and DOES NOT clear the old Materializer. If successful, this
460 /// returns false.
461 bool MaterializeAllPermanently(std::string *ErrInfo = 0);
456 /// Make sure all GlobalValues in this Module are fully read and clear the
457 /// Materializer. If the module is corrupt, this DOES NOT clear the old
458 /// Materializer.
459 error_code materializeAllPermanently();
462460
463461 /// @}
464462 /// @name Direct access to the globals list, functions list, and symbol table
33583358 static_cast(M->getMaterializer())->setBufferOwned(false);
33593359
33603360 // Read in the entire module, and destroy the BitcodeReader.
3361 if (M->MaterializeAllPermanently(ErrMsg)) {
3361 if (error_code EC = M->materializeAllPermanently()) {
3362 if (ErrMsg)
3363 *ErrMsg = EC.message();
33623364 delete M;
33633365 return 0;
33643366 }
3333 ///
3434 ExecutionEngine *Interpreter::create(Module *M, std::string* ErrStr) {
3535 // Tell this Module to materialize everything and release the GVMaterializer.
36 if (M->MaterializeAllPermanently(ErrStr))
36 if (error_code EC = M->materializeAllPermanently()) {
37 if (ErrStr)
38 *ErrStr = EC.message();
3739 // We got an error, just return 0
3840 return 0;
41 }
3942
4043 return new Interpreter(M);
4144 }
382382 return Materializer->MaterializeModule(this);
383383 }
384384
385 bool Module::MaterializeAllPermanently(std::string *ErrInfo) {
386 if (error_code EC = materializeAll()) {
387 if (ErrInfo)
388 *ErrInfo = EC.message();
389 return true;
390 }
385 error_code Module::materializeAllPermanently() {
386 if (error_code EC = materializeAll())
387 return EC;
388
391389 Materializer.reset();
392 return false;
390 return error_code::success();
393391 }
394392
395393 //===----------------------------------------------------------------------===//
168168
169169 TargetMachine *target = march->createTargetMachine(TripleStr, CPU, FeatureStr,
170170 options);
171 m->MaterializeAllPermanently();
171 m->materializeAllPermanently();
172172
173173 LTOModule *Ret = new LTOModule(m.take(), target);
174174 if (Ret->parseSymbols(errMsg)) {
412412 }
413413
414414 // If not jitting lazily, load the whole bitcode file eagerly too.
415 std::string ErrorMsg;
416415 if (NoLazyCompilation) {
417 if (Mod->MaterializeAllPermanently(&ErrorMsg)) {
416 if (error_code EC = Mod->materializeAllPermanently()) {
418417 errs() << argv[0] << ": bitcode didn't read correctly.\n";
419 errs() << "Reason: " << ErrorMsg << "\n";
418 errs() << "Reason: " << EC.message() << "\n";
420419 exit(1);
421420 }
422421 }
432431 DebugIRPass->runOnModule(*Mod);
433432 }
434433
434 std::string ErrorMsg;
435435 EngineBuilder builder(Mod);
436436 builder.setMArch(MArch);
437437 builder.setMCPU(MCPU);
134134 DisplayFilename = InputFilename;
135135 M.reset(getStreamedBitcodeModule(DisplayFilename, streamer, Context,
136136 &ErrorMessage));
137 if(M.get() != 0 && M->MaterializeAllPermanently(&ErrorMessage)) {
138 M.reset();
137 if(M.get() != 0) {
138 if (error_code EC = M->materializeAllPermanently()) {
139 ErrorMessage = EC.message();
140 M.reset();
141 }
139142 }
140143 }
141144