mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-26 00:23:14 +01:00
use the new NamedMDNode class
this will need a LLVM >= r77619
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#define LDC_GEN_METADATA_H
|
||||
|
||||
// MDNode was moved into its own header, and contains Value*s
|
||||
#include "llvm/MDNode.h"
|
||||
#include "llvm/Metadata.h"
|
||||
typedef llvm::Value MDNodeField;
|
||||
|
||||
// Use getNumElements() and getElement() to access elements.
|
||||
|
||||
@@ -201,18 +201,18 @@ namespace {
|
||||
GlobalVariable* ClassInfo = dyn_cast<GlobalVariable>(arg);
|
||||
if (!ClassInfo)
|
||||
return false;
|
||||
|
||||
|
||||
std::string metaname = CD_PREFIX;
|
||||
metaname += ClassInfo->getName();
|
||||
|
||||
GlobalVariable* global = A.M.getGlobalVariable(metaname);
|
||||
if (!global || !global->hasInitializer())
|
||||
|
||||
NamedMDNode* meta = A.M.getNamedMetadata(metaname);
|
||||
if (!meta)
|
||||
return false;
|
||||
|
||||
MDNode* node = dyn_cast<MDNode>(global->getInitializer());
|
||||
|
||||
MDNode* node = static_cast<MDNode*>(meta->getElement(0));
|
||||
if (!node || MD_GetNumElements(node) != CD_NumFields)
|
||||
return false;
|
||||
|
||||
|
||||
// Inserting destructor calls is not implemented yet, so classes
|
||||
// with destructors are ignored for now.
|
||||
Constant* hasDestructor = dyn_cast<Constant>(MD_GetElement(node, CD_Finalize));
|
||||
@@ -396,15 +396,15 @@ const Type* Analysis::getTypeFor(Value* typeinfo) const {
|
||||
|
||||
std::string metaname = TD_PREFIX;
|
||||
metaname += ti_global->getName();
|
||||
|
||||
GlobalVariable* global = M.getGlobalVariable(metaname);
|
||||
if (!global || !global->hasInitializer())
|
||||
|
||||
NamedMDNode* meta = M.getNamedMetadata(metaname);
|
||||
if (!meta)
|
||||
return NULL;
|
||||
|
||||
MDNode* node = dyn_cast<MDNode>(global->getInitializer());
|
||||
|
||||
MDNode* node = static_cast<MDNode*>(meta->getElement(0));
|
||||
if (!node)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (MD_GetNumElements(node) != TD_NumFields)
|
||||
return NULL;
|
||||
if (TD_Confirm >= 0 && (!MD_GetElement(node, TD_Confirm) ||
|
||||
|
||||
@@ -304,7 +304,7 @@ void DtoResolveTypeInfo(TypeInfoDeclaration* tid)
|
||||
|
||||
// Add some metadata for use by optimization passes.
|
||||
std::string metaname = std::string(TD_PREFIX) + mangle;
|
||||
LLGlobalVariable* meta = gIR->module->getGlobalVariable(metaname);
|
||||
llvm::NamedMDNode* meta = gIR->module->getNamedMetadata(metaname);
|
||||
// Don't generate metadata for non-concrete types
|
||||
// (such as tuple types, slice types, typeof(expr), etc.)
|
||||
if (!meta && tid->tinfo->toBasetype()->ty < Terror) {
|
||||
@@ -314,10 +314,9 @@ void DtoResolveTypeInfo(TypeInfoDeclaration* tid)
|
||||
mdVals[TD_Confirm] = llvm::cast<MDNodeField>(irg->value);
|
||||
mdVals[TD_Type] = llvm::UndefValue::get(DtoType(tid->tinfo));
|
||||
// Construct the metadata
|
||||
llvm::MDNode* metadata = gIR->context().getMDNode(mdVals, TD_NumFields);
|
||||
llvm::MetadataBase* metadata = gIR->context().getMDNode(mdVals, TD_NumFields);
|
||||
// Insert it into the module
|
||||
new llvm::GlobalVariable(*gIR->module, metadata->getType(), true,
|
||||
METADATA_LINKAGE_TYPE, metadata, metaname);
|
||||
llvm::NamedMDNode::Create(metaname, &metadata, 1, gIR->module);
|
||||
}
|
||||
|
||||
DtoDeclareTypeInfo(tid);
|
||||
|
||||
@@ -85,10 +85,10 @@ LLGlobalVariable * IrStruct::getClassInfoSymbol()
|
||||
mdVals[CD_Finalize] = LLConstantInt::get(LLType::Int1Ty, hasDestructor);
|
||||
mdVals[CD_CustomDelete] = LLConstantInt::get(LLType::Int1Ty, hasCustomDelete);
|
||||
// Construct the metadata
|
||||
llvm::MDNode* metadata = gIR->context().getMDNode(mdVals, CD_NumFields);
|
||||
llvm::MetadataBase* metadata = gIR->context().getMDNode(mdVals, CD_NumFields);
|
||||
// Insert it into the module
|
||||
new llvm::GlobalVariable(*gIR->module, metadata->getType(), true,
|
||||
METADATA_LINKAGE_TYPE, metadata, CD_PREFIX + initname);
|
||||
std::string metaname = CD_PREFIX + initname;
|
||||
llvm::NamedMDNode::Create(metaname, &metadata, 1, gIR->module);
|
||||
}
|
||||
|
||||
return classInfo;
|
||||
|
||||
Reference in New Issue
Block a user