summaryrefslogtreecommitdiff
path: root/lib/VMCore/Metadata.cpp
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2010-05-04 14:25:42 +0000
committerDuncan Sands <baldrick@free.fr>2010-05-04 14:25:42 +0000
commitd29f5282e06a395e696130d57aa3b1e0c73a60d4 (patch)
tree1ce83ccca34ed1cd4914c584ab63f8ba995bccb1 /lib/VMCore/Metadata.cpp
parent203f7cb68b6c509b388d1662d8439693f75bb964 (diff)
downloadllvm-d29f5282e06a395e696130d57aa3b1e0c73a60d4.tar.gz
llvm-d29f5282e06a395e696130d57aa3b1e0c73a60d4.tar.bz2
llvm-d29f5282e06a395e696130d57aa3b1e0c73a60d4.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103008 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Metadata.cpp')
-rw-r--r--lib/VMCore/Metadata.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/VMCore/Metadata.cpp b/lib/VMCore/Metadata.cpp
index 73376f5a6b..b894ea30aa 100644
--- a/lib/VMCore/Metadata.cpp
+++ b/lib/VMCore/Metadata.cpp
@@ -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;
}