本文整理汇总了C++中module::iterator::Materialize方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::Materialize方法的具体用法?C++ iterator::Materialize怎么用?C++ iterator::Materialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module::iterator
的用法示例。
在下文中一共展示了iterator::Materialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
//.........这里部分代码省略.........