Work around an LLVM bug by not referring to globals from metadata. This was

only used for consistency checking anyway.
For the LLVM bug, see http://llvm.org/PR4180 / http://llvm.org/PR4046
This commit is contained in:
Frits van Bommel
2009-05-08 16:00:44 +02:00
parent 5c29832ee7
commit adf1fd4d44
3 changed files with 7 additions and 3 deletions

View File

@@ -15,7 +15,10 @@
/// The fields in the metadata node for a TypeInfo instance.
/// (Its name will be TD_PREFIX ~ <Name of TypeInfo global>)
enum TypeDataFields {
TD_Confirm, /// The TypeInfo this node is for
// TD_Confirm is disabled for now 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.
TD_Type, /// A value of the LLVM type corresponding to this D type
// Must be kept last:

View File

@@ -347,7 +347,7 @@ const Type* Analysis::getTypeFor(Value* typeinfo) const {
return NULL;
if (node->getNumOperands() != TD_NumFields ||
node->getOperand(TD_Confirm)->stripPointerCasts() != ti_global)
(TD_Confirm >= 0 && node->getOperand(TD_Confirm)->stripPointerCasts() != ti_global))
return NULL;
return node->getOperand(TD_Type)->getType();

View File

@@ -295,7 +295,8 @@ void DtoResolveTypeInfo(TypeInfoDeclaration* tid)
if (!meta && tid->tinfo->toBasetype()->ty < Terror) {
// Construct the fields
LLConstant* mdVals[TD_NumFields];
mdVals[TD_Confirm] = llvm::cast<LLConstant>(irg->value);
if (TD_Confirm >= 0)
mdVals[TD_Confirm] = llvm::cast<LLConstant>(irg->value);
mdVals[TD_Type] = llvm::UndefValue::get(DtoType(tid->tinfo));
// Construct the metadata
llvm::MDNode* metadata = llvm::MDNode::get(mdVals, TD_NumFields);