summaryrefslogtreecommitdiff
path: root/lib/VMCore/Instruction.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-28 23:41:32 +0000
committerChris Lattner <sabre@nondot.org>2009-12-28 23:41:32 +0000
commit3990b121cf4a0b280ed3e54cf13870cbf4259e78 (patch)
tree9d5ea8aa8a5f0b166334346e372f143b832b9d03 /lib/VMCore/Instruction.cpp
parentf309880ad86114cda05037538c46123f6cda1a7e (diff)
downloadllvm-3990b121cf4a0b280ed3e54cf13870cbf4259e78.tar.gz
llvm-3990b121cf4a0b280ed3e54cf13870cbf4259e78.tar.bz2
llvm-3990b121cf4a0b280ed3e54cf13870cbf4259e78.tar.xz
This is a major cleanup of the instruction metadata interfaces that
I asked Devang to do back on Sep 27. Instead of going through the MetadataContext class with methods like getMD() and getMDs(), just ask the instruction directly for its metadata with getMetadata() and getAllMetadata(). This includes a variety of other fixes and improvements: previously all Value*'s were bloated because the HasMetadata bit was thrown into value, adding a 9th bit to a byte. Now this is properly sunk down to the Instruction class (the only place where it makes sense) and it will be folded away somewhere soon. This also fixes some confusion in getMDs and its clients about whether the returned list is indexed by the MDID or densely packed. This is now returned sorted and densely packed and the comments make this clear. This introduces a number of fixme's which I'll follow up on. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92235 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Instruction.cpp')
-rw-r--r--lib/VMCore/Instruction.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index ce253d64ce..f468c1bf3a 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -24,7 +24,8 @@ using namespace llvm;
Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
Instruction *InsertBefore)
- : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
+ : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0),
+ HasMetadata(false) {
// Make sure that we get added to a basicblock
LeakDetector::addGarbageObject(this);
@@ -38,7 +39,8 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
BasicBlock *InsertAtEnd)
- : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
+ : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0),
+ HasMetadata(false) {
// Make sure that we get added to a basicblock
LeakDetector::addGarbageObject(this);
@@ -51,10 +53,8 @@ Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
// Out of line virtual method, so the vtable, etc has a home.
Instruction::~Instruction() {
assert(Parent == 0 && "Instruction still linked in the program!");
- if (hasMetadata()) {
- LLVMContext &Context = getContext();
- Context.pImpl->TheMetadata.ValueIsDeleted(this);
- }
+ if (HasMetadata)
+ getContext().pImpl->TheMetadata.ValueIsDeleted(this);
}
@@ -464,7 +464,7 @@ bool Instruction::isSafeToSpeculativelyExecute() const {
Instruction *Instruction::clone() const {
Instruction *New = clone_impl();
New->SubclassOptionalData = SubclassOptionalData;
- if (hasMetadata())
+ if (HasMetadata)
getContext().pImpl->TheMetadata.ValueIsCloned(this, New);
return New;
}