diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2009-09-27 23:27:42 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2009-09-27 23:27:42 +0000 |
commit | c261df9fab0c95e2362b518d071ac2ec37d0a9df (patch) | |
tree | b7698384d1d02354a307ad994c727a532fc6d80b | |
parent | ae03af26635b5831d1370b5bc161ced577397200 (diff) | |
download | external_llvm-c261df9fab0c95e2362b518d071ac2ec37d0a9df.zip external_llvm-c261df9fab0c95e2362b518d071ac2ec37d0a9df.tar.gz external_llvm-c261df9fab0c95e2362b518d071ac2ec37d0a9df.tar.bz2 |
Remove the "metadata*" type and simplify the code it complicated. This was only
used to support GlobalVariables storing MDNodes, back when they were derived
from Constant before the introduction of NamedMDNode, but never removed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82943 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | docs/LangRef.html | 8 | ||||
-rw-r--r-- | lib/VMCore/Type.cpp | 51 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 58 |
3 files changed, 22 insertions, 95 deletions
diff --git a/docs/LangRef.html b/docs/LangRef.html index 6f5fbb3..3853692 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -1489,9 +1489,9 @@ Classifications</a> </div> <div class="doc_text"> <h5>Overview:</h5> -<p>The metadata type represents embedded metadata. The only derived type that - may contain metadata is <tt>metadata*</tt> or a function type that returns or - takes metadata typed parameters, but not pointer to metadata types.</p> +<p>The metadata type represents embedded metadata. No derived types may be + created from metadata except for <a href="#t_function">function</a> + arguments. <h5>Syntax:</h5> <pre> @@ -1601,7 +1601,7 @@ Classifications</a> </div> Variable argument functions can access their arguments with the <a href="#int_varargs">variable argument handling intrinsic</a> functions. '<tt><returntype></tt>' is a any type except - <a href="#t_label">label</a> and <a href="#t_metadata">metadata</a>.</p> + <a href="#t_label">label</a>.</p> <h5>Examples:</h5> <table class="layout"> diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 820789d..087464d 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -365,9 +365,6 @@ const IntegerType *Type::getInt64Ty(LLVMContext &C) { /// isValidReturnType - Return true if the specified type is valid as a return /// type. bool FunctionType::isValidReturnType(const Type *RetTy) { - if (const PointerType *PTy = dyn_cast<PointerType>(RetTy)) - return PTy->getElementType()->getTypeID() != MetadataTyID; - return RetTy->getTypeID() != LabelTyID && RetTy->getTypeID() != MetadataTyID; } @@ -375,12 +372,7 @@ bool FunctionType::isValidReturnType(const Type *RetTy) { /// isValidArgumentType - Return true if the specified type is valid as an /// argument type. bool FunctionType::isValidArgumentType(const Type *ArgTy) { - if ((!ArgTy->isFirstClassType() && !isa<OpaqueType>(ArgTy)) || - (isa<PointerType>(ArgTy) && - cast<PointerType>(ArgTy)->getElementType()->getTypeID() == MetadataTyID)) - return false; - - return true; + return ArgTy->isFirstClassType() || isa<OpaqueType>(ArgTy); } FunctionType::FunctionType(const Type *Result, @@ -817,15 +809,8 @@ ArrayType *ArrayType::get(const Type *ElementType, uint64_t NumElements) { } bool ArrayType::isValidElementType(const Type *ElemTy) { - if (ElemTy->getTypeID() == VoidTyID || ElemTy->getTypeID() == LabelTyID || - ElemTy->getTypeID() == MetadataTyID || isa<FunctionType>(ElemTy)) - return false; - - if (const PointerType *PTy = dyn_cast<PointerType>(ElemTy)) - if (PTy->getElementType()->getTypeID() == MetadataTyID) - return false; - - return true; + return ElemTy->getTypeID() != VoidTyID && ElemTy->getTypeID() != LabelTyID && + ElemTy->getTypeID() != MetadataTyID && !isa<FunctionType>(ElemTy); } VectorType *VectorType::get(const Type *ElementType, unsigned NumElements) { @@ -849,11 +834,8 @@ VectorType *VectorType::get(const Type *ElementType, unsigned NumElements) { } bool VectorType::isValidElementType(const Type *ElemTy) { - if (ElemTy->isInteger() || ElemTy->isFloatingPoint() || - isa<OpaqueType>(ElemTy)) - return true; - - return false; + return ElemTy->isInteger() || ElemTy->isFloatingPoint() || + isa<OpaqueType>(ElemTy); } //===----------------------------------------------------------------------===// @@ -896,15 +878,8 @@ StructType *StructType::get(LLVMContext &Context, const Type *type, ...) { } bool StructType::isValidElementType(const Type *ElemTy) { - if (ElemTy->getTypeID() == VoidTyID || ElemTy->getTypeID() == LabelTyID || - ElemTy->getTypeID() == MetadataTyID || isa<FunctionType>(ElemTy)) - return false; - - if (const PointerType *PTy = dyn_cast<PointerType>(ElemTy)) - if (PTy->getElementType()->getTypeID() == MetadataTyID) - return false; - - return true; + return ElemTy->getTypeID() != VoidTyID && ElemTy->getTypeID() != LabelTyID && + ElemTy->getTypeID() != MetadataTyID && !isa<FunctionType>(ElemTy); } @@ -941,15 +916,9 @@ PointerType *Type::getPointerTo(unsigned addrs) const { } bool PointerType::isValidElementType(const Type *ElemTy) { - if (ElemTy->getTypeID() == VoidTyID || - ElemTy->getTypeID() == LabelTyID) - return false; - - if (const PointerType *PTy = dyn_cast<PointerType>(ElemTy)) - if (PTy->getElementType()->getTypeID() == MetadataTyID) - return false; - - return true; + return ElemTy->getTypeID() != VoidTyID && + ElemTy->getTypeID() != LabelTyID && + ElemTy->getTypeID() != MetadataTyID; } diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 140e6bd..4f7c847 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -447,28 +447,6 @@ void Verifier::visitGlobalVariable(GlobalVariable &GV) { Assert1(!GV.isConstant(), "'common' global may not be marked constant!", &GV); } - - // Verify that any metadata used in a global initializer points only to - // other globals. - if (MDNode *FirstNode = dyn_cast<MDNode>(GV.getInitializer())) { - SmallVector<const MDNode *, 4> NodesToAnalyze; - NodesToAnalyze.push_back(FirstNode); - while (!NodesToAnalyze.empty()) { - const MDNode *N = NodesToAnalyze.back(); - NodesToAnalyze.pop_back(); - - for (MDNode::const_elem_iterator I = N->elem_begin(), - E = N->elem_end(); I != E; ++I) - if (const Value *V = *I) { - if (const MDNode *Next = dyn_cast<MDNode>(V)) - NodesToAnalyze.push_back(Next); - else - Assert3(isa<Constant>(V), - "reference to instruction from global metadata node", - &GV, N, V); - } - } - } } else { Assert1(GV.hasExternalLinkage() || GV.hasDLLImportLinkage() || GV.hasExternalWeakLinkage(), @@ -622,12 +600,12 @@ void Verifier::visitFunction(Function &F) { "# formal arguments must match # of arguments for function type!", &F, FT); Assert1(F.getReturnType()->isFirstClassType() || - F.getReturnType() == Type::getVoidTy(F.getContext()) || + F.getReturnType()->getTypeID() == Type::VoidTyID || isa<StructType>(F.getReturnType()), "Functions cannot return aggregate values!", &F); Assert1(!F.hasStructRetAttr() || - F.getReturnType() == Type::getVoidTy(F.getContext()), + F.getReturnType()->getTypeID() == Type::VoidTyID, "Invalid struct return type!", &F); const AttrListPtr &Attrs = F.getAttributes(); @@ -654,9 +632,6 @@ void Verifier::visitFunction(Function &F) { bool isLLVMdotName = F.getName().size() >= 5 && F.getName().substr(0, 5) == "llvm."; - if (!isLLVMdotName) - Assert1(F.getReturnType() != Type::getMetadataTy(F.getContext()), - "Function may not return metadata unless it's an intrinsic", &F); // Check that the argument values match the function type for this function... unsigned i = 0; @@ -763,7 +738,7 @@ void Verifier::visitTerminatorInst(TerminatorInst &I) { void Verifier::visitReturnInst(ReturnInst &RI) { Function *F = RI.getParent()->getParent(); unsigned N = RI.getNumOperands(); - if (F->getReturnType() == Type::getVoidTy(RI.getContext())) + if (F->getReturnType()->getTypeID() == Type::VoidTyID) Assert2(N == 0, "Found return instr that returns non-void in Function of void " "return type!", &RI, F->getReturnType()); @@ -1126,8 +1101,6 @@ void Verifier::VerifyCallSite(CallSite CS) { // Verify that there's no metadata unless it's a direct call to an intrinsic. if (!CS.getCalledFunction() || CS.getCalledFunction()->getName().size() < 5 || CS.getCalledFunction()->getName().substr(0, 5) != "llvm.") { - Assert1(FTy->getReturnType() != Type::getMetadataTy(I->getContext()), - "Only intrinsics may return metadata", I); for (FunctionType::param_iterator PI = FTy->param_begin(), PE = FTy->param_end(); PI != PE; ++PI) Assert1(PI->get() != Type::getMetadataTy(I->getContext()), @@ -1297,8 +1270,6 @@ void Verifier::visitLoadInst(LoadInst &LI) { const Type *ElTy = PTy->getElementType(); Assert2(ElTy == LI.getType(), "Load result type does not match pointer operand type!", &LI, ElTy); - Assert1(ElTy != Type::getMetadataTy(LI.getContext()), - "Can't load metadata!", &LI); visitInstruction(LI); } @@ -1309,8 +1280,6 @@ void Verifier::visitStoreInst(StoreInst &SI) { Assert2(ElTy == SI.getOperand(0)->getType(), "Stored value type does not match pointer operand type!", &SI, ElTy); - Assert1(ElTy != Type::getMetadataTy(SI.getContext()), - "Can't store metadata!", &SI); visitInstruction(SI); } @@ -1365,22 +1334,16 @@ void Verifier::visitInstruction(Instruction &I) { // Check that the return value of the instruction is either void or a legal // value type. - Assert1(I.getType() == Type::getVoidTy(I.getContext()) || - I.getType()->isFirstClassType() - || ((isa<CallInst>(I) || isa<InvokeInst>(I)) - && isa<StructType>(I.getType())), + Assert1(I.getType()->getTypeID() == Type::VoidTyID || + I.getType()->isFirstClassType(), "Instruction returns a non-scalar type!", &I); - // Check that the instruction doesn't produce metadata or metadata*. Calls - // all already checked against the callee type. - Assert1(I.getType() != Type::getMetadataTy(I.getContext()) || + // Check that the instruction doesn't produce metadata. Calls are already + // checked against the callee type. + Assert1(I.getType()->getTypeID() != Type::MetadataTyID || isa<CallInst>(I) || isa<InvokeInst>(I), "Invalid use of metadata!", &I); - if (const PointerType *PTy = dyn_cast<PointerType>(I.getType())) - Assert1(PTy->getElementType() != Type::getMetadataTy(I.getContext()), - "Instructions may not produce pointer to metadata.", &I); - // Check that all uses of the instruction, if they are instructions // themselves, actually have parent basic blocks. If the use is not an // instruction, it is an error! @@ -1404,11 +1367,6 @@ void Verifier::visitInstruction(Instruction &I) { Assert1(0, "Instruction operands must be first-class values!", &I); } - if (const PointerType *PTy = - dyn_cast<PointerType>(I.getOperand(i)->getType())) - Assert1(PTy->getElementType() != Type::getMetadataTy(I.getContext()), - "Invalid use of metadata pointer.", &I); - if (Function *F = dyn_cast<Function>(I.getOperand(i))) { // Check to make sure that the "address of" an intrinsic function is never // taken. |