Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tclin914
Copy link
Contributor

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

…and setObjectSize.

The type of the variable returned by `getObjectSize` and set by
`setObjectSize` is uint64_t.
@llvmbot
Copy link
Member

llvmbot commented Jul 17, 2025

@llvm/pr-subscribers-backend-systemz

@llvm/pr-subscribers-llvm-selectiondag

Author: Jim Lin (tclin914)

Changes

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


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

4 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/MachineFrameInfo.h (+2-2)
  • (modified) llvm/lib/CodeGen/SanitizerBinaryMetadata.cpp (+1-1)
  • (modified) llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp (+1-1)
  • (modified) llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp (+1-1)
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 ||

@arsenm
Copy link
Contributor

arsenm commented Jul 17, 2025

Generally immediates are encoded as int64_t. If we change this to anything it should probably be TypeSize

@RKSimon RKSimon requested a review from topperc July 17, 2025 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants