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

Side by Side Diff: src/IceConverter.cpp

Issue 641193002: Introduce the notion of function addresses in Subzero. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Clean up code and fix nits. Created 6 years, 2 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 // This file implements the LLVM to ICE converter. 10 // This file implements the LLVM to ICE converter.
(...skipping 16 matching lines...) Expand all
27 #include "IceConverter.h" 27 #include "IceConverter.h"
28 #include "IceDefs.h" 28 #include "IceDefs.h"
29 #include "IceGlobalContext.h" 29 #include "IceGlobalContext.h"
30 #include "IceGlobalInits.h" 30 #include "IceGlobalInits.h"
31 #include "IceInst.h" 31 #include "IceInst.h"
32 #include "IceOperand.h" 32 #include "IceOperand.h"
33 #include "IceTargetLowering.h" 33 #include "IceTargetLowering.h"
34 #include "IceTypes.h" 34 #include "IceTypes.h"
35 #include "IceTypeConverter.h" 35 #include "IceTypeConverter.h"
36 36
37 using namespace llvm; 37 using namespace llvm;
Jim Stichnoth 2014/10/10 13:15:00 A number of "llvm::" prefixes crept in, should the
Karl 2014/10/10 20:17:30 There are several comments around the topic of nam
38 38
39 namespace { 39 namespace {
40 40
41 // Debugging helper 41 // Debugging helper
42 template <typename T> static std::string LLVMObjectAsString(const T *O) { 42 template <typename T> static std::string LLVMObjectAsString(const T *O) {
43 std::string Dump; 43 std::string Dump;
44 raw_string_ostream Stream(Dump); 44 raw_string_ostream Stream(Dump);
45 O->print(Stream); 45 O->print(Stream);
46 return Stream.str(); 46 return Stream.str();
47 } 47 }
48 48
49 // Base class for converting LLVM to ICE. 49 // Base class for converting LLVM to ICE.
50 class LLVM2ICEConverter { 50 class LLVM2ICEConverter {
51 LLVM2ICEConverter(const LLVM2ICEConverter &) = delete; 51 LLVM2ICEConverter(const LLVM2ICEConverter &) = delete;
52 LLVM2ICEConverter &operator=(const LLVM2ICEConverter &) = delete; 52 LLVM2ICEConverter &operator=(const LLVM2ICEConverter &) = delete;
53 53
54 public: 54 public:
55 LLVM2ICEConverter(Ice::GlobalContext *Ctx, LLVMContext &LLVMContext) 55 LLVM2ICEConverter(Ice::Converter &Converter)
56 : Ctx(Ctx), TypeConverter(LLVMContext) {} 56 : Converter(Converter), Ctx(Converter.getContext()),
57 TypeConverter(Converter.getModule()->getContext()) {}
58
59 public:
jvoung (off chromium) 2014/10/10 01:47:27 already in the public: section?
Karl 2014/10/10 20:17:29 Removed.
60 Ice::Converter &getConverter() { return Converter; }
jvoung (off chromium) 2014/10/10 01:47:28 const ?
Karl 2014/10/10 20:17:30 Done.
57 61
58 protected: 62 protected:
59 // Data 63 Ice::Converter &Converter;
60 Ice::GlobalContext *Ctx; 64 Ice::GlobalContext *Ctx;
61 const Ice::TypeConverter TypeConverter; 65 const Ice::TypeConverter TypeConverter;
62 }; 66 };
63 67
64 // Converter from LLVM functions to ICE. The entry point is the 68 // Converter from LLVM functions to ICE. The entry point is the
65 // convertFunction method. 69 // convertFunction method.
66 // 70 //
67 // Note: this currently assumes that the given IR was verified to be 71 // Note: this currently assumes that the given IR was verified to be
68 // valid PNaCl bitcode. Otherwise, the behavior is undefined. 72 // valid PNaCl bitcode. Otherwise, the behavior is undefined.
69 class LLVM2ICEFunctionConverter : LLVM2ICEConverter { 73 class LLVM2ICEFunctionConverter : LLVM2ICEConverter {
70 LLVM2ICEFunctionConverter(const LLVM2ICEFunctionConverter &) = delete; 74 LLVM2ICEFunctionConverter(const LLVM2ICEFunctionConverter &) = delete;
71 LLVM2ICEFunctionConverter & 75 LLVM2ICEFunctionConverter &
72 operator=(const LLVM2ICEFunctionConverter &) = delete; 76 operator=(const LLVM2ICEFunctionConverter &) = delete;
73 77
74 public: 78 public:
75 LLVM2ICEFunctionConverter(Ice::GlobalContext *Ctx, LLVMContext &LLVMContext) 79 LLVM2ICEFunctionConverter(Ice::Converter &Converter)
76 : LLVM2ICEConverter(Ctx, LLVMContext), Func(NULL) {} 80 : LLVM2ICEConverter(Converter), Func(NULL) {}
77 81
78 // Caller is expected to delete the returned Ice::Cfg object. 82 // Caller is expected to delete the returned Ice::Cfg object.
79 Ice::Cfg *convertFunction(const Function *F) { 83 Ice::Cfg *convertFunction(const Function *F) {
80 VarMap.clear(); 84 VarMap.clear();
81 NodeMap.clear(); 85 NodeMap.clear();
82 Func = new Ice::Cfg(Ctx); 86 Func = new Ice::Cfg(Ctx);
83 Func->setFunctionName(F->getName()); 87 Func->setFunctionName(F->getName());
84 Func->setReturnType(convertToIceType(F->getReturnType())); 88 Func->setReturnType(convertToIceType(F->getReturnType()));
85 Func->setInternal(F->hasInternalLinkage()); 89 Func->setInternal(F->hasInternalLinkage());
86 Ice::TimerMarker T(Ice::TimerStack::TT_llvmConvert, Func); 90 Ice::TimerMarker T(Ice::TimerStack::TT_llvmConvert, Func);
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 // convertGlobalsToIce method. 633 // convertGlobalsToIce method.
630 // 634 //
631 // Note: this currently assumes that the given IR was verified to be 635 // Note: this currently assumes that the given IR was verified to be
632 // valid PNaCl bitcode. Othewise, the behavior is undefined. 636 // valid PNaCl bitcode. Othewise, the behavior is undefined.
633 class LLVM2ICEGlobalsConverter : public LLVM2ICEConverter { 637 class LLVM2ICEGlobalsConverter : public LLVM2ICEConverter {
634 LLVM2ICEGlobalsConverter(const LLVM2ICEGlobalsConverter &) = delete; 638 LLVM2ICEGlobalsConverter(const LLVM2ICEGlobalsConverter &) = delete;
635 LLVM2ICEGlobalsConverter & 639 LLVM2ICEGlobalsConverter &
636 operator-(const LLVM2ICEGlobalsConverter &) = delete; 640 operator-(const LLVM2ICEGlobalsConverter &) = delete;
637 641
638 public: 642 public:
639 LLVM2ICEGlobalsConverter(Ice::GlobalContext *Ctx, LLVMContext &LLVMContext) 643 LLVM2ICEGlobalsConverter(Ice::Converter &Converter)
640 : LLVM2ICEConverter(Ctx, LLVMContext) {} 644 : LLVM2ICEConverter(Converter) {}
641
642 ~LLVM2ICEGlobalsConverter() { DeleteContainerSeconds(GlobalVarAddressMap); }
643 645
644 /// Converts global variables, and their initializers into ICE global 646 /// Converts global variables, and their initializers into ICE global
645 /// addresses, for module Mod. Puts corresponding converted global 647 /// addresses, for module Mod. Puts corresponding converted global
646 /// addresses into GlobalAddresses. 648 /// addresses into GlobalVariables.
647 void convertGlobalsToIce(Module *Mod, 649 void
648 Ice::Translator::GlobalAddressList &GlobalAddresses); 650 convertGlobalsToIce(Module *Mod,
651 Ice::Translator::GlobalVariableListType &GlobalVariables);
649 652
650 private: 653 private:
651 typedef std::map<const GlobalVariable *, Ice::GlobalAddress *>
652 GlobalVarAddressMapType;
653 // Map from global variables to their corresponding global address.
654 GlobalVarAddressMapType GlobalVarAddressMap;
655
656 // Adds the Initializer to the list of initializers for Global address. 654 // Adds the Initializer to the list of initializers for Global address.
657 void addGlobalInitializer(Ice::GlobalAddress &Global, 655 void addGlobalInitializer(Ice::GlobalVariable &Global,
658 const Constant *Initializer) { 656 const Constant *Initializer) {
659 const bool HasOffset = false; 657 const bool HasOffset = false;
660 const Ice::GlobalAddress::RelocOffsetType Offset = 0; 658 const Ice::GlobalVariable::RelocOffsetType Offset = 0;
661 addGlobalInitializer(Global, Initializer, HasOffset, Offset); 659 addGlobalInitializer(Global, Initializer, HasOffset, Offset);
662 } 660 }
663 661
664 // Adds Initializer to the list of initializers for Global 662 // Adds Initializer to the list of initializers for Global
665 // address. HasOffset is true only if Initializer is a relocation 663 // address. HasOffset is true only if Initializer is a relocation
666 // initializer and Offset should be added to the relocation. 664 // initializer and Offset should be added to the relocation.
667 void addGlobalInitializer(Ice::GlobalAddress &Global, 665 void addGlobalInitializer(Ice::GlobalVariable &Global,
668 const Constant *Initializer, bool HasOffset, 666 const Constant *Initializer, bool HasOffset,
669 Ice::GlobalAddress::RelocOffsetType Offset); 667 Ice::GlobalVariable::RelocOffsetType Offset);
670
671 // Returns the global address associated with global variable GV.
672 Ice::GlobalAddress *getGlobalVarAddress(const GlobalVariable *GV) {
673 if (GlobalVarAddressMap.find(GV) == GlobalVarAddressMap.end())
674 GlobalVarAddressMap[GV] = new Ice::GlobalAddress();
675 return GlobalVarAddressMap[GV];
676 }
677 668
678 // Converts the given constant C to the corresponding integer 669 // Converts the given constant C to the corresponding integer
679 // literal it contains. 670 // literal it contains.
680 Ice::GlobalAddress::RelocOffsetType 671 Ice::GlobalVariable::RelocOffsetType
681 getIntegerLiteralConstant(const Value *C) { 672 getIntegerLiteralConstant(const Value *C) {
682 const auto CI = dyn_cast<ConstantInt>(C); 673 const auto CI = dyn_cast<ConstantInt>(C);
683 if (CI && CI->getType()->isIntegerTy(32)) 674 if (CI && CI->getType()->isIntegerTy(32))
684 return CI->getSExtValue(); 675 return CI->getSExtValue();
685 676
686 std::string Buffer; 677 std::string Buffer;
687 raw_string_ostream StrBuf(Buffer); 678 raw_string_ostream StrBuf(Buffer);
688 StrBuf << "Constant not i32 literal: " << *C; 679 StrBuf << "Constant not i32 literal: " << *C;
689 report_fatal_error(StrBuf.str()); 680 report_fatal_error(StrBuf.str());
690 return 0; 681 return 0;
691 } 682 }
692 }; 683 };
693 684
694 void LLVM2ICEGlobalsConverter::convertGlobalsToIce( 685 void LLVM2ICEGlobalsConverter::convertGlobalsToIce(
695 Module *Mod, Ice::Translator::GlobalAddressList &GlobalAddresses) { 686 Module *Mod, Ice::Translator::GlobalVariableListType &GlobalVariables) {
696 for (Module::const_global_iterator I = Mod->global_begin(), 687 for (Module::const_global_iterator I = Mod->global_begin(),
697 E = Mod->global_end(); 688 E = Mod->global_end();
698 I != E; ++I) { 689 I != E; ++I) {
699 if (!I->hasInitializer() && Ctx->getFlags().AllowUninitializedGlobals) 690 if (!I->hasInitializer() && Ctx->getFlags().AllowUninitializedGlobals)
700 continue; 691 continue;
701 692
702 const auto GV = dyn_cast<GlobalVariable>(I); 693 const auto GV = dyn_cast<GlobalVariable>(I);
jvoung (off chromium) 2014/10/10 01:47:28 cast<> is a checked cast and would help assert(GV)
Karl 2014/10/10 20:17:30 Ok. Changing to cast and removing assert.
703 assert(GV); 694 assert(GV);
704 Ice::IceString Name = GV->getName(); 695 Ice::IceString Name = GV->getName();
705 if (!GV->hasInternalLinkage()) { 696 if (!GV->hasInternalLinkage()) {
706 std::string Buffer; 697 std::string Buffer;
707 raw_string_ostream StrBuf(Buffer); 698 raw_string_ostream StrBuf(Buffer);
708 StrBuf << "Can't define external global address: " << Name; 699 StrBuf << "Can't define external global address: " << Name;
709 report_fatal_error(StrBuf.str()); 700 report_fatal_error(StrBuf.str());
710 } 701 }
711 702
712 Ice::GlobalAddress *Addr = getGlobalVarAddress(GV); 703 Ice::GlobalAddress *Addr = getConverter().getGlobalAddress(GV);
713 GlobalAddresses.push_back(Addr); 704 assert(llvm::isa<Ice::GlobalVariable>(Addr));
jvoung (off chromium) 2014/10/10 01:47:28 sometimes llvm:: is used, but sometimes not?
Karl 2014/10/10 20:17:29 Assuming we should always use on GlobalVariable, s
714 Addr->setAlignment(GV->getAlignment()); 705 auto VarAddr = llvm::cast<Ice::GlobalVariable>(Addr);
jvoung (off chromium) 2014/10/10 01:47:28 cast<> already asserts isa<>, so the earlier asser
Karl 2014/10/10 20:17:30 Removing redundancy.
715 Addr->setIsConstant(GV->isConstant()); 706 GlobalVariables.push_back(VarAddr);
716 // Note: We allow external for cross tests.
717 Addr->setIsInternal(!GV->isExternallyInitialized());
718 Addr->setName(Name);
719 707
720 const Constant *Initializer = GV->getInitializer(); 708 const Constant *Initializer = GV->getInitializer();
721 if (const auto CompoundInit = dyn_cast<ConstantStruct>(Initializer)) { 709 if (const auto CompoundInit = dyn_cast<ConstantStruct>(Initializer)) {
722 for (ConstantStruct::const_op_iterator I = CompoundInit->op_begin(), 710 for (ConstantStruct::const_op_iterator I = CompoundInit->op_begin(),
723 E = CompoundInit->op_end(); 711 E = CompoundInit->op_end();
724 I != E; ++I) { 712 I != E; ++I) {
725 if (const auto Init = dyn_cast<Constant>(I)) { 713 if (const auto Init = dyn_cast<Constant>(I)) {
726 addGlobalInitializer(*Addr, Init); 714 addGlobalInitializer(*VarAddr, Init);
727 } 715 }
728 } 716 }
729 } else { 717 } else {
730 addGlobalInitializer(*Addr, Initializer); 718 addGlobalInitializer(*VarAddr, Initializer);
731 } 719 }
732 } 720 }
733 } 721 }
734 722
735 void LLVM2ICEGlobalsConverter::addGlobalInitializer( 723 void LLVM2ICEGlobalsConverter::addGlobalInitializer(
736 Ice::GlobalAddress &Global, const Constant *Initializer, bool HasOffset, 724 Ice::GlobalVariable &Global, const Constant *Initializer, bool HasOffset,
737 Ice::GlobalAddress::RelocOffsetType Offset) { 725 Ice::GlobalVariable::RelocOffsetType Offset) {
738 assert(HasOffset || Offset == 0); 726 assert(HasOffset || Offset == 0);
739 727
740 if (const auto CDA = dyn_cast<ConstantDataArray>(Initializer)) { 728 if (const auto CDA = dyn_cast<ConstantDataArray>(Initializer)) {
741 assert(!HasOffset && isa<IntegerType>(CDA->getElementType()) && 729 assert(!HasOffset && isa<IntegerType>(CDA->getElementType()) &&
742 (cast<IntegerType>(CDA->getElementType())->getBitWidth() == 8)); 730 (cast<IntegerType>(CDA->getElementType())->getBitWidth() == 8));
743 Global.addInitializer(new Ice::GlobalAddress::DataInitializer( 731 Global.addInitializer(new Ice::GlobalVariable::DataInitializer(
744 CDA->getRawDataValues().data(), CDA->getNumElements())); 732 CDA->getRawDataValues().data(), CDA->getNumElements()));
745 return; 733 return;
746 } 734 }
747 735
748 if (isa<ConstantAggregateZero>(Initializer)) { 736 if (isa<ConstantAggregateZero>(Initializer)) {
749 if (const auto AT = dyn_cast<ArrayType>(Initializer->getType())) { 737 if (const auto AT = dyn_cast<ArrayType>(Initializer->getType())) {
750 assert(!HasOffset && isa<IntegerType>(AT->getElementType()) && 738 assert(!HasOffset && isa<IntegerType>(AT->getElementType()) &&
751 (cast<IntegerType>(AT->getElementType())->getBitWidth() == 8)); 739 (cast<IntegerType>(AT->getElementType())->getBitWidth() == 8));
752 Global.addInitializer( 740 Global.addInitializer(
753 new Ice::GlobalAddress::ZeroInitializer(AT->getNumElements())); 741 new Ice::GlobalVariable::ZeroInitializer(AT->getNumElements()));
754 } else { 742 } else {
755 llvm_unreachable("Unhandled constant aggregate zero type"); 743 llvm_unreachable("Unhandled constant aggregate zero type");
756 } 744 }
757 return; 745 return;
758 } 746 }
759 747
760 if (const auto Exp = dyn_cast<ConstantExpr>(Initializer)) { 748 if (const auto Exp = dyn_cast<ConstantExpr>(Initializer)) {
761 switch (Exp->getOpcode()) { 749 switch (Exp->getOpcode()) {
762 case Instruction::Add: 750 case Instruction::Add:
763 assert(!HasOffset); 751 assert(!HasOffset);
764 addGlobalInitializer(Global, Exp->getOperand(0), true, 752 addGlobalInitializer(Global, Exp->getOperand(0), true,
765 getIntegerLiteralConstant(Exp->getOperand(1))); 753 getIntegerLiteralConstant(Exp->getOperand(1)));
766 return; 754 return;
767 case Instruction::PtrToInt: { 755 case Instruction::PtrToInt: {
768 assert(TypeConverter.convertToIceType(Exp->getType()) == 756 assert(TypeConverter.convertToIceType(Exp->getType()) ==
769 TypeConverter.getIcePointerType()); 757 TypeConverter.getIcePointerType());
770 const auto GV = dyn_cast<GlobalValue>(Exp->getOperand(0)); 758 const auto GV = dyn_cast<GlobalValue>(Exp->getOperand(0));
771 assert(GV); 759 assert(GV);
772 if (const auto Fcn = dyn_cast<Function>(GV)) { 760 const Ice::GlobalAddress *Addr = getConverter().getGlobalAddress(GV);
773 Ice::GlobalAddress::RelocationAddress Addr(Fcn); 761 if (Addr == NULL) {
jvoung (off chromium) 2014/10/10 01:47:28 nullptr
Karl 2014/10/10 20:17:30 Replaced all occurrences.
774 Global.addInitializer( 762 std::string Buffer;
775 new Ice::GlobalAddress::RelocInitializer(Addr, Offset)); 763 raw_string_ostream StrBuf(Buffer);
776 return; 764 StrBuf << "Can't find global address for: " << GV;
777 } else if (const auto Var = dyn_cast<GlobalVariable>(GV)) { 765 report_fatal_error(StrBuf.str());
778 Ice::GlobalAddress::RelocationAddress Addr(getGlobalVarAddress(Var));
779 Global.addInitializer(
780 new Ice::GlobalAddress::RelocInitializer(Addr, Offset));
781 return; 766 return;
782 } 767 }
783 break; 768 Global.addInitializer(
769 new Ice::GlobalVariable::RelocInitializer(Addr, Offset));
770 return;
784 } 771 }
785 default: 772 default:
786 break; 773 break;
787 } 774 }
788 } 775 }
789 776
790 std::string Buffer; 777 std::string Buffer;
791 raw_string_ostream StrBuf(Buffer); 778 raw_string_ostream StrBuf(Buffer);
792 StrBuf << "Unhandled global initializer: " << Initializer; 779 StrBuf << "Unhandled global initializer: " << Initializer;
793 report_fatal_error(StrBuf.str()); 780 report_fatal_error(StrBuf.str());
794 } 781 }
795 782
796 } // end of anonymous namespace 783 } // end of anonymous namespace
797 784
798 namespace Ice { 785 namespace Ice {
799 786
800 void Converter::convertToIce() { 787 void Converter::convertToIce() {
801 TimerMarker T(TimerStack::TT_convertToIce, Ctx); 788 TimerMarker T(TimerStack::TT_convertToIce, Ctx);
802 nameUnnamedGlobalAddresses(Mod); 789 nameUnnamedGlobalVariables(Mod);
803 nameUnnamedFunctions(Mod); 790 nameUnnamedFunctions(Mod);
791 installGlobalAddresses(Mod);
804 convertGlobals(Mod); 792 convertGlobals(Mod);
805 convertFunctions(); 793 convertFunctions();
806 } 794 }
807 795
796 GlobalAddress *Converter::getGlobalAddress(const llvm::GlobalValue *V) {
797 GlobalAddressMapType::const_iterator Pos = GlobalAddressMap.find(V);
798 if (Pos == GlobalAddressMap.end())
799 return nullptr;
800 return Pos->second;
801 }
802
803 void Converter::installGlobalAddresses(Module *Mod) {
804 const TypeConverter Converter(Mod->getContext());
805 // Install function addresses.
806 for (llvm::Function &Func : *Mod) {
jvoung (off chromium) 2014/10/10 01:47:28 could this be const ?
Karl 2014/10/10 20:17:29 Done.
807 FuncSigType Signature;
808 llvm::FunctionType *FuncType = Func.getFunctionType();
809 Signature.setReturnType(
810 Converter.convertToIceType(FuncType->getReturnType()));
811 for (size_t I = 0; I < FuncType->getNumParams(); ++I) {
812 Signature.appendArgType(
813 Converter.convertToIceType(FuncType->getParamType(I)));
814 }
815 Ice::Function *IceFunc = Ice::Function::create(
816 Ctx, Signature, Func.getCallingConv(), Func.getLinkage(), Func.empty());
817 IceFunc->setName(Func.getName());
818 GlobalAddressMap[&Func] = IceFunc;
819 }
820 // Install global variable addresses.
821 for (Module::const_global_iterator I = Mod->global_begin(),
822 E = Mod->global_end();
823 I != E; ++I) {
824 const auto GV = dyn_cast<llvm::GlobalVariable>(I);
jvoung (off chromium) 2014/10/10 01:47:28 could just cast<> to assert that GV is really a Gl
jvoung (off chromium) 2014/10/10 01:47:28 In some places plain "GlobalVariable" is used for
Karl 2014/10/10 20:17:30 Fixed use of cast. Using explicit namespace prefix
825 assert(GV);
826 Ice::GlobalVariable *Vbl = Ice::GlobalVariable::create(Ctx);
827 Vbl->setName(GV->getName());
828 Vbl->setAlignment(GV->getAlignment());
829 Vbl->setIsConstant(GV->isConstant());
830 // Note: We allow external for cross tests.
831 Vbl->setIsInternal(!GV->isExternallyInitialized());
jvoung (off chromium) 2014/10/10 01:47:27 Was there a commandline flag to check?
Karl 2014/10/10 20:17:30 Yes. Will do in a separate CL, since many lit tes
832 GlobalAddressMap[GV] = Vbl;
833 }
834 }
835
808 void Converter::convertGlobals(Module *Mod) { 836 void Converter::convertGlobals(Module *Mod) {
809 LLVM2ICEGlobalsConverter GlobalsConverter(Ctx, Mod->getContext()); 837 LLVM2ICEGlobalsConverter GlobalsConverter(*this);
810 Translator::GlobalAddressList GlobalAddresses; 838 Translator::GlobalVariableListType GlobalVariables;
811 GlobalsConverter.convertGlobalsToIce(Mod, GlobalAddresses); 839 GlobalsConverter.convertGlobalsToIce(Mod, GlobalVariables);
812 lowerGlobals(GlobalAddresses); 840 lowerGlobals(GlobalVariables);
813 } 841 }
814 842
815 void Converter::convertFunctions() { 843 void Converter::convertFunctions() {
816 TimerStackIdT StackID = GlobalContext::TSK_Funcs; 844 TimerStackIdT StackID = GlobalContext::TSK_Funcs;
817 for (const Function &I : *Mod) { 845 for (const llvm::Function &I : *Mod) {
818 if (I.empty()) 846 if (I.empty())
819 continue; 847 continue;
820 848
821 TimerIdT TimerID = 0; 849 TimerIdT TimerID = 0;
822 if (Ctx->getFlags().TimeEachFunction) { 850 if (Ctx->getFlags().TimeEachFunction) {
823 TimerID = Ctx->getTimerID(StackID, I.getName()); 851 TimerID = Ctx->getTimerID(StackID, I.getName());
824 Ctx->pushTimer(TimerID, StackID); 852 Ctx->pushTimer(TimerID, StackID);
825 } 853 }
826 LLVM2ICEFunctionConverter FunctionConverter(Ctx, Mod->getContext()); 854 LLVM2ICEFunctionConverter FunctionConverter(*this);
827 855
828 Cfg *Fcn = FunctionConverter.convertFunction(&I); 856 Cfg *Fcn = FunctionConverter.convertFunction(&I);
829 translateFcn(Fcn); 857 translateFcn(Fcn);
830 if (Ctx->getFlags().TimeEachFunction) 858 if (Ctx->getFlags().TimeEachFunction)
831 Ctx->popTimer(TimerID, StackID); 859 Ctx->popTimer(TimerID, StackID);
832 } 860 }
833 861
834 emitConstants(); 862 emitConstants();
835 } 863 }
836 864
837 } // end of namespace Ice 865 } // end of namespace Ice
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698