#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
/// 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
// 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 {
/// 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) {