[llvm] [ReachingDefAnalysis][NFC] Use named constants. (PR #175075)

Mikhail Gudim via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 11 07:35:35 PST 2026


https://github.com/mgudim updated https://github.com/llvm/llvm-project/pull/175075

>From fde5fa72736ad20d0aaca543823b70bb100b4e18 Mon Sep 17 00:00:00 2001
From: Mikhail Gudim <mgudim at qti.qualcomm.com>
Date: Thu, 8 Jan 2026 13:47:21 -0800
Subject: [PATCH 1/2] [ReachingDefAnalysis][NFC] Use named constants.

---
 llvm/include/llvm/CodeGen/ReachingDefAnalysis.h | 2 ++
 llvm/lib/CodeGen/ReachingDefAnalysis.cpp        | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h b/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
index 863c3b39229b9..03505efdebfd9 100644
--- a/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
+++ b/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
@@ -152,6 +152,8 @@ class ReachingDefInfo {
 
   /// Default values are 'nothing happened a long time ago'.
   const int ReachingDefDefaultVal = -(1 << 21);
+  /// Special values for function live-ins.
+  const int FunctionLiveInMarker = -1;
 
   using InstSet = SmallPtrSetImpl<MachineInstr*>;
   using BlockSet = SmallPtrSetImpl<MachineBasicBlock*>;
diff --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
index b8b35210413ff..78ee5ce77cf81 100644
--- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
+++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
@@ -134,9 +134,9 @@ void ReachingDefInfo::enterBasicBlock(MachineBasicBlock *MBB) {
         // Treat function live-ins as if they were defined just before the first
         // instruction.  Usually, function arguments are set up immediately
         // before the call.
-        if (LiveRegs[static_cast<unsigned>(Unit)] != -1) {
-          LiveRegs[static_cast<unsigned>(Unit)] = -1;
-          MBBReachingDefs.append(MBBNumber, Unit, -1);
+        if (LiveRegs[static_cast<unsigned>(Unit)] != FunctionLiveInMarker) {
+          LiveRegs[static_cast<unsigned>(Unit)] = FunctionLiveInMarker;
+          MBBReachingDefs.append(MBBNumber, Unit, FunctionLiveInMarker);
         }
       }
     }

>From 19d33d9b9ec35d53ccf3a7f784f30fbff19f9292 Mon Sep 17 00:00:00 2001
From: Mikhail Gudim <mgudim at qti.qualcomm.com>
Date: Sun, 11 Jan 2026 07:34:37 -0800
Subject: [PATCH 2/2] review comments.

---
 llvm/include/llvm/CodeGen/ReachingDefAnalysis.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h b/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
index 03505efdebfd9..b6ca1d6e9b328 100644
--- a/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
+++ b/llvm/include/llvm/CodeGen/ReachingDefAnalysis.h
@@ -151,9 +151,9 @@ class ReachingDefInfo {
   MBBFrameObjsReachingDefsInfo MBBFrameObjsReachingDefs;
 
   /// Default values are 'nothing happened a long time ago'.
-  const int ReachingDefDefaultVal = -(1 << 21);
+  static constexpr int ReachingDefDefaultVal = -(1 << 21);
   /// Special values for function live-ins.
-  const int FunctionLiveInMarker = -1;
+  static constexpr int FunctionLiveInMarker = -1;
 
   using InstSet = SmallPtrSetImpl<MachineInstr*>;
   using BlockSet = SmallPtrSetImpl<MachineBasicBlock*>;



More information about the llvm-commits mailing list