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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Converts function declarations into constant value IDs. | 476 // Converts function declarations into constant value IDs. |
477 void createValueIDsForFunctions() { | 477 void createValueIDsForFunctions() { |
| 478 Ice::GlobalContext *Ctx = getTranslator().getContext(); |
478 for (const Ice::FunctionDeclaration *Func : FunctionDeclarations) { | 479 for (const Ice::FunctionDeclaration *Func : FunctionDeclarations) { |
| 480 if (!Func->verifyLinkageCorrect(Ctx)) { |
| 481 std::string Buffer; |
| 482 raw_string_ostream StrBuf(Buffer); |
| 483 StrBuf << "Function " << Func->getName() |
| 484 << " has incorrect linkage: " << Func->getLinkageName(); |
| 485 Error(StrBuf.str()); |
| 486 continue; |
| 487 } |
479 Ice::Constant *C = nullptr; | 488 Ice::Constant *C = nullptr; |
480 if (!isIRGenerationDisabled()) { | 489 if (!isIRGenerationDisabled()) { |
481 C = getConstantSym(Func->getName(), Func->getSuppressMangling(), | 490 C = getConstantSym(Func->getName(), Func->getSuppressMangling(), |
482 Func->isProto()); | 491 Func->isProto()); |
483 } | 492 } |
484 ValueIDConstants.push_back(C); | 493 ValueIDConstants.push_back(C); |
485 } | 494 } |
486 } | 495 } |
487 | 496 |
488 // Converts global variable declarations into constant value IDs. | 497 // Converts global variable declarations into constant value IDs. |
489 void createValueIDsForGlobalVars() { | 498 void createValueIDsForGlobalVars() { |
| 499 Ice::GlobalContext *Ctx = getTranslator().getContext(); |
490 for (const Ice::VariableDeclaration *Decl : *VariableDeclarations) { | 500 for (const Ice::VariableDeclaration *Decl : *VariableDeclarations) { |
| 501 if (!Decl->verifyLinkageCorrect(Ctx)) { |
| 502 std::string Buffer; |
| 503 raw_string_ostream StrBuf(Buffer); |
| 504 StrBuf << "Global " << Decl->getName() |
| 505 << " has incorrect linkage: " << Decl->getLinkageName(); |
| 506 Error(StrBuf.str()); |
| 507 } |
491 Ice::Constant *C = nullptr; | 508 Ice::Constant *C = nullptr; |
492 if (!isIRGenerationDisabled()) { | 509 if (!isIRGenerationDisabled()) { |
493 C = getConstantSym(Decl->getName(), Decl->getSuppressMangling(), | 510 C = getConstantSym(Decl->getName(), Decl->getSuppressMangling(), |
494 !Decl->hasInitializer()); | 511 !Decl->hasInitializer()); |
495 } | 512 } |
496 ValueIDConstants.push_back(C); | 513 ValueIDConstants.push_back(C); |
497 } | 514 } |
498 } | 515 } |
499 | 516 |
500 // 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... |
3280 raw_string_ostream StrBuf(Buffer); | 3297 raw_string_ostream StrBuf(Buffer); |
3281 StrBuf << IRFilename << ": Does not contain a module!"; | 3298 StrBuf << IRFilename << ": Does not contain a module!"; |
3282 llvm::report_fatal_error(StrBuf.str()); | 3299 llvm::report_fatal_error(StrBuf.str()); |
3283 } | 3300 } |
3284 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { | 3301 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { |
3285 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"); |
3286 } | 3303 } |
3287 } | 3304 } |
3288 | 3305 |
3289 } // end of namespace Ice | 3306 } // end of namespace Ice |
OLD | NEW |