diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2019-09-14 00:21:24 +0700 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2020-10-23 11:08:26 +0700 |
commit | 7975b8c38da2f46f8d88c14d24259af28805dbf3 (patch) | |
tree | 400cb7c6602870167c2ad607aed311afe6517c36 /llvm/lib/IR/Value.cpp | |
parent | 4437df8eedfdaa11b445c34fc3b19a1b14cb3d93 (diff) | |
download | llvm-7975b8c38da2f46f8d88c14d24259af28805dbf3.zip llvm-7975b8c38da2f46f8d88c14d24259af28805dbf3.tar.gz llvm-7975b8c38da2f46f8d88c14d24259af28805dbf3.tar.bz2 |
[IR] Merge metadata manipulation code into Value
Now there are two main classes in Value hierarchy, which support metadata,
these are Instruction and GlobalObject. They implement different APIs for
metadata manipulation, which however overlap. This change moves metadata
manipulation code into Value, so descendant classes can use this code for
their operations on metadata.
No functional changes intended.
Differential Revision: https://reviews.llvm.org/D67626
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r-- | llvm/lib/IR/Value.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index f01a639..51a84b6 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -51,9 +51,9 @@ static inline Type *checkType(Type *Ty) { } Value::Value(Type *ty, unsigned scid) - : VTy(checkType(ty)), UseList(nullptr), SubclassID(scid), - HasValueHandle(0), SubclassOptionalData(0), SubclassData(0), - NumUserOperands(0), IsUsedByMD(false), HasName(false) { + : VTy(checkType(ty)), UseList(nullptr), SubclassID(scid), HasValueHandle(0), + SubclassOptionalData(0), SubclassData(0), NumUserOperands(0), + IsUsedByMD(false), HasName(false), HasMetadata(false) { static_assert(ConstantFirstVal == 0, "!(SubclassID < ConstantFirstVal)"); // FIXME: Why isn't this in the subclass gunk?? // Note, we cannot call isa<CallInst> before the CallInst has been @@ -77,6 +77,10 @@ Value::~Value() { if (isUsedByMetadata()) ValueAsMetadata::handleDeletion(this); + // Remove associated metadata from context. + if (HasMetadata) + clearMetadata(); + #ifndef NDEBUG // Only in -g mode... // Check to make sure that there are no uses of this value that are still // around when the value is destroyed. If there are, then we have a dangling |