summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Metadata.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-09-14 01:37:57 +0000
committerDan Gohman <gohman@apple.com>2010-09-14 01:37:57 +0000
commite1328dc0e958f8190492fc9c870ced6e1441bf01 (patch)
tree3462c4737c329a795761e8209f9862a271c29331 /llvm/lib/VMCore/Metadata.cpp
parent6d87fab8a4f84fc3d4d8b050bd81071670bbb176 (diff)
downloadbcm5719-llvm-e1328dc0e958f8190492fc9c870ced6e1441bf01.tar.gz
bcm5719-llvm-e1328dc0e958f8190492fc9c870ced6e1441bf01.zip
When a function-local value with function-local metadata uses gets RAUWed with a
non-function-local value, it may result in the metadata no longer needing to be function-local. Check for this condition, and clear the isFunctionLocal flag, if it's still in the uniquing map, since any node in the uniquing map needs to have an accurate function-local flag. Also, add an assert to help catch problematic cases. llvm-svn: 113828
Diffstat (limited to 'llvm/lib/VMCore/Metadata.cpp')
-rw-r--r--llvm/lib/VMCore/Metadata.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Metadata.cpp b/llvm/lib/VMCore/Metadata.cpp
index b9f97dbf603..da69c43ff73 100644
--- a/llvm/lib/VMCore/Metadata.cpp
+++ b/llvm/lib/VMCore/Metadata.cpp
@@ -354,6 +354,22 @@ void MDNode::replaceOperand(MDNodeOperand *Op, Value *To) {
// InsertPoint will have been set by the FindNodeOrInsertPos call.
pImpl->MDNodeSet.InsertNode(this, InsertPoint);
+
+ // If this MDValue was previously function-local but no longer is, clear
+ // its function-local flag.
+ if (isFunctionLocal() && !isFunctionLocalValue(To)) {
+ bool isStillFunctionLocal = false;
+ for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
+ Value *V = getOperand(i);
+ if (!V) continue;
+ if (isFunctionLocalValue(V)) {
+ isStillFunctionLocal = true;
+ break;
+ }
+ }
+ if (!isStillFunctionLocal)
+ setValueSubclassData(getSubclassDataFromValue() & ~FunctionLocalBit);
+ }
}
//===----------------------------------------------------------------------===//
@@ -387,6 +403,8 @@ MDNode *NamedMDNode::getOperand(unsigned i) const {
/// addOperand - Add metadata Operand.
void NamedMDNode::addOperand(MDNode *M) {
+ assert(!M->isFunctionLocal() &&
+ "NamedMDNode operands must not be function-local!");
getNMDOps(Operands).push_back(TrackingVH<MDNode>(M));
}
OpenPOWER on IntegriCloud