Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(450)

Side by Side Diff: src/PNaClTranslator.cpp

Issue 1766233002: Subzero: Fix symbol name mangling. Make flags global. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Code review changes Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceTargetLoweringX86BaseImpl.h ('k') | unittest/BitcodeMunge.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 const Ice::IceString &FunctionPrefix = 501 const Ice::IceString &FunctionPrefix =
502 getTranslator().getFlags().getDefaultFunctionPrefix(); 502 getTranslator().getFlags().getDefaultFunctionPrefix();
503 if (!FunctionPrefix.empty()) { 503 if (!FunctionPrefix.empty()) {
504 NaClBcIndexSize_t NameIndex = 0; 504 NaClBcIndexSize_t NameIndex = 0;
505 for (Ice::FunctionDeclaration *Func : FunctionDeclarations) { 505 for (Ice::FunctionDeclaration *Func : FunctionDeclarations) {
506 installDeclarationName(Func, FunctionPrefix, "function", NameIndex); 506 installDeclarationName(Func, FunctionPrefix, "function", NameIndex);
507 } 507 }
508 } 508 }
509 } 509 }
510 510
511 // Builds a constant symbol named Name, suppressing name mangling if 511 // Builds a constant symbol named Name. IsExternal is true iff the symbol is
512 // SuppressMangling. IsExternal is true iff the symbol is external. 512 // external.
513 Ice::Constant *getConstantSym(const Ice::IceString &Name, 513 Ice::Constant *getConstantSym(const Ice::IceString &Name,
514 bool SuppressMangling, bool IsExternal) const { 514 bool IsExternal) const {
515 if (IsExternal) { 515 if (IsExternal) {
516 return getTranslator().getContext()->getConstantExternSym(Name); 516 return getTranslator().getContext()->getConstantExternSym(Name);
517 } else { 517 } else {
518 const Ice::RelocOffsetT Offset = 0; 518 const Ice::RelocOffsetT Offset = 0;
519 return getTranslator().getContext()->getConstantSym(Offset, Name, 519 return getTranslator().getContext()->getConstantSym(Offset, Name);
520 SuppressMangling);
521 } 520 }
522 } 521 }
523 522
524 void reportLinkageError(const char *Kind, 523 void reportLinkageError(const char *Kind,
525 const Ice::GlobalDeclaration &Decl) { 524 const Ice::GlobalDeclaration &Decl) {
526 std::string Buffer; 525 std::string Buffer;
527 raw_string_ostream StrBuf(Buffer); 526 raw_string_ostream StrBuf(Buffer);
528 StrBuf << Kind << " " << Decl.getName() 527 StrBuf << Kind << " " << Decl.getName()
529 << " has incorrect linkage: " << Decl.getLinkageName(); 528 << " has incorrect linkage: " << Decl.getLinkageName();
530 if (Decl.isExternal()) 529 if (Decl.isExternal())
531 StrBuf << "\n Use flag -allow-externally-defined-symbols to override"; 530 StrBuf << "\n Use flag -allow-externally-defined-symbols to override";
532 Error(StrBuf.str()); 531 Error(StrBuf.str());
533 } 532 }
534 533
535 // Converts function declarations into constant value IDs. 534 // Converts function declarations into constant value IDs.
536 void createValueIDsForFunctions() { 535 void createValueIDsForFunctions() {
537 Ice::GlobalContext *Ctx = getTranslator().getContext(); 536 Ice::GlobalContext *Ctx = getTranslator().getContext();
538 for (const Ice::FunctionDeclaration *Func : FunctionDeclarations) { 537 for (const Ice::FunctionDeclaration *Func : FunctionDeclarations) {
539 if (!Func->verifyLinkageCorrect(Ctx)) 538 if (!Func->verifyLinkageCorrect(Ctx))
540 reportLinkageError("Function", *Func); 539 reportLinkageError("Function", *Func);
541 Ice::Constant *C = getConstantSym( 540 Ice::Constant *C = getConstantSym(Func->getName(), Func->isProto());
542 Func->getName(), Func->getSuppressMangling(), Func->isProto());
543 ValueIDConstants.push_back(C); 541 ValueIDConstants.push_back(C);
544 } 542 }
545 } 543 }
546 544
547 // Converts global variable declarations into constant value IDs. 545 // Converts global variable declarations into constant value IDs.
548 void createValueIDsForGlobalVars() { 546 void createValueIDsForGlobalVars() {
549 Ice::GlobalContext *Ctx = getTranslator().getContext(); 547 Ice::GlobalContext *Ctx = getTranslator().getContext();
550 for (const Ice::VariableDeclaration *Decl : *VariableDeclarations) { 548 for (const Ice::VariableDeclaration *Decl : *VariableDeclarations) {
551 if (!Decl->verifyLinkageCorrect(Ctx)) 549 if (!Decl->verifyLinkageCorrect(Ctx))
552 reportLinkageError("Global", *Decl); 550 reportLinkageError("Global", *Decl);
553 Ice::Constant *C = 551 Ice::Constant *C =
554 getConstantSym(Decl->getName(), Decl->getSuppressMangling(), 552 getConstantSym(Decl->getName(), !Decl->hasInitializer());
555 !Decl->hasInitializer());
556 ValueIDConstants.push_back(C); 553 ValueIDConstants.push_back(C);
557 } 554 }
558 } 555 }
559 556
560 // Reports that type ID is undefined, or not of the WantedType. 557 // Reports that type ID is undefined, or not of the WantedType.
561 void reportBadTypeIDAs(NaClBcIndexSize_t ID, const ExtendedType *Ty, 558 void reportBadTypeIDAs(NaClBcIndexSize_t ID, const ExtendedType *Ty,
562 ExtendedType::TypeKind WantedType); 559 ExtendedType::TypeKind WantedType);
563 560
564 // Reports that there is no function declaration for ID. Returns an error 561 // Reports that there is no function declaration for ID. Returns an error
565 // recovery value to use. 562 // recovery value to use.
(...skipping 2639 matching lines...) Expand 10 before | Expand all | Expand 10 after
3205 raw_string_ostream StrBuf(Buffer); 3202 raw_string_ostream StrBuf(Buffer);
3206 StrBuf << IRFilename << ": Does not contain a module!"; 3203 StrBuf << IRFilename << ": Does not contain a module!";
3207 llvm::report_fatal_error(StrBuf.str()); 3204 llvm::report_fatal_error(StrBuf.str());
3208 } 3205 }
3209 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) { 3206 if (InputStreamFile.getBitcodeBytes().getExtent() % 4 != 0) {
3210 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes"); 3207 llvm::report_fatal_error("Bitcode stream should be a multiple of 4 bytes");
3211 } 3208 }
3212 } 3209 }
3213 3210
3214 } // end of namespace Ice 3211 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLoweringX86BaseImpl.h ('k') | unittest/BitcodeMunge.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698