[clang] Fix callee type generation (PR #186272)

Prabhu Rajasekaran via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 12 20:19:54 PDT 2026


================
@@ -3267,8 +3267,10 @@ void CodeGenModule::createFunctionTypeMetadataForIcall(const FunctionDecl *FD,
 
 void CodeGenModule::createCalleeTypeMetadataForIcall(const QualType &QT,
                                                      llvm::CallBase *CB) {
-  // Only if needed for call graph section and only for indirect calls.
-  if (!CodeGenOpts.CallGraphSection || !CB->isIndirectCall())
+  // Only if needed for call graph section and only for indirect calls that are
+  // visible externally.
+  if (!CodeGenOpts.CallGraphSection || !CB->isIndirectCall() ||
+      !isExternallyVisible(QT->getLinkage()))
----------------
Prabhuk wrote:

The failure is not related to devirtualization but the decision to not add type metadata to symbols local to TU seems to be an optimization that makes sense. Especially in the LTO context if most of the indirect calls can be optimized away if not all. I am willing to go with this fix to make sure we do not break the compiler due to verifier check failing for such cases and revisit if we must improve the handling of such cases from the call graph precision point of view.

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


More information about the cfe-commits mailing list