| 780 | } |
| 781 | |
| 782 | Result interpretLLVMIRAsMain(std::unique_ptr<llvm::Module> mod, llvm::CodeGenOpt::Level optLevel, |
| 783 | std::vector<std::string> args, llvm::Function* funcToRun, int* ret) { |
| 784 | assert(mod); |
| 785 | |
| 786 | Result res; |
| 787 | |
| 788 | if (funcToRun == nullptr) { |
| 789 | funcToRun = mod->getFunction("main"); |
| 790 | |
| 791 | if (funcToRun == nullptr) { |
| 792 | res.addEntry("EUKN", "Failed to find main function in module", |
| 793 | {{"Module Name", mod->getModuleIdentifier()}}); |
| 794 | return res; |
| 795 | } |
| 796 | } |
| 797 | |
| 798 | std::string errMsg; |
| 799 | auto EE = createEE(std::move(mod), optLevel, errMsg); |
| 800 | EE->finalizeObject(); |
| 801 | EE->runStaticConstructorsDestructors(false); |
| 802 | |
| 803 | if (!EE) { |
| 804 | res.addEntry("EINT", "Failed to create an LLVM ExecutionEngine", {{"Error", errMsg}}); |
| 805 | return res; |
| 806 | } |
| 807 | |
| 808 | auto returnValue = EE->runFunctionAsMain(funcToRun, args, nullptr); |
| 809 | |
| 810 | EE->runStaticConstructorsDestructors(true); |
| 811 | |
| 812 | if (ret != nullptr) { *ret = returnValue; } |
| 813 | |
| 814 | return res; |
| 815 | } |
| 816 | |
| 817 | std::tuple<VCSType, std::string, std::string> resolveUrlFromModuleName(const boost::filesystem::path& path) { |
| 818 | // handle github |