[llvm] [LTO] Simplify calculateCallGraphRoot (NFC) (PR #107765)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 8 08:56:06 PDT 2024


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

The function returns an instance of FunctionSummary populated by
calculateCallGraphRoot regardless of whether Edges is empty or not.


>From caa7e773a163c9751664047d06c37668e92d2462 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 8 Sep 2024 08:41:40 -0700
Subject: [PATCH] [LTO] Simplify calculateCallGraphRoot (NFC)

The function returns an instance of FunctionSummary populated by
calculateCallGraphRoot regardless of whether Edges is empty or not.
---
 llvm/include/llvm/IR/ModuleSummaryIndex.h | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/llvm/include/llvm/IR/ModuleSummaryIndex.h b/llvm/include/llvm/IR/ModuleSummaryIndex.h
index dae208d0b132e4..288aba16702f56 100644
--- a/llvm/include/llvm/IR/ModuleSummaryIndex.h
+++ b/llvm/include/llvm/IR/ModuleSummaryIndex.h
@@ -1544,14 +1544,7 @@ class ModuleSummaryIndex {
         continue; // skip over non-root nodes
       Edges.push_back(std::make_pair(P.first, CalleeInfo{}));
     }
-    if (Edges.empty()) {
-      // Failed to find root - return an empty node
-      return FunctionSummary::makeDummyFunctionSummary(
-          SmallVector<FunctionSummary::EdgeTy, 0>());
-    }
-    auto CallGraphRoot =
-        FunctionSummary::makeDummyFunctionSummary(std::move(Edges));
-    return CallGraphRoot;
+    return FunctionSummary::makeDummyFunctionSummary(std::move(Edges));
   }
 
   bool withGlobalValueDeadStripping() const {



More information about the llvm-commits mailing list