[llvm] [ModuleInliner] Skip function declarations during candidate scan (PR #195567)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun May 3 18:10:31 PDT 2026


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/195567

This patch skips function declarations during the candidate scan in
ModuleInlinerPass::run as declarations do not have bodies.


>From 52def0a6b2376ac1b56914c8b30ebbff7676d34b Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 3 May 2026 17:53:38 -0700
Subject: [PATCH] [ModuleInliner] Skip function declarations during candidate
 scan

This patch skips function declarations during the candidate scan in
ModuleInlinerPass::run as declarations do not have bodies.
---
 llvm/lib/Transforms/IPO/ModuleInliner.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/Transforms/IPO/ModuleInliner.cpp b/llvm/lib/Transforms/IPO/ModuleInliner.cpp
index 79f545a9b3283..138f24d26e278 100644
--- a/llvm/lib/Transforms/IPO/ModuleInliner.cpp
+++ b/llvm/lib/Transforms/IPO/ModuleInliner.cpp
@@ -139,6 +139,8 @@ PreservedAnalyses ModuleInlinerPass::run(Module &M,
   // Populate the initial list of calls in this module.
   SetVector<std::pair<CallBase *, Function *>> ICPCandidates;
   for (Function &F : M) {
+    if (F.isDeclaration())
+      continue;
     auto &ORE = FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);
     for (Instruction &I : instructions(F)) {
       if (auto *CB = dyn_cast<CallBase>(&I)) {



More information about the llvm-commits mailing list