本文整理汇总了C++中module::global_iterator::getNameLen方法的典型用法代码示例。如果您正苦于以下问题:C++ global_iterator::getNameLen方法的具体用法?C++ global_iterator::getNameLen怎么用?C++ global_iterator::getNameLen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module::global_iterator
的用法示例。
在下文中一共展示了global_iterator::getNameLen方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CloneModule
/// SplitFunctionsOutOfModule - Given a module and a list of functions in the
/// module, split the functions OUT of the specified module, and place them in
/// the new module.
Module *
llvm::SplitFunctionsOutOfModule(Module *M,
const std::vector<Function*> &F,
DenseMap<const Value*, Value*> &ValueMap) {
// Make sure functions & globals are all external so that linkage
// between the two modules will work.
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
I->setLinkage(GlobalValue::ExternalLinkage);
for (Module::global_iterator I = M->global_begin(), E = M->global_end();
I != E; ++I) {
if (I->hasName() && *I->getNameStart() == '\01')
I->setName(I->getNameStart()+1, I->getNameLen()-1);
I->setLinkage(GlobalValue::ExternalLinkage);
}
DenseMap<const Value*, Value*> NewValueMap;
Module *New = CloneModule(M, NewValueMap);
// Make sure global initializers exist only in the safe module (CBE->.so)
for (Module::global_iterator I = New->global_begin(), E = New->global_end();
I != E; ++I)
I->setInitializer(0); // Delete the initializer to make it external
// Remove the Test functions from the Safe module
std::set<Function *> TestFunctions;
for (unsigned i = 0, e = F.size(); i != e; ++i) {
Function *TNOF = cast<Function>(ValueMap[F[i]]);
DEBUG(std::cerr << "Removing function ");
DEBUG(WriteAsOperand(std::cerr, TNOF, false));
DEBUG(std::cerr << "\n");
TestFunctions.insert(cast<Function>(NewValueMap[TNOF]));
DeleteFunctionBody(TNOF); // Function is now external in this module!
}
// Remove the Safe functions from the Test module
for (Module::iterator I = New->begin(), E = New->end(); I != E; ++I)
if (!TestFunctions.count(I))
DeleteFunctionBody(I);
// Make sure that there is a global ctor/dtor array in both halves of the
// module if they both have static ctor/dtor functions.
SplitStaticCtorDtor("llvm.global_ctors", M, New, NewValueMap);
SplitStaticCtorDtor("llvm.global_dtors", M, New, NewValueMap);
return New;
}