[llvm] [CodeGen] Change the type from int64_t to uint64_t for getObjectSize and setObjectSize (PR #149251)

Jim Lin via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 16 22:23:45 PDT 2025


https://github.com/tclin914 created https://github.com/llvm/llvm-project/pull/149251

The type of the variable returned by `getObjectSize` and set by `setObjectSize` is uint64_t.

>From 1d3d3126b434745c25298188f4f166afa338ebbc Mon Sep 17 00:00:00 2001
From: Jim Lin <jim at andestech.com>
Date: Thu, 17 Jul 2025 13:05:48 +0800
Subject: [PATCH] [CodeGen] Change the type from int64_t to uint64_t for
 getObjectSize and setObjectSize.

The type of the variable returned by `getObjectSize` and set by
`setObjectSize` is uint64_t.
---
 llvm/include/llvm/CodeGen/MachineFrameInfo.h         | 4 ++--
 llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp         | 2 +-
 llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp | 2 +-
 llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp         | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/MachineFrameInfo.h b/llvm/include/llvm/CodeGen/MachineFrameInfo.h
index 403e5eda949f1..d672cef9ceefa 100644
--- a/llvm/include/llvm/CodeGen/MachineFrameInfo.h
+++ b/llvm/include/llvm/CodeGen/MachineFrameInfo.h
@@ -471,14 +471,14 @@ class MachineFrameInfo {
   }
 
   /// Return the size of the specified object.
-  int64_t getObjectSize(int ObjectIdx) const {
+  uint64_t getObjectSize(int ObjectIdx) const {
     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
            "Invalid Object Idx!");
     return Objects[ObjectIdx+NumFixedObjects].Size;
   }
 
   /// Change the size of the specified stack object.
-  void setObjectSize(int ObjectIdx, int64_t Size) {
+  void setObjectSize(int ObjectIdx, uint64_t Size) {
     assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
            "Invalid Object Idx!");
     Objects[ObjectIdx+NumFixedObjects].Size = Size;
diff --git a/llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp b/llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp
index 5cd35cc79d8a1..480e7b576a392 100644
--- a/llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp
+++ b/llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp
@@ -84,7 +84,7 @@ bool MachineSanitizerBinaryMetadata::run(MachineFunction &MF) {
   if (!Features->getUniqueInteger()[kSanitizerBinaryMetadataUARBit])
     return false;
   // Calculate size of stack args for the function.
-  int64_t Size = 0;
+  uint64_t Size = 0;
   uint64_t Align = 0;
   const MachineFrameInfo &MFI = MF.getFrameInfo();
   for (int i = -1; i >= (int)-MFI.getNumFixedObjects(); --i) {
diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
index 80aeefe8e068a..919529c42da62 100644
--- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -394,7 +394,7 @@ spillIncomingStatepointValue(SDValue Incoming, SDValue Chain,
     MachineFrameInfo &MFI = Builder.DAG.getMachineFunction().getFrameInfo();
     assert((MFI.getObjectSize(Index) * 8) ==
                (-8 & (7 + // Round up modulo 8.
-                      (int64_t)Incoming.getValueSizeInBits())) &&
+                      Incoming.getValueSizeInBits())) &&
            "Bad spill:  stack slot does not match!");
 
     // Note: Using the alignment of the spill slot (rather than the abi or
diff --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
index ae6ca55a36092..7efd59168ffd1 100644
--- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
@@ -404,7 +404,7 @@ bool SystemZInstrInfo::isStackSlotCopy(const MachineInstr &MI,
     return false;
 
   // Check that Length covers the full slots.
-  int64_t Length = MI.getOperand(2).getImm();
+  uint64_t Length = MI.getOperand(2).getImm();
   unsigned FI1 = MI.getOperand(0).getIndex();
   unsigned FI2 = MI.getOperand(3).getIndex();
   if (MFI.getObjectSize(FI1) != Length ||



More information about the llvm-commits mailing list