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

Side by Side Diff: src/IceConverter.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: Cleanup 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
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 /// \file 10 /// \file
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 explicit LLVM2ICEFunctionConverter(Ice::Converter &Converter) 94 explicit LLVM2ICEFunctionConverter(Ice::Converter &Converter)
95 : LLVM2ICEConverter(Converter), Func(nullptr) {} 95 : LLVM2ICEConverter(Converter), Func(nullptr) {}
96 96
97 void convertFunction(const Function *F) { 97 void convertFunction(const Function *F) {
98 Func = Ice::Cfg::create(Ctx, Converter.getNextSequenceNumber()); 98 Func = Ice::Cfg::create(Ctx, Converter.getNextSequenceNumber());
99 { 99 {
100 Ice::CfgLocalAllocatorScope _(Func.get()); 100 Ice::CfgLocalAllocatorScope _(Func.get());
101 101
102 VarMap.clear(); 102 VarMap.clear();
103 NodeMap.clear(); 103 NodeMap.clear();
104 Func->setFunctionName(F->getName()); 104 Func->setFunctionName(Ice::GlobalContext::mangleName(F->getName()));
105 Func->setReturnType(convertToIceType(F->getReturnType())); 105 Func->setReturnType(convertToIceType(F->getReturnType()));
106 Func->setInternal(F->hasInternalLinkage()); 106 Func->setInternal(F->hasInternalLinkage());
107 Ice::TimerMarker T(Ice::TimerStack::TT_llvmConvert, Func.get()); 107 Ice::TimerMarker T(Ice::TimerStack::TT_llvmConvert, Func.get());
108 108
109 // The initial definition/use of each arg is the entry node. 109 // The initial definition/use of each arg is the entry node.
110 for (auto ArgI = F->arg_begin(), ArgE = F->arg_end(); ArgI != ArgE; 110 for (auto ArgI = F->arg_begin(), ArgE = F->arg_end(); ArgI != ArgE;
111 ++ArgI) { 111 ++ArgI) {
112 Func->addArg(mapValueToIceVar(ArgI)); 112 Func->addArg(mapValueToIceVar(ArgI));
113 } 113 }
114 114
(...skipping 19 matching lines...) Expand all
134 if (const auto *Func = llvm::dyn_cast<Ice::FunctionDeclaration>(Decl)) 134 if (const auto *Func = llvm::dyn_cast<Ice::FunctionDeclaration>(Decl))
135 IsUndefined = Func->isProto(); 135 IsUndefined = Func->isProto();
136 else if (const auto *Var = llvm::dyn_cast<Ice::VariableDeclaration>(Decl)) 136 else if (const auto *Var = llvm::dyn_cast<Ice::VariableDeclaration>(Decl))
137 IsUndefined = !Var->hasInitializer(); 137 IsUndefined = !Var->hasInitializer();
138 else 138 else
139 report_fatal_error("Unhandled GlobalDeclaration type"); 139 report_fatal_error("Unhandled GlobalDeclaration type");
140 if (IsUndefined) 140 if (IsUndefined)
141 return Ctx->getConstantExternSym(Decl->getName()); 141 return Ctx->getConstantExternSym(Decl->getName());
142 else { 142 else {
143 const Ice::RelocOffsetT Offset = 0; 143 const Ice::RelocOffsetT Offset = 0;
144 return Ctx->getConstantSym(Offset, Decl->getName(), 144 return Ctx->getConstantSym(Offset, Decl->getName());
145 Decl->getSuppressMangling());
146 } 145 }
147 } else if (const auto CI = dyn_cast<ConstantInt>(Const)) { 146 } else if (const auto CI = dyn_cast<ConstantInt>(Const)) {
148 Ice::Type Ty = convertToIceType(CI->getType()); 147 Ice::Type Ty = convertToIceType(CI->getType());
149 return Ctx->getConstantInt(Ty, CI->getSExtValue()); 148 return Ctx->getConstantInt(Ty, CI->getSExtValue());
150 } else if (const auto CFP = dyn_cast<ConstantFP>(Const)) { 149 } else if (const auto CFP = dyn_cast<ConstantFP>(Const)) {
151 Ice::Type Type = convertToIceType(CFP->getType()); 150 Ice::Type Type = convertToIceType(CFP->getType());
152 if (Type == Ice::IceType_f32) 151 if (Type == Ice::IceType_f32)
153 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat()); 152 return Ctx->getConstantFloat(CFP->getValueAPF().convertToFloat());
154 else if (Type == Ice::IceType_f64) 153 else if (Type == Ice::IceType_f64)
155 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble()); 154 return Ctx->getConstantDouble(CFP->getValueAPF().convertToDouble());
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 } 881 }
883 if (!IceFunc->validateTypeSignature(Ctx)) 882 if (!IceFunc->validateTypeSignature(Ctx))
884 report_fatal_error(IceFunc->getTypeSignatureError(Ctx)); 883 report_fatal_error(IceFunc->getTypeSignatureError(Ctx));
885 GlobalDeclarationMap[&Func] = IceFunc; 884 GlobalDeclarationMap[&Func] = IceFunc;
886 } 885 }
887 // Install global variable declarations. 886 // Install global variable declarations.
888 for (Module::const_global_iterator I = Mod->global_begin(), 887 for (Module::const_global_iterator I = Mod->global_begin(),
889 E = Mod->global_end(); 888 E = Mod->global_end();
890 I != E; ++I) { 889 I != E; ++I) {
891 const GlobalVariable *GV = I; 890 const GlobalVariable *GV = I;
892 auto *Var = VariableDeclaration::create(Ctx); 891 constexpr bool NoSuppressMangling = false;
893 Var->setName(GV->getName()); 892 auto *Var =
893 VariableDeclaration::create(Ctx, NoSuppressMangling, GV->getLinkage());
894 Var->setAlignment(GV->getAlignment()); 894 Var->setAlignment(GV->getAlignment());
895 Var->setIsConstant(GV->isConstant()); 895 Var->setIsConstant(GV->isConstant());
896 Var->setLinkage(GV->getLinkage()); 896 Var->setName(GV->getName());
897 if (!Var->verifyLinkageCorrect(Ctx)) { 897 if (!Var->verifyLinkageCorrect(Ctx)) {
898 std::string Buffer; 898 std::string Buffer;
899 raw_string_ostream StrBuf(Buffer); 899 raw_string_ostream StrBuf(Buffer);
900 StrBuf << "Global " << Var->getName() 900 StrBuf << "Global " << Var->getName()
901 << " has incorrect linkage: " << Var->getLinkageName(); 901 << " has incorrect linkage: " << Var->getLinkageName();
902 if (Var->isExternal()) 902 if (Var->isExternal())
903 StrBuf << "\n Use flag -allow-externally-defined-symbols to override"; 903 StrBuf << "\n Use flag -allow-externally-defined-symbols to override";
904 report_fatal_error(StrBuf.str()); 904 report_fatal_error(StrBuf.str());
905 } 905 }
906 GlobalDeclarationMap[GV] = Var; 906 GlobalDeclarationMap[GV] = Var;
(...skipping 17 matching lines...) Expand all
924 Ctx->pushTimer(TimerID, StackID); 924 Ctx->pushTimer(TimerID, StackID);
925 } 925 }
926 LLVM2ICEFunctionConverter FunctionConverter(*this); 926 LLVM2ICEFunctionConverter FunctionConverter(*this);
927 FunctionConverter.convertFunction(&I); 927 FunctionConverter.convertFunction(&I);
928 if (TimeThisFunction) 928 if (TimeThisFunction)
929 Ctx->popTimer(TimerID, StackID); 929 Ctx->popTimer(TimerID, StackID);
930 } 930 }
931 } 931 }
932 932
933 } // end of namespace Ice 933 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698