summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2009-10-13 17:00:54 +0000
committerDevang Patel <dpatel@apple.com>2009-10-13 17:00:54 +0000
commite6f26a74153ba66553e836d75f7beb7ae09b102e (patch)
tree3290aabe52b59c28cf6d2e219cabfb4692f1ede9
parentfc460554f6d115026bdb89919f8171de2b4adc18 (diff)
downloadbcm5719-llvm-e6f26a74153ba66553e836d75f7beb7ae09b102e.tar.gz
bcm5719-llvm-e6f26a74153ba66553e836d75f7beb7ae09b102e.zip
Copy metadata when value is RAUW'd. It is debatable whether this is the right approach for custom metadata data in general. However, right now the only custom data user, "dbg", expects this behavior while FE is constructing llvm IR with debug info.
llvm-svn: 83977
-rw-r--r--llvm/include/llvm/Metadata.h1
-rw-r--r--llvm/lib/VMCore/Metadata.cpp12
-rw-r--r--llvm/lib/VMCore/Value.cpp4
3 files changed, 17 insertions, 0 deletions
diff --git a/llvm/include/llvm/Metadata.h b/llvm/include/llvm/Metadata.h
index e4414817ca0..dd79ac09a2d 100644
--- a/llvm/include/llvm/Metadata.h
+++ b/llvm/include/llvm/Metadata.h
@@ -361,6 +361,7 @@ public:
void ValueIsDeleted(const Instruction *Inst) {
removeMDs(Inst);
}
+ void ValueIsRAUWd(Value *V1, Value *V2);
/// ValueIsCloned - This handler is used to update metadata store
/// when In1 is cloned to create In2.
diff --git a/llvm/lib/VMCore/Metadata.cpp b/llvm/lib/VMCore/Metadata.cpp
index 2f2345f55ef..f3601cbdf5c 100644
--- a/llvm/lib/VMCore/Metadata.cpp
+++ b/llvm/lib/VMCore/Metadata.cpp
@@ -404,3 +404,15 @@ void MetadataContext::ValueIsCloned(const Instruction *In1, Instruction *In2) {
if (MDNode *MD = dyn_cast_or_null<MDNode>(I->second))
addMD(I->first, MD, In2);
}
+
+/// ValueIsRAUWd - This handler is used when V1's all uses are replaced by
+/// V2.
+void MetadataContext::ValueIsRAUWd(Value *V1, Value *V2) {
+ Instruction *I1 = dyn_cast<Instruction>(V1);
+ Instruction *I2 = dyn_cast<Instruction>(V2);
+ if (!I1 || !I2)
+ return;
+
+ // FIXME : Give custom handlers a chance to override this.
+ ValueIsCloned(I1, I2);
+}
diff --git a/llvm/lib/VMCore/Value.cpp b/llvm/lib/VMCore/Value.cpp
index 03b0e6f172e..ba72af635cd 100644
--- a/llvm/lib/VMCore/Value.cpp
+++ b/llvm/lib/VMCore/Value.cpp
@@ -309,6 +309,10 @@ void Value::uncheckedReplaceAllUsesWith(Value *New) {
// Notify all ValueHandles (if present) that this value is going away.
if (HasValueHandle)
ValueHandleBase::ValueIsRAUWd(this, New);
+ if (HasMetadata) {
+ LLVMContext &Context = getContext();
+ Context.pImpl->TheMetadata.ValueIsRAUWd(this, New);
+ }
while (!use_empty()) {
Use &U = *UseList;
OpenPOWER on IntegriCloud