OLD | NEW |
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 849 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
860 FunctionType *FuncType = Func.getFunctionType(); | 860 FunctionType *FuncType = Func.getFunctionType(); |
861 Signature.setReturnType( | 861 Signature.setReturnType( |
862 Converter.convertToIceType(FuncType->getReturnType())); | 862 Converter.convertToIceType(FuncType->getReturnType())); |
863 for (size_t I = 0; I < FuncType->getNumParams(); ++I) { | 863 for (size_t I = 0; I < FuncType->getNumParams(); ++I) { |
864 Signature.appendArgType( | 864 Signature.appendArgType( |
865 Converter.convertToIceType(FuncType->getParamType(I))); | 865 Converter.convertToIceType(FuncType->getParamType(I))); |
866 } | 866 } |
867 FunctionDeclaration *IceFunc = FunctionDeclaration::create( | 867 FunctionDeclaration *IceFunc = FunctionDeclaration::create( |
868 Ctx, Signature, Func.getCallingConv(), Func.getLinkage(), Func.empty()); | 868 Ctx, Signature, Func.getCallingConv(), Func.getLinkage(), Func.empty()); |
869 IceFunc->setName(Func.getName()); | 869 IceFunc->setName(Func.getName()); |
| 870 if (!IceFunc->verifyLinkageCorrect(Ctx)) { |
| 871 std::string Buffer; |
| 872 raw_string_ostream StrBuf(Buffer); |
| 873 StrBuf << "Function " << IceFunc->getName() |
| 874 << " has incorrect linkage: " << IceFunc->getLinkageName(); |
| 875 report_fatal_error(StrBuf.str()); |
| 876 } |
870 GlobalDeclarationMap[&Func] = IceFunc; | 877 GlobalDeclarationMap[&Func] = IceFunc; |
871 } | 878 } |
872 // Install global variable declarations. | 879 // Install global variable declarations. |
873 for (Module::const_global_iterator I = Mod->global_begin(), | 880 for (Module::const_global_iterator I = Mod->global_begin(), |
874 E = Mod->global_end(); | 881 E = Mod->global_end(); |
875 I != E; ++I) { | 882 I != E; ++I) { |
876 const GlobalVariable *GV = I; | 883 const GlobalVariable *GV = I; |
877 VariableDeclaration *Var = VariableDeclaration::create(Ctx); | 884 VariableDeclaration *Var = VariableDeclaration::create(Ctx); |
878 Var->setName(GV->getName()); | 885 Var->setName(GV->getName()); |
879 Var->setAlignment(GV->getAlignment()); | 886 Var->setAlignment(GV->getAlignment()); |
880 Var->setIsConstant(GV->isConstant()); | 887 Var->setIsConstant(GV->isConstant()); |
881 Var->setLinkage(GV->getLinkage()); | 888 Var->setLinkage(GV->getLinkage()); |
| 889 if (!Var->verifyLinkageCorrect(Ctx)) { |
| 890 std::string Buffer; |
| 891 raw_string_ostream StrBuf(Buffer); |
| 892 StrBuf << "Global " << Var->getName() |
| 893 << " has incorrect linkage: " << Var->getLinkageName(); |
| 894 report_fatal_error(StrBuf.str()); |
| 895 } |
882 GlobalDeclarationMap[GV] = Var; | 896 GlobalDeclarationMap[GV] = Var; |
883 } | 897 } |
884 } | 898 } |
885 | 899 |
886 void Converter::convertGlobals(Module *Mod) { | 900 void Converter::convertGlobals(Module *Mod) { |
887 lowerGlobals(LLVM2ICEGlobalsConverter(*this).convertGlobalsToIce(Mod)); | 901 lowerGlobals(LLVM2ICEGlobalsConverter(*this).convertGlobalsToIce(Mod)); |
888 } | 902 } |
889 | 903 |
890 void Converter::convertFunctions() { | 904 void Converter::convertFunctions() { |
891 const TimerStackIdT StackID = GlobalContext::TSK_Funcs; | 905 const TimerStackIdT StackID = GlobalContext::TSK_Funcs; |
892 for (const Function &I : *Mod) { | 906 for (const Function &I : *Mod) { |
893 if (I.empty()) | 907 if (I.empty()) |
894 continue; | 908 continue; |
895 | 909 |
896 TimerIdT TimerID = 0; | 910 TimerIdT TimerID = 0; |
897 const bool TimeThisFunction = Ctx->getFlags().getTimeEachFunction(); | 911 const bool TimeThisFunction = Ctx->getFlags().getTimeEachFunction(); |
898 if (TimeThisFunction) { | 912 if (TimeThisFunction) { |
899 TimerID = Ctx->getTimerID(StackID, I.getName()); | 913 TimerID = Ctx->getTimerID(StackID, I.getName()); |
900 Ctx->pushTimer(TimerID, StackID); | 914 Ctx->pushTimer(TimerID, StackID); |
901 } | 915 } |
902 LLVM2ICEFunctionConverter FunctionConverter(*this); | 916 LLVM2ICEFunctionConverter FunctionConverter(*this); |
903 FunctionConverter.convertFunction(&I); | 917 FunctionConverter.convertFunction(&I); |
904 if (TimeThisFunction) | 918 if (TimeThisFunction) |
905 Ctx->popTimer(TimerID, StackID); | 919 Ctx->popTimer(TimerID, StackID); |
906 } | 920 } |
907 } | 921 } |
908 | 922 |
909 } // end of namespace Ice | 923 } // end of namespace Ice |
OLD | NEW |