aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Instruction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VMCore/Instruction.cpp')
-rw-r--r--lib/VMCore/Instruction.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index 85fd0e8..a5500e6 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -11,12 +11,10 @@
//
//===----------------------------------------------------------------------===//
-#include "LLVMContextImpl.h"
+#include "llvm/Instruction.h"
#include "llvm/Type.h"
#include "llvm/Instructions.h"
-#include "llvm/Function.h"
#include "llvm/Constants.h"
-#include "llvm/GlobalVariable.h"
#include "llvm/Module.h"
#include "llvm/Support/CallSite.h"
#include "llvm/Support/LeakDetector.h"
@@ -52,7 +50,7 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
Instruction::~Instruction() {
assert(Parent == 0 && "Instruction still linked in the program!");
if (hasMetadata())
- getContext().pImpl->TheMetadata.ValueIsDeleted(this);
+ removeAllMetadata();
}
@@ -462,7 +460,14 @@ bool Instruction::isSafeToSpeculativelyExecute() const {
Instruction *Instruction::clone() const {
Instruction *New = clone_impl();
New->SubclassOptionalData = SubclassOptionalData;
- if (hasMetadata())
- getContext().pImpl->TheMetadata.ValueIsCloned(this, New);
+ if (!hasMetadata())
+ return New;
+
+ // Otherwise, enumerate and copy over metadata from the old instruction to the
+ // new one.
+ SmallVector<std::pair<unsigned, MDNode*>, 4> TheMDs;
+ getAllMetadata(TheMDs);
+ for (unsigned i = 0, e = TheMDs.size(); i != e; ++i)
+ New->setMetadata(TheMDs[i].first, TheMDs[i].second);
return New;
}