[llvm] Check for Res first before checking if we are to export it (PR #152346)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 6 10:34:08 PDT 2025


https://github.com/AZero13 created https://github.com/llvm/llvm-project/pull/152346

Res can be null, though it is unclear if res is always set if the cs info is exported. Better to be safe just in case.

>From fd4a560fbece64d2a8cd9ca9d1787d647505a056 Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Wed, 6 Aug 2025 13:33:51 -0400
Subject: [PATCH] Check for Res first before checking if we are to export it

Res can be null, though it is unclear if res is always set if the cs info is exported. Better to be safe just in case.
---
 llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index aec484f8a18f9..e20025a997b8c 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1648,7 +1648,7 @@ bool DevirtModule::tryUniformRetValOpt(
     if (Target.RetVal != TheRetVal)
       return false;
 
-  if (CSInfo.isExported()) {
+  if (Res && CSInfo.isExported()) {
     Res->TheKind = WholeProgramDevirtResolution::ByArg::UniformRetVal;
     Res->Info = TheRetVal;
   }



More information about the llvm-commits mailing list