[llvm] Fix assertion of null pointer samples in inline replay mode (PR #99378)
Lei Wang via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 17 12:24:00 PDT 2024
https://github.com/wlei-llvm created https://github.com/llvm/llvm-project/pull/99378
Fix https://github.com/llvm/llvm-project/issues/97108. In inline replay mode, `CalleeSamples` may be null and the order doesn't matter.
>From 318f8ed15053ff9178c8f2ddaff4ae4e5fe83bea Mon Sep 17 00:00:00 2001
From: wlei <wlei at fb.com>
Date: Mon, 8 Jul 2024 17:22:23 -0700
Subject: [PATCH] Fix assertion of null pointer samples in inline replay mode
---
llvm/lib/Transforms/IPO/SampleProfile.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 5cc2911a1a80e..b43fde3d4e086 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -439,7 +439,10 @@ struct CandidateComparer {
const FunctionSamples *LCS = LHS.CalleeSamples;
const FunctionSamples *RCS = RHS.CalleeSamples;
- assert(LCS && RCS && "Expect non-null FunctionSamples");
+ // In inline replay mode, CalleeSamples may be null and the order doesn't
+ // matter.
+ if (!LCS || !RCS)
+ return false;
// Tie breaker using number of samples try to favor smaller functions first
if (LCS->getBodySamples().size() != RCS->getBodySamples().size())
More information about the llvm-commits
mailing list