[llvm] [Bolt] Replace -1ULL/-2ULL/-3ULL with std::numeric_limits in DataAggregator (PR #178597)

via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 7 20:44:11 PST 2026


https://github.com/Devanshi-cmd updated https://github.com/llvm/llvm-project/pull/178597

>From f5e746089273d909e2709d9090686cbfb8964241 Mon Sep 17 00:00:00 2001
From: Devanshi-cmd <devanshitiwari250 at gmail.com>
Date: Thu, 29 Jan 2026 11:11:45 +0530
Subject: [PATCH 1/3] [Bolt] Replace -1ULL/-2ULL/-3ULL with std::numeric_limits
 in DataAggregator
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Replace instances of -1ULL, -2ULL, and -3ULL with std::numeric_limits
in Bolt DataAggregator Trace constants to address C4146 compiler warning.

Changes:
- BR_ONLY: -1ULL → std::numeric_limits<uint64_t>::max()
- FT_ONLY: -1ULL → std::numeric_limits<uint64_t>::max()
- FT_EXTERNAL_ORIGIN: -2ULL → std::numeric_limits<uint64_t>::max() - 1
- FT_EXTERNAL_RETURN: -3ULL → std::numeric_limits<uint64_t>::max() - 2

Fixes part of #147439
---
 bolt/include/bolt/Profile/DataAggregator.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/bolt/include/bolt/Profile/DataAggregator.h b/bolt/include/bolt/Profile/DataAggregator.h
index db0f6903185b7..ab34077d8591c 100644
--- a/bolt/include/bolt/Profile/DataAggregator.h
+++ b/bolt/include/bolt/Profile/DataAggregator.h
@@ -108,10 +108,10 @@ class DataAggregator : public DataReader {
   ///   (FT_ONLY, FT_EXTERNAL_ORIGIN, or FT_EXTERNAL_RETURN).
   struct Trace {
     static constexpr const uint64_t EXTERNAL = 0ULL;
-    static constexpr const uint64_t BR_ONLY = -1ULL;
-    static constexpr const uint64_t FT_ONLY = -1ULL;
-    static constexpr const uint64_t FT_EXTERNAL_ORIGIN = -2ULL;
-    static constexpr const uint64_t FT_EXTERNAL_RETURN = -3ULL;
+    static constexpr const uint64_t BR_ONLY = std::numeric_limits<uint64_t>::max();
+    static constexpr const uint64_t FT_ONLY = std::numeric_limits<uint64_t>::max();
+    static constexpr const uint64_t FT_EXTERNAL_ORIGIN = std::numeric_limits<uint64_t>::max() - 1;
+    static constexpr const uint64_t FT_EXTERNAL_RETURN = std::numeric_limits<uint64_t>::max() - 2;
 
     uint64_t Branch;
     uint64_t From;

>From d6f3ae6bd989c6dbb8375fa87682e7ce10016bde Mon Sep 17 00:00:00 2001
From: Devanshi-cmd <devanshitiwari250 at gmail.com>
Date: Thu, 29 Jan 2026 17:07:59 +0530
Subject: [PATCH 2/3] Add missing limits header and fix formatting

- Add #include <limits> for std::numeric_limits
- Fix clang-format issues by splitting long lines
---
 bolt/include/bolt/Profile/DataAggregator.h | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/bolt/include/bolt/Profile/DataAggregator.h b/bolt/include/bolt/Profile/DataAggregator.h
index ab34077d8591c..137808a7b8e94 100644
--- a/bolt/include/bolt/Profile/DataAggregator.h
+++ b/bolt/include/bolt/Profile/DataAggregator.h
@@ -20,6 +20,7 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Program.h"
 #include <unordered_map>
+#include<limits>
 
 namespace llvm {
 namespace bolt {
@@ -108,10 +109,14 @@ class DataAggregator : public DataReader {
   ///   (FT_ONLY, FT_EXTERNAL_ORIGIN, or FT_EXTERNAL_RETURN).
   struct Trace {
     static constexpr const uint64_t EXTERNAL = 0ULL;
-    static constexpr const uint64_t BR_ONLY = std::numeric_limits<uint64_t>::max();
-    static constexpr const uint64_t FT_ONLY = std::numeric_limits<uint64_t>::max();
-    static constexpr const uint64_t FT_EXTERNAL_ORIGIN = std::numeric_limits<uint64_t>::max() - 1;
-    static constexpr const uint64_t FT_EXTERNAL_RETURN = std::numeric_limits<uint64_t>::max() - 2;
+    static constexpr const uint64_t BR_ONLY =
+        std::numeric_limits<uint64_t>::max();
+    static constexpr const uint64_t FT_ONLY =
+        std::numeric_limits<uint64_t>::max();
+    static constexpr const uint64_t FT_EXTERNAL_ORIGIN =
+        std::numeric_limits<uint64_t>::max() - 1;
+    static constexpr const uint64_t FT_EXTERNAL_RETURN =
+        std::numeric_limits<uint64_t>::max() - 2;
 
     uint64_t Branch;
     uint64_t From;

>From 58f6c636fa1c24653d5fb47e45a93673d4bb7958 Mon Sep 17 00:00:00 2001
From: Devanshi-cmd <devanshitiwari250 at gmail.com>
Date: Sun, 8 Feb 2026 10:13:53 +0530
Subject: [PATCH 3/3] Fix formatting: add missing limits header and correct
 placement

Add space in #include directive and move <limits> header to correct
alphabetical position before <unordered_map> to satisfy clang-format
requirements.
---
 bolt/include/bolt/Profile/DataAggregator.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bolt/include/bolt/Profile/DataAggregator.h b/bolt/include/bolt/Profile/DataAggregator.h
index 137808a7b8e94..666df9eb18ed8 100644
--- a/bolt/include/bolt/Profile/DataAggregator.h
+++ b/bolt/include/bolt/Profile/DataAggregator.h
@@ -19,8 +19,8 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/Program.h"
+#include <limits>
 #include <unordered_map>
-#include<limits>
 
 namespace llvm {
 namespace bolt {



More information about the llvm-commits mailing list