================ @@ -2860,9 +2861,25 @@ static void setLinkageForGV(llvm::GlobalValue *GV, const NamedDecl *ND) { GV->setLinkage(llvm::GlobalValue::ExternalWeakLinkage); } +static bool HasExistingGeneralizedTypeMD(llvm::Function *F) { + llvm::MDNode *MD = F->getMetadata(llvm::LLVMContext::MD_type); + if (!MD || !isa<llvm::MDString>(MD->getOperand(1))) + return false; + + llvm::MDString *TypeIdStr = cast<llvm::MDString>(MD->getOperand(1)); + return TypeIdStr->getString().ends_with(".generalized"); +} + void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD, llvm::Function *F) { - // Only if we are checking indirect calls. + if (CodeGenOpts.CallGraphSection && !HasExistingGeneralizedTypeMD(F) && ---------------- ilovepi wrote:
Does this *ever* get called on a function that already has metadata? Seems like this code assumes it will only be called on a function once... so I'd guess `hasExistingGeneralizedTypeMD() == false` for all uses of this function. If you're worried, maybe it could be an assert instead? https://github.com/llvm/llvm-project/pull/117036 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits