本文整理汇总了C++中module::iterator::hasWeakLinkage方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::hasWeakLinkage方法的具体用法?C++ iterator::hasWeakLinkage怎么用?C++ iterator::hasWeakLinkage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module::iterator
的用法示例。
在下文中一共展示了iterator::hasWeakLinkage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runOnModule
bool MergeFunctions::runOnModule(Module &M) {
bool Changed = false;
std::map<unsigned long, std::vector<Function *> > FnMap;
for (Module::iterator F = M.begin(), E = M.end(); F != E; ++F) {
if (F->isDeclaration() || F->isIntrinsic())
continue;
if (!F->hasLocalLinkage() && !F->hasExternalLinkage() &&
!F->hasWeakLinkage())
continue;
if (hasAddressTaken(F))
continue;
FnMap[hash(F)].push_back(F);
}
// TODO: instead of running in a loop, we could also fold functions in callgraph
// order. Constructing the CFG probably isn't cheaper than just running in a loop.
bool LocalChanged;
do {
LocalChanged = false;
for (std::map<unsigned long, std::vector<Function *> >::iterator
I = FnMap.begin(), E = FnMap.end(); I != E; ++I) {
DOUT << "size: " << FnMap.size() << "\n";
std::vector<Function *> &FnVec = I->second;
DOUT << "hash (" << I->first << "): " << FnVec.size() << "\n";
for (int i = 0, e = FnVec.size(); i != e; ++i) {
for (int j = i + 1; j != e; ++j) {
bool isEqual = equals(FnVec[i], FnVec[j]);
DOUT << " " << FnVec[i]->getName()
<< (isEqual ? " == " : " != ")
<< FnVec[j]->getName() << "\n";
if (isEqual) {
if (fold(FnVec, i, j)) {
LocalChanged = true;
FnVec.erase(FnVec.begin() + j);
--j, --e;
}
}
}
}
}
Changed |= LocalChanged;
} while (LocalChanged);
return Changed;
}