Fix a problem exposed by my previous commit and noticed by a release-asserts

buildbot: the debugging and non-debugging versions of getFunction were not
functionally equivalent: the non-debugging version wrongly assumed that if a
metadata operand was not metadata, then it had a non-null containing function.
This is not true, since the operand might be a global value, constant etc.

llvm-svn: 103008
This commit is contained in:
Duncan Sands 2010-05-04 14:25:42 +00:00
parent c2928c6ef5
commit 8815f38312
1 changed files with 3 additions and 11 deletions

View File

@ -159,17 +159,9 @@ const Function *MDNode::getFunction() const {
return assertLocalFunction(this);
#endif
if (!isFunctionLocal()) return NULL;
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
if (Value *V = getOperand(i)) {
if (MDNode *MD = dyn_cast<MDNode>(V)) {
if (const Function *F = MD->getFunction())
return F;
} else {
return getFunctionForValue(V);
}
}
}
for (unsigned i = 0, e = getNumOperands(); i != e; ++i)
if (const Function *F = getFunctionForValue(getOperand(i)))
return F;
return NULL;
}