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

Function interpretLLVMIR

libchigraph/src/Context.cpp:746–780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

744} // anonymous namespace
745
746Result interpretLLVMIR(std::unique_ptr<llvm::Module> mod, llvm::CodeGenOpt::Level optLevel,
747 std::vector<llvm::GenericValue> args, llvm::Function* funcToRun,
748 llvm::GenericValue* ret) {
749 assert(mod);
750
751 Result res;
752
753 if (funcToRun == nullptr) {
754 funcToRun = mod->getFunction("main");
755
756 if (funcToRun == nullptr) {
757 res.addEntry("EUKN", "Failed to find main function in module",
758 {{"Module Name", mod->getModuleIdentifier()}});
759 return res;
760 }
761 }
762
763 std::string errMsg;
764 auto EE = createEE(std::move(mod), optLevel, errMsg);
765 EE->finalizeObject();
766 EE->runStaticConstructorsDestructors(false);
767
768 if (!EE) {
769 res.addEntry("EINT", "Failed to create an LLVM ExecutionEngine", {{"Error", errMsg}});
770 return res;
771 }
772
773 auto returnValue = EE->runFunction(funcToRun, args);
774
775 EE->runStaticConstructorsDestructors(true);
776
777 if (ret != nullptr) { *ret = returnValue; }
778
779 return res;
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) {

Callers

nothing calls this directly

Calls 2

createEEFunction · 0.85
addEntryMethod · 0.80

Tested by

no test coverage detected