diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-10-31 20:13:11 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-10-31 20:13:11 +0000 |
commit | e5d641ebcafc3586f4981bc3a04f01b7f6b6acb8 (patch) | |
tree | 27c75754599acef3e3f16260aac1f4e9d27ca501 | |
parent | 0c0b6d9ac6b37724807f1cf0c0c05b1bba3c3b48 (diff) | |
download | bcm5719-llvm-e5d641ebcafc3586f4981bc3a04f01b7f6b6acb8.tar.gz bcm5719-llvm-e5d641ebcafc3586f4981bc3a04f01b7f6b6acb8.zip |
IR: MDNode => Value: Instruction::setMetadata()
Change `Instruction::setMetadata()` API to accept `Value` instead of
`MDNode`. Part of PR21433.
llvm-svn: 220994
-rw-r--r-- | llvm/include/llvm/IR/IRBuilder.h | 2 | ||||
-rw-r--r-- | llvm/include/llvm/IR/Instruction.h | 6 | ||||
-rw-r--r-- | llvm/lib/IR/Metadata.cpp | 15 |
3 files changed, 13 insertions, 10 deletions
diff --git a/llvm/include/llvm/IR/IRBuilder.h b/llvm/include/llvm/IR/IRBuilder.h index d803bf407e6..35dda0b9aa0 100644 --- a/llvm/include/llvm/IR/IRBuilder.h +++ b/llvm/include/llvm/IR/IRBuilder.h @@ -23,12 +23,12 @@ #include "llvm/IR/DataLayout.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Metadata.h" #include "llvm/IR/Operator.h" #include "llvm/IR/ValueHandle.h" #include "llvm/Support/CBindingWrapping.h" namespace llvm { - class MDNode; /// \brief This provides the default implementation of the IRBuilder /// 'InsertHelper' method that is called whenever an instruction is created by diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h index 4a713ef7df1..4baacba78ed 100644 --- a/llvm/include/llvm/IR/Instruction.h +++ b/llvm/include/llvm/IR/Instruction.h @@ -176,9 +176,9 @@ public: /// setMetadata - Set the metadata of the specified kind to the specified /// node. This updates/replaces metadata if already present, or removes it if - /// Node is null. - void setMetadata(unsigned KindID, MDNode *Node); - void setMetadata(StringRef Kind, MDNode *Node); + /// MD is null. + void setMetadata(unsigned KindID, Value *MD); + void setMetadata(StringRef Kind, Value *MD); /// \brief Drop unknown metadata. /// Passes are required to drop metadata they don't understand. This is a diff --git a/llvm/lib/IR/Metadata.cpp b/llvm/lib/IR/Metadata.cpp index cc118496033..24c78fea646 100644 --- a/llvm/lib/IR/Metadata.cpp +++ b/llvm/lib/IR/Metadata.cpp @@ -600,9 +600,9 @@ StringRef NamedMDNode::getName() const { // Instruction Metadata method implementations. // -void Instruction::setMetadata(StringRef Kind, MDNode *Node) { - if (!Node && !hasMetadata()) return; - setMetadata(getContext().getMDKindID(Kind), Node); +void Instruction::setMetadata(StringRef Kind, Value *MD) { + if (!MD && !hasMetadata()) return; + setMetadata(getContext().getMDKindID(Kind), MD); } MDNode *Instruction::getMetadataImpl(StringRef Kind) const { @@ -655,9 +655,12 @@ void Instruction::dropUnknownMetadata(ArrayRef<unsigned> KnownIDs) { /// setMetadata - Set the metadata of of the specified kind to the specified /// node. This updates/replaces metadata if already present, or removes it if -/// Node is null. -void Instruction::setMetadata(unsigned KindID, MDNode *Node) { - if (!Node && !hasMetadata()) return; +/// MD is null. +void Instruction::setMetadata(unsigned KindID, Value *MD) { + if (!MD && !hasMetadata()) return; + + // For now, we only expect MDNodes here. + MDNode *Node = cast<MDNode>(MD); // Handle 'dbg' as a special case since it is not stored in the hash table. if (KindID == LLVMContext::MD_dbg) { |