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

via llvm-commits llvm-commits at lists.llvm.org
Sun May 3 18:11:05 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

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


---
Full diff: https://github.com/llvm/llvm-project/pull/195567.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/IPO/ModuleInliner.cpp (+2) 


``````````diff
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)) {

``````````

</details>


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


More information about the llvm-commits mailing list