本文整理汇总了C++中ExecutionEngine::runStaticConstructorsDestructors方法的典型用法代码示例。如果您正苦于以下问题:C++ ExecutionEngine::runStaticConstructorsDestructors方法的具体用法?C++ ExecutionEngine::runStaticConstructorsDestructors怎么用?C++ ExecutionEngine::runStaticConstructorsDestructors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExecutionEngine
的用法示例。
在下文中一共展示了ExecutionEngine::runStaticConstructorsDestructors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
int run(unique_ptr<Module> module, Chars_const fnName, const vector<string> args) {
check(module, "no module");
Function* entryFn = module->getFunction(fnName);
check(entryFn, "Source file does not contain a function of the given name");
// Use an EngineBuilder to configure and construct an MCJIT ExecutionEngine.
#if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR <= 5
EngineBuilder builder(module.release());
builder.setUseMCJIT(true);
#else
const EngineBuilder builder(move(module));
const SectionMemoryManager mm;
builder.setMCJITMemoryManager(&mm);
#endif
string errorStr;
builder.setErrorStr(&errorStr);
builder.setEngineKind(EngineKind::JIT);
builder.setOptLevel(CodeGenOpt::None);
ExecutionEngine* engine = builder.create();
// Call 'finalizeObject' to notify the JIT that we're ready to execute the jitted code,
// then run the static constructors.
engine->finalizeObject();
engine->runStaticConstructorsDestructors(false);
// Pass the args to the jitted function, and capture the result.
const int result = engine->runFunctionAsMain(entryFn, args, nullptr);
engine->runStaticConstructorsDestructors(true); // Run the static destructors.
return result;
}