diff --git a/llvm/include/llvm/IR/GlobalIFunc.h b/llvm/include/llvm/IR/GlobalIFunc.h --- a/llvm/include/llvm/IR/GlobalIFunc.h +++ b/llvm/include/llvm/IR/GlobalIFunc.h @@ -84,6 +84,11 @@ return FunctionType::get(IFuncValTy->getPointerTo(), false); } + static bool isValidLinkage(LinkageTypes L) { + return isExternalLinkage(L) || isLocalLinkage(L) || isWeakLinkage(L) || + isLinkOnceLinkage(L); + } + // Methods for support type inquiry through isa, cast, and dyn_cast: static bool classof(const Value *V) { return V->getValueID() == Value::GlobalIFuncVal; diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -836,10 +836,15 @@ } void Verifier::visitGlobalIFunc(const GlobalIFunc &GI) { + Assert(GlobalIFunc::isValidLinkage(GI.getLinkage()), + "IFunc should have private, internal, linkonce, weak, linkonce_odr, " + "weak_odr, or external linkage!", &GI); // Pierce through ConstantExprs and GlobalAliases and check that the resolver - // has a Function + // is a Function definition const Function *Resolver = GI.getResolverFunction(); Assert(Resolver, "IFunc must have a Function resolver", &GI); + Assert(!Resolver->isDeclarationForLinker(), + "IFunc resolver must be a definition", &GI); // Check that the immediate resolver operand (prior to any bitcasts) has the // correct type