[llvm] ce8c43f - Fix assertion of null pointer samples in inline replay mode (#99378)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 18 10:16:47 PDT 2024


Author: Lei Wang
Date: 2024-07-18T10:16:44-07:00
New Revision: ce8c43fe274f3f090cad2342af6032176efb846f

URL: https://github.com/llvm/llvm-project/commit/ce8c43fe274f3f090cad2342af6032176efb846f
DIFF: https://github.com/llvm/llvm-project/commit/ce8c43fe274f3f090cad2342af6032176efb846f.diff

LOG: Fix assertion of null pointer samples in inline replay mode (#99378)

Fix https://github.com/llvm/llvm-project/issues/97108. In inline replay
mode, `CalleeSamples` may be null and the order doesn't matter.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/SampleProfile.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index 5cc2911a1a80e..6af284d513efc 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 LCS;
 
     // 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