[flang-commits] [openmp] [clang-tools-extra] [libcxx] [libc] [mlir] [lldb] [llvm] [flang] [clang] GlobalISel: Guide return in llvm::getIConstantSplatVal (PR #71989)

via flang-commits flang-commits at lists.llvm.org
Fri Nov 10 13:59:01 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-globalisel

Author: Changpeng Fang (changpeng)

<details>
<summary>Changes</summary>

getIConstantVRegValWithLookThrough could return NULL.

---
Full diff: https://github.com/llvm/llvm-project/pull/71989.diff


1 Files Affected:

- (modified) llvm/lib/CodeGen/GlobalISel/Utils.cpp (+3-3) 


``````````diff
diff --git a/llvm/lib/CodeGen/GlobalISel/Utils.cpp b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
index 473c3f452f8b1d9..eaf829f562b2dc9 100644
--- a/llvm/lib/CodeGen/GlobalISel/Utils.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/Utils.cpp
@@ -1116,9 +1116,9 @@ std::optional<APInt>
 llvm::getIConstantSplatVal(const Register Reg, const MachineRegisterInfo &MRI) {
   if (auto SplatValAndReg =
           getAnyConstantSplat(Reg, MRI, /* AllowUndef */ false)) {
-    std::optional<ValueAndVReg> ValAndVReg =
-        getIConstantVRegValWithLookThrough(SplatValAndReg->VReg, MRI);
-    return ValAndVReg->Value;
+    if (std::optional<ValueAndVReg> ValAndVReg =
+        getIConstantVRegValWithLookThrough(SplatValAndReg->VReg, MRI))
+      return ValAndVReg->Value;
   }
 
   return std::nullopt;

``````````

</details>


https://github.com/llvm/llvm-project/pull/71989


More information about the flang-commits mailing list