[llvm-branch-commits] [clang] callee_type metadata for indirect calls (PR #117036)

Paul Kirth via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Apr 22 10:00:06 PDT 2025


================
@@ -2873,14 +2890,33 @@ void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
 
   llvm::Metadata *MD = CreateMetadataIdentifierForType(FD->getType());
   F->addTypeMetadata(0, MD);
-  F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(FD->getType()));
+  // Add the generalized identifier if not added already.
+  if (!HasExistingGeneralizedTypeMD(F))
----------------
ilovepi wrote:

You can probably forgo the call to `hasExistingGeneralizedTypeMD()` altogether. The only way that this code would execute is if we're doing CFI and we'd add metadata. As the code is written that will always happen if you reach this point. Therefor, the MD won't exist, unless you've added it. You can track that w/ a local variable `bool AddedTypeMD`, and set it to true if you modify anything. 

https://github.com/llvm/llvm-project/pull/117036


More information about the llvm-branch-commits mailing list