From 848812a55e530517191ed0f4f15c0c60752ea9c4 Mon Sep 17 00:00:00 2001 From: Itay Bookstein Date: Sun, 31 Oct 2021 20:00:57 -0700 Subject: [Verifier] Add verification logic for GlobalIFuncs Verify that the resolver exists, that it is a defined Function, and that its return type matches the ifunc's type. Add corresponding check to BitcodeReader, change clang to emit the correct type, and fix tests to comply. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D112349 --- llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp') diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 9ba7602..8b0846d 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2279,7 +2279,11 @@ Error BitcodeReader::resolveGlobalAndIndirectSymbolInits() { return error("Alias and aliasee types don't match"); GA->setAliasee(C); } else if (auto *GI = dyn_cast(GV)) { - GI->setResolver(C); + Type *ResolverFTy = + GlobalIFunc::getResolverFunctionType(GI->getValueType()); + // Transparently fix up the type for compatiblity with older bitcode + GI->setResolver( + ConstantExpr::getBitCast(C, ResolverFTy->getPointerTo())); } else { return error("Expected an alias or an ifunc"); } -- cgit v1.1