Copy metadata when value is RAUW'd. It is debatable whether this is the right approac...
[oota-llvm.git] / lib / VMCore / Metadata.cpp
index 2f2345f55ef150f5888b069214391c96bba847bc..f3601cbdf5c97cb7b68f3f184add9270b426c286 100644 (file)
@@ -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);
+}