Re-enable consistency check for fixed LLVM versions.

This commit is contained in:
Frits van Bommel
2009-05-11 15:48:33 +02:00
parent 49a2924823
commit e4e07baf87
3 changed files with 12 additions and 5 deletions

View File

@@ -42,9 +42,14 @@
/// The fields in the metadata node for a TypeInfo instance.
/// (Its name will be TD_PREFIX ~ <Name of TypeInfo global>)
enum TypeDataFields {
// TD_Confirm is disabled for now due to an LLVM bug when MDNodes contain
// globals (see http://llvm.org/PR4180 / http://llvm.org/PR4046 )
#if LLVM_REV < 71407
// TD_Confirm is disabled for older revisions due to an LLVM bug when
// MDNodes contain globals
// (see http://llvm.org/PR4180 / http://llvm.org/PR4046 )
TD_Confirm = -1,/// The TypeInfo this node is for.
#else
TD_Confirm, /// The TypeInfo this node is for.
#endif
TD_Type, /// A value of the LLVM type corresponding to this D type

View File

@@ -397,8 +397,10 @@ const Type* Analysis::getTypeFor(Value* typeinfo) const {
if (!node)
return NULL;
if (MD_GetNumElements(node) != TD_NumFields ||
(TD_Confirm >= 0 && MD_GetElement(node, TD_Confirm)->stripPointerCasts() != ti_global))
if (MD_GetNumElements(node) != TD_NumFields)
return NULL;
if (TD_Confirm >= 0 && (!MD_GetElement(node, TD_Confirm) ||
MD_GetElement(node, TD_Confirm)->stripPointerCasts() != ti_global))
return NULL;
return MD_GetElement(node, TD_Type)->getType();

View File

@@ -296,7 +296,7 @@ void DtoResolveTypeInfo(TypeInfoDeclaration* tid)
// Construct the fields
MDNodeField* mdVals[TD_NumFields];
if (TD_Confirm >= 0)
mdVals[TD_Confirm] = llvm::cast<LLConstant>(irg->value);
mdVals[TD_Confirm] = llvm::cast<MDNodeField>(irg->value);
mdVals[TD_Type] = llvm::UndefValue::get(DtoType(tid->tinfo));
// Construct the metadata
llvm::MDNode* metadata = llvm::MDNode::get(mdVals, TD_NumFields);