================ @@ -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) && ---------------- Prabhuk wrote:
Yes! The CreateFunctionTypeMetadataForIcall function is called twice consistently from: 1. clang::CodeGen::CodeGenModule::SetFunctionAttributes 2. clang::CodeGen::CodeGenModule::SetLLVMFunctionAttributesForDefinition This leads to multiple instances of !type metadata getting added to the functions. 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