MCPcopy Create free account
hub / github.com/chigraph/chigraph / interpretLLVMIRAsMain

Function interpretLLVMIRAsMain

libchigraph/src/Context.cpp:782–815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

780}
781
782Result 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
817std::tuple<VCSType, std::string, std::string> resolveUrlFromModuleName(const boost::filesystem::path& path) {
818 // handle github

Callers 2

interpretFunction · 0.85
runFunction · 0.85

Calls 2

createEEFunction · 0.85
addEntryMethod · 0.80

Tested by

no test coverage detected