[llvm] fix CodeGenPrepare crash with null PSI (issue #173360) (PR #173385)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 23 08:45:15 PST 2025
https://github.com/nataliakokoromyti updated https://github.com/llvm/llvm-project/pull/173385
>From 6e2d9e2158c96c972a0638328661a44fff1918bc Mon Sep 17 00:00:00 2001
From: Natalia Kokoromyti <nataliakokoromyti at gmail.com>
Date: Tue, 23 Dec 2025 08:37:45 -0800
Subject: [PATCH] fix issue #173360
---
llvm/lib/CodeGen/CodeGenPrepare.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 01f49b8ecccff..aa645d87fe025 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -585,7 +585,7 @@ bool CodeGenPrepare::_run(Function &F) {
if (BBSectionsGuidedSectionPrefix && BBSectionsProfileReader &&
BBSectionsProfileReader->isFunctionHot(F.getName())) {
(void)F.setSectionPrefix("hot");
- } else if (ProfileGuidedSectionPrefix) {
+ } else if (ProfileGuidedSectionPrefix && PSI) {
// The hot attribute overwrites profile count based hotness while profile
// counts based hotness overwrite the cold attribute.
// This is a conservative behabvior.
@@ -605,7 +605,7 @@ bool CodeGenPrepare::_run(Function &F) {
/// This optimization identifies DIV instructions that can be
/// profitably bypassed and carried out with a shorter, faster divide.
- if (!OptSize && !PSI->hasHugeWorkingSetSize() && TLI->isSlowDivBypassed()) {
+ if (!OptSize && PSI && !PSI->hasHugeWorkingSetSize() && TLI->isSlowDivBypassed()) {
const DenseMap<unsigned int, unsigned int> &BypassWidths =
TLI->getBypassSlowDivWidths();
BasicBlock *BB = &*F.begin();
More information about the llvm-commits
mailing list