[llvm] [MIRSampleProfile] Check nullptr Reader to avoid crash when profile file missing (PR #190186)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 2 09:12:50 PDT 2026
https://github.com/frank-515 updated https://github.com/llvm/llvm-project/pull/190186
>From 88807fe5d0d702cc8b7e243c8c205cf22e71a893 Mon Sep 17 00:00:00 2001
From: frank515 <frank515_ at outlook.com>
Date: Thu, 2 Apr 2026 22:52:11 +0800
Subject: [PATCH] [MIRSampleProfile] Fix nullptr deref crash when profile file
is not found
---
llvm/lib/CodeGen/MIRSampleProfile.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/llvm/lib/CodeGen/MIRSampleProfile.cpp b/llvm/lib/CodeGen/MIRSampleProfile.cpp
index 1f00446465c12..e2b31f9afb46d 100644
--- a/llvm/lib/CodeGen/MIRSampleProfile.cpp
+++ b/llvm/lib/CodeGen/MIRSampleProfile.cpp
@@ -317,6 +317,8 @@ bool MIRProfileLoader::runOnFunction(MachineFunction &MF) {
// discriminator would end up getting zero samples. This could in turn undo
// the sample distribution effort done by previous BFI maintenance and the
// probe distribution factor work for pseudo probes.
+ if (!Reader)
+ return false;
if (!Reader->profileIsFS())
return false;
More information about the llvm-commits
mailing list