llvm.org GIT mirror llvm / 815275f
IR: MDNode => Value: Instruction::setMetadata() Change `Instruction::setMetadata()` API to accept `Value` instead of `MDNode`. Part of PR21433. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220994 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 5 years ago
3 changed file(s) with 13 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
2222 #include "llvm/IR/DataLayout.h"
2323 #include "llvm/IR/Instructions.h"
2424 #include "llvm/IR/LLVMContext.h"
25 #include "llvm/IR/Metadata.h"
2526 #include "llvm/IR/Operator.h"
2627 #include "llvm/IR/ValueHandle.h"
2728 #include "llvm/Support/CBindingWrapping.h"
2829
2930 namespace llvm {
30 class MDNode;
3131
3232 /// \brief This provides the default implementation of the IRBuilder
3333 /// 'InsertHelper' method that is called whenever an instruction is created by
175175
176176 /// setMetadata - Set the metadata of the specified kind to the specified
177177 /// node. This updates/replaces metadata if already present, or removes it if
178 /// Node is null.
179 void setMetadata(unsigned KindID, MDNode *Node);
180 void setMetadata(StringRef Kind, MDNode *Node);
178 /// MD is null.
179 void setMetadata(unsigned KindID, Value *MD);
180 void setMetadata(StringRef Kind, Value *MD);
181181
182182 /// \brief Drop unknown metadata.
183183 /// Passes are required to drop metadata they don't understand. This is a
599599 // Instruction Metadata method implementations.
600600 //
601601
602 void Instruction::setMetadata(StringRef Kind, MDNode *Node) {
603 if (!Node && !hasMetadata()) return;
604 setMetadata(getContext().getMDKindID(Kind), Node);
602 void Instruction::setMetadata(StringRef Kind, Value *MD) {
603 if (!MD && !hasMetadata()) return;
604 setMetadata(getContext().getMDKindID(Kind), MD);
605605 }
606606
607607 MDNode *Instruction::getMetadataImpl(StringRef Kind) const {
654654
655655 /// setMetadata - Set the metadata of of the specified kind to the specified
656656 /// node. This updates/replaces metadata if already present, or removes it if
657 /// Node is null.
658 void Instruction::setMetadata(unsigned KindID, MDNode *Node) {
659 if (!Node && !hasMetadata()) return;
657 /// MD is null.
658 void Instruction::setMetadata(unsigned KindID, Value *MD) {
659 if (!MD && !hasMetadata()) return;
660
661 // For now, we only expect MDNodes here.
662 MDNode *Node = cast(MD);
660663
661664 // Handle 'dbg' as a special case since it is not stored in the hash table.
662665 if (KindID == LLVMContext::MD_dbg) {