OLD | NEW |
1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// | 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 bool SuppressMangling, bool IsExternal) const { | 466 bool SuppressMangling, bool IsExternal) const { |
467 if (IsExternal) { | 467 if (IsExternal) { |
468 return getTranslator().getContext()->getConstantExternSym(Name); | 468 return getTranslator().getContext()->getConstantExternSym(Name); |
469 } else { | 469 } else { |
470 const Ice::RelocOffsetT Offset = 0; | 470 const Ice::RelocOffsetT Offset = 0; |
471 return getTranslator().getContext()->getConstantSym(Offset, Name, | 471 return getTranslator().getContext()->getConstantSym(Offset, Name, |
472 SuppressMangling); | 472 SuppressMangling); |
473 } | 473 } |
474 } | 474 } |
475 | 475 |
| 476 void reportLinkageError(const char *Kind, |
| 477 const Ice::GlobalDeclaration &Decl) { |
| 478 std::string Buffer; |
| 479 raw_string_ostream StrBuf(Buffer); |
| 480 StrBuf << Kind << " " << Decl.getName() |
| 481 << " has incorrect linkage: " << Decl.getLinkageName(); |
| 482 if (Decl.isExternal()) |
| 483 StrBuf << "\n Use flag -allow-externally-defined-symbols to override"; |
| 484 Error(StrBuf.str()); |
| 485 } |
| 486 |
476 // Converts function declarations into constant value IDs. | 487 // Converts function declarations into constant value IDs. |
477 void createValueIDsForFunctions() { | 488 void createValueIDsForFunctions() { |
478 Ice::GlobalContext *Ctx = getTranslator().getContext(); | 489 Ice::GlobalContext *Ctx = getTranslator().getContext(); |
479 for (const Ice::FunctionDeclaration *Func : FunctionDeclarations) { | 490 for (const Ice::FunctionDeclaration *Func : FunctionDeclarations) { |
480 if (!Func->verifyLinkageCorrect(Ctx)) { | 491 if (!Func->verifyLinkageCorrect(Ctx)) |
481 std::string Buffer; | 492 reportLinkageError("Function", *Func); |
482 raw_string_ostream StrBuf(Buffer); | |
483 StrBuf << "Function " << Func->getName() | |
484 << " has incorrect linkage: " << Func->getLinkageName(); | |
485 Error(StrBuf.str()); | |
486 continue; | |
487 } | |
488 Ice::Constant *C = nullptr; | 493 Ice::Constant *C = nullptr; |
489 if (!isIRGenerationDisabled()) { | 494 if (!isIRGenerationDisabled()) { |
490 C = getConstantSym(Func->getName(), Func->getSuppressMangling(), | 495 C = getConstantSym(Func->getName(), Func->getSuppressMangling(), |
491 Func->isProto()); | 496 Func->isProto()); |
492 } | 497 } |
493 ValueIDConstants.push_back(C); | 498 ValueIDConstants.push_back(C); |
494 } | 499 } |
495 } | 500 } |
496 | 501 |
497 // Converts global variable declarations into constant value IDs. | 502 // Converts global variable declarations into constant value IDs. |
498 void createValueIDsForGlobalVars() { | 503 void createValueIDsForGlobalVars() { |
499 Ice::GlobalContext *Ctx = getTranslator().getContext(); | 504 Ice::GlobalContext *Ctx = getTranslator().getContext(); |
500 for (const Ice::VariableDeclaration *Decl : *VariableDeclarations) { | 505 for (const Ice::VariableDeclaration *Decl : *VariableDeclarations) { |
501 if (!Decl->verifyLinkageCorrect(Ctx)) { | 506 if (!Decl->verifyLinkageCorrect(Ctx)) |
502 std::string Buffer; | 507 reportLinkageError("Global", *Decl); |
503 raw_string_ostream StrBuf(Buffer); | |
504 StrBuf << "Global " << Decl->getName() | |
505 << " has incorrect linkage: " << Decl->getLinkageName(); | |
506 Error(StrBuf.str()); | |
507 } | |
508 Ice::Constant *C = nullptr; | 508 Ice::Constant *C = nullptr; |
509 if (!isIRGenerationDisabled()) { | 509 if (!isIRGenerationDisabled()) { |
510 C = getConstantSym(Decl->getName(), Decl->getSuppressMangling(), | 510 C = getConstantSym(Decl->getName(), Decl->getSuppressMangling(), |
511 !Decl->hasInitializer()); | 511 !Decl->hasInitializer()); |
512 } | 512 } |
513 ValueIDConstants.push_back(C); | 513 ValueIDConstants.push_back(C); |
514 } | 514 } |
515 } | 515 } |
516 | 516 |
517 // Reports that type ID is undefined, or not of the WantedType. | 517 // Reports that type ID is undefined, or not of the WantedType. |
(...skipping 2779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3297 raw_string_ostream StrBuf(Buffer); | 3297 raw_string_ostream StrBuf(Buffer); |
3298 StrBuf << IRFilename << ": Does not contain a module!"; | 3298 StrBuf << IRFilename << ": Does not contain a module!"; |
3299 llvm::report_fatal_error(StrBuf.str()); | 3299 llvm::report_fatal_error(StrBuf.str()); |
3300 } | 3300 } |
3301 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { | 3301 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { |
3302 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); | 3302 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); |
3303 } | 3303 } |
3304 } | 3304 } |
3305 | 3305 |
3306 } // end of namespace Ice | 3306 } // end of namespace Ice |
OLD | NEW |