本文整理汇总了C++中module::iterator::isMaterializable方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::isMaterializable方法的具体用法?C++ iterator::isMaterializable怎么用?C++ iterator::isMaterializable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module::iterator
的用法示例。
在下文中一共展示了iterator::isMaterializable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runCompilePasses
//.........这里部分代码省略.........
std::unique_ptr<legacy::PassManagerBase> PM;
if (LazyBitcode)
PM.reset(new legacy::FunctionPassManager(ModuleRef));
else
PM.reset(new legacy::PassManager());
// Add the target data from the target machine, if it exists, or the module.
if (const DataLayout *DL = Target.getDataLayout())
ModuleRef->setDataLayout(*DL);
// For conformance with llc, we let the user disable LLVM IR verification with
// -disable-verify. Unlike llc, when LLVM IR verification is enabled we only
// run it once, before PNaCl ABI verification.
if (!NoVerify)
PM->add(createVerifierPass());
// Add the ABI verifier pass before the analysis and code emission passes.
if (PNaClABIVerify)
PM->add(createPNaClABIVerifyFunctionsPass(&ABIErrorReporter));
// Add the intrinsic resolution pass. It assumes ABI-conformant code.
PM->add(createResolvePNaClIntrinsicsPass());
// Add an appropriate TargetLibraryInfo pass for the module's triple.
TargetLibraryInfoImpl TLII(TheTriple);
// The -disable-simplify-libcalls flag actually disables all builtin optzns.
if (DisableSimplifyLibCalls)
TLII.disableAllFunctions();
PM->add(new TargetLibraryInfoWrapperPass(TLII));
// Allow subsequent passes and the backend to better optimize instructions
// that were simplified for PNaCl's ABI. This pass uses the TargetLibraryInfo
// above.
PM->add(createBackendCanonicalizePass());
// Ask the target to add backend passes as necessary. We explicitly ask it
// not to add the verifier pass because we added it earlier.
if (Target.addPassesToEmitFile(*PM, OS, FileType,
/* DisableVerify */ true)) {
errs() << ProgramName
<< ": target does not support generation of this file type!\n";
return 1;
}
if (LazyBitcode) {
auto FPM = static_cast<legacy::FunctionPassManager *>(PM.get());
FPM->doInitialization();
unsigned FuncIndex = 0;
switch (SplitModuleSched) {
case SplitModuleStatic:
for (Function &F : *ModuleRef) {
if (FuncQueue->GrabFunctionStatic(FuncIndex, ModuleIndex)) {
FPM->run(F);
CheckABIVerifyErrors(ABIErrorReporter, "Function " + F.getName());
F.Dematerialize();
}
++FuncIndex;
}
break;
case SplitModuleDynamic:
unsigned ChunkSize = 0;
unsigned NumFunctions = FuncQueue->Size();
Module::iterator I = ModuleRef->begin();
while (FuncIndex < NumFunctions) {
ChunkSize = FuncQueue->RecommendedChunkSize();
unsigned NextIndex;
bool grabbed = FuncQueue->GrabFunctionDynamic(FuncIndex, ChunkSize,
NextIndex);
if (grabbed) {
while (FuncIndex < NextIndex) {
if (!I->isMaterializable() && I->isDeclaration()) {
++I;
continue;
}
FPM->run(*I);
CheckABIVerifyErrors(ABIErrorReporter, "Function " + I->getName());
I->Dematerialize();
++FuncIndex;
++I;
}
} else {
while (FuncIndex < NextIndex) {
if (!I->isMaterializable() && I->isDeclaration()) {
++I;
continue;
}
++FuncIndex;
++I;
}
}
}
break;
}
FPM->doFinalization();
} else
static_cast<legacy::PassManager *>(PM.get())->run(*ModuleRef);
return 0;
}
示例2: run
bool ModuleLinker::run() {
assert(DstM && "Null destination module");
assert(SrcM && "Null source module");
// Inherit the target data from the source module if the destination module
// doesn't have one already.
if (DstM->getDataLayout().empty() && !SrcM->getDataLayout().empty())
DstM->setDataLayout(SrcM->getDataLayout());
// Copy the target triple from the source to dest if the dest's is empty.
if (DstM->getTargetTriple().empty() && !SrcM->getTargetTriple().empty())
DstM->setTargetTriple(SrcM->getTargetTriple());
if (!SrcM->getDataLayout().empty() && !DstM->getDataLayout().empty() &&
SrcM->getDataLayout() != DstM->getDataLayout())
errs() << "WARNING: Linking two modules of different data layouts!\n";
if (!SrcM->getTargetTriple().empty() &&
DstM->getTargetTriple() != SrcM->getTargetTriple()) {
errs() << "WARNING: Linking two modules of different target triples: ";
if (!SrcM->getModuleIdentifier().empty())
errs() << SrcM->getModuleIdentifier() << ": ";
errs() << "'" << SrcM->getTargetTriple() << "' and '"
<< DstM->getTargetTriple() << "'\n";
}
// Append the module inline asm string.
if (!SrcM->getModuleInlineAsm().empty()) {
if (DstM->getModuleInlineAsm().empty())
DstM->setModuleInlineAsm(SrcM->getModuleInlineAsm());
else
DstM->setModuleInlineAsm(DstM->getModuleInlineAsm()+"\n"+
SrcM->getModuleInlineAsm());
}
// Update the destination module's dependent libraries list with the libraries
// from the source module. There's no opportunity for duplicates here as the
// Module ensures that duplicate insertions are discarded.
for (Module::lib_iterator SI = SrcM->lib_begin(), SE = SrcM->lib_end();
SI != SE; ++SI)
DstM->addLibrary(*SI);
// If the source library's module id is in the dependent library list of the
// destination library, remove it since that module is now linked in.
StringRef ModuleId = SrcM->getModuleIdentifier();
if (!ModuleId.empty())
DstM->removeLibrary(sys::path::stem(ModuleId));
// Loop over all of the linked values to compute type mappings.
computeTypeMapping();
// Insert all of the globals in src into the DstM module... without linking
// initializers (which could refer to functions not yet mapped over).
for (Module::global_iterator I = SrcM->global_begin(),
E = SrcM->global_end(); I != E; ++I)
if (linkGlobalProto(I))
return true;
// Link the functions together between the two modules, without doing function
// bodies... this just adds external function prototypes to the DstM
// function... We do this so that when we begin processing function bodies,
// all of the global values that may be referenced are available in our
// ValueMap.
for (Module::iterator I = SrcM->begin(), E = SrcM->end(); I != E; ++I)
if (linkFunctionProto(I))
return true;
// If there were any aliases, link them now.
for (Module::alias_iterator I = SrcM->alias_begin(),
E = SrcM->alias_end(); I != E; ++I)
if (linkAliasProto(I))
return true;
for (unsigned i = 0, e = AppendingVars.size(); i != e; ++i)
linkAppendingVarInit(AppendingVars[i]);
// Update the initializers in the DstM module now that all globals that may
// be referenced are in DstM.
linkGlobalInits();
// Link in the function bodies that are defined in the source module into
// DstM.
for (Module::iterator SF = SrcM->begin(), E = SrcM->end(); SF != E; ++SF) {
// Skip if not linking from source.
if (DoNotLinkFromSource.count(SF)) continue;
// Skip if no body (function is external) or materialize.
if (SF->isDeclaration()) {
if (!SF->isMaterializable())
continue;
if (SF->Materialize(&ErrorMsg))
return true;
}
linkFunctionBody(cast<Function>(ValueMap[SF]), SF);
}
// Resolve all uses of aliases with aliasees.
linkAliasBodies();
// Remap all of the named MDNodes in Src into the DstM module. We do this
//.........这里部分代码省略.........