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

Side by Side Diff: src/IceConverter.cpp

Issue 876083007: Subzero: Emit functions and global initializers in a separate thread. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: More code review changes Created 5 years, 10 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/IceConverter.h ('k') | src/IceGlobalContext.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/IceConverter.cpp - Converts LLVM to Ice ---------------===// 1 //===- subzero/src/IceConverter.cpp - Converts LLVM to Ice ---------------===//
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 // This file implements the LLVM to ICE converter. 10 // This file implements the LLVM to ICE converter.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 class LLVM2ICEFunctionConverter : LLVM2ICEConverter { 77 class LLVM2ICEFunctionConverter : LLVM2ICEConverter {
78 LLVM2ICEFunctionConverter(const LLVM2ICEFunctionConverter &) = delete; 78 LLVM2ICEFunctionConverter(const LLVM2ICEFunctionConverter &) = delete;
79 LLVM2ICEFunctionConverter & 79 LLVM2ICEFunctionConverter &
80 operator=(const LLVM2ICEFunctionConverter &) = delete; 80 operator=(const LLVM2ICEFunctionConverter &) = delete;
81 81
82 public: 82 public:
83 LLVM2ICEFunctionConverter(Ice::Converter &Converter) 83 LLVM2ICEFunctionConverter(Ice::Converter &Converter)
84 : LLVM2ICEConverter(Converter), Func(nullptr) {} 84 : LLVM2ICEConverter(Converter), Func(nullptr) {}
85 85
86 void convertFunction(const Function *F) { 86 void convertFunction(const Function *F) {
87 Func = Ice::Cfg::create(Ctx); 87 if (Ctx->isIRGenerationDisabled())
88 return;
89 Func = Ice::Cfg::create(Ctx, Converter.getNextSequenceNumber());
88 Ice::Cfg::setCurrentCfg(Func.get()); 90 Ice::Cfg::setCurrentCfg(Func.get());
89 91
90 VarMap.clear(); 92 VarMap.clear();
91 NodeMap.clear(); 93 NodeMap.clear();
92 Func->setFunctionName(F->getName()); 94 Func->setFunctionName(F->getName());
93 Func->setReturnType(convertToIceType(F->getReturnType())); 95 Func->setReturnType(convertToIceType(F->getReturnType()));
94 Func->setInternal(F->hasInternalLinkage()); 96 Func->setInternal(F->hasInternalLinkage());
95 Ice::TimerMarker T(Ice::TimerStack::TT_llvmConvert, Func.get()); 97 Ice::TimerMarker T(Ice::TimerStack::TT_llvmConvert, Func.get());
96 98
97 // The initial definition/use of each arg is the entry node. 99 // The initial definition/use of each arg is the entry node.
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 raw_string_ostream StrBuf(Buffer); 796 raw_string_ostream StrBuf(Buffer);
795 StrBuf << "Unhandled global initializer: " << Initializer; 797 StrBuf << "Unhandled global initializer: " << Initializer;
796 report_fatal_error(StrBuf.str()); 798 report_fatal_error(StrBuf.str());
797 } 799 }
798 800
799 } // end of anonymous namespace 801 } // end of anonymous namespace
800 802
801 namespace Ice { 803 namespace Ice {
802 804
803 void Converter::nameUnnamedGlobalVariables(Module *Mod) { 805 void Converter::nameUnnamedGlobalVariables(Module *Mod) {
804 const IceString &GlobalPrefix = Flags.DefaultGlobalPrefix; 806 const IceString &GlobalPrefix = Ctx->getFlags().DefaultGlobalPrefix;
805 if (GlobalPrefix.empty()) 807 if (GlobalPrefix.empty())
806 return; 808 return;
807 uint32_t NameIndex = 0; 809 uint32_t NameIndex = 0;
808 for (auto V = Mod->global_begin(), E = Mod->global_end(); V != E; ++V) { 810 for (auto V = Mod->global_begin(), E = Mod->global_end(); V != E; ++V) {
809 if (!V->hasName()) { 811 if (!V->hasName()) {
810 V->setName(createUnnamedName(GlobalPrefix, NameIndex)); 812 V->setName(createUnnamedName(GlobalPrefix, NameIndex));
811 ++NameIndex; 813 ++NameIndex;
812 } else { 814 } else {
813 checkIfUnnamedNameSafe(V->getName(), "global", GlobalPrefix); 815 checkIfUnnamedNameSafe(V->getName(), "global", GlobalPrefix);
814 } 816 }
815 } 817 }
816 } 818 }
817 819
818 void Converter::nameUnnamedFunctions(Module *Mod) { 820 void Converter::nameUnnamedFunctions(Module *Mod) {
819 const IceString &FunctionPrefix = Flags.DefaultFunctionPrefix; 821 const IceString &FunctionPrefix = Ctx->getFlags().DefaultFunctionPrefix;
820 if (FunctionPrefix.empty()) 822 if (FunctionPrefix.empty())
821 return; 823 return;
822 uint32_t NameIndex = 0; 824 uint32_t NameIndex = 0;
823 for (Function &F : *Mod) { 825 for (Function &F : *Mod) {
824 if (!F.hasName()) { 826 if (!F.hasName()) {
825 F.setName(createUnnamedName(FunctionPrefix, NameIndex)); 827 F.setName(createUnnamedName(FunctionPrefix, NameIndex));
826 ++NameIndex; 828 ++NameIndex;
827 } else { 829 } else {
828 checkIfUnnamedNameSafe(F.getName(), "function", FunctionPrefix); 830 checkIfUnnamedNameSafe(F.getName(), "function", FunctionPrefix);
829 } 831 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 Var->setName(GV->getName()); 878 Var->setName(GV->getName());
877 Var->setAlignment(GV->getAlignment()); 879 Var->setAlignment(GV->getAlignment());
878 Var->setIsConstant(GV->isConstant()); 880 Var->setIsConstant(GV->isConstant());
879 Var->setLinkage(GV->getLinkage()); 881 Var->setLinkage(GV->getLinkage());
880 GlobalDeclarationMap[GV] = Var; 882 GlobalDeclarationMap[GV] = Var;
881 } 883 }
882 } 884 }
883 885
884 void Converter::convertGlobals(Module *Mod) { 886 void Converter::convertGlobals(Module *Mod) {
885 LLVM2ICEGlobalsConverter GlobalsConverter(*this); 887 LLVM2ICEGlobalsConverter GlobalsConverter(*this);
886 VariableDeclarationList VariableDeclarations; 888 VariableDeclarationList *VariableDeclarations = new VariableDeclarationList;
887 GlobalsConverter.convertGlobalsToIce(Mod, VariableDeclarations); 889 GlobalsConverter.convertGlobalsToIce(Mod, *VariableDeclarations);
888 lowerGlobals(VariableDeclarations); 890 lowerGlobals(VariableDeclarations);
889 } 891 }
890 892
891 void Converter::convertFunctions() { 893 void Converter::convertFunctions() {
892 const TimerStackIdT StackID = GlobalContext::TSK_Funcs; 894 const TimerStackIdT StackID = GlobalContext::TSK_Funcs;
893 for (const Function &I : *Mod) { 895 for (const Function &I : *Mod) {
894 if (I.empty()) 896 if (I.empty())
895 continue; 897 continue;
896 898
897 TimerIdT TimerID = 0; 899 TimerIdT TimerID = 0;
898 const bool TimeThisFunction = 900 const bool TimeThisFunction =
899 ALLOW_DUMP && Ctx->getFlags().TimeEachFunction; 901 ALLOW_DUMP && Ctx->getFlags().TimeEachFunction;
900 if (TimeThisFunction) { 902 if (TimeThisFunction) {
901 TimerID = Ctx->getTimerID(StackID, I.getName()); 903 TimerID = Ctx->getTimerID(StackID, I.getName());
902 Ctx->pushTimer(TimerID, StackID); 904 Ctx->pushTimer(TimerID, StackID);
903 } 905 }
904 LLVM2ICEFunctionConverter FunctionConverter(*this); 906 LLVM2ICEFunctionConverter FunctionConverter(*this);
905 FunctionConverter.convertFunction(&I); 907 FunctionConverter.convertFunction(&I);
906 if (TimeThisFunction) 908 if (TimeThisFunction)
907 Ctx->popTimer(TimerID, StackID); 909 Ctx->popTimer(TimerID, StackID);
908 } 910 }
909 } 911 }
910 912
911 } // end of namespace Ice 913 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceConverter.h ('k') | src/IceGlobalContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698