Skip to content
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

[AsmPrinter] Increase upper bound for size in global structs #92334

Conversation

MaskRay
Copy link
Member

@MaskRay MaskRay commented May 16, 2024

This is part of the fixes to address #57353

https://reviews.llvm.org/D133845

Created using spr 1.3.5-bogner
@llvmbot
Copy link
Collaborator

llvmbot commented May 16, 2024

@llvm/pr-subscribers-backend-x86

Author: Fangrui Song (MaskRay)

Changes

This is part of the fixes to address #57353

https://reviews.llvm.org/D133845


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

2 Files Affected:

  • (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+1-1)
  • (added) llvm/test/CodeGen/X86/big-array-init.ll (+7)
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 869670d43a178..d50cdc4323ecf 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -3501,7 +3501,7 @@ static void emitGlobalConstantStruct(const DataLayout &DL,
                                      const Constant *BaseCV, uint64_t Offset,
                                      AsmPrinter::AliasMapTy *AliasList) {
   // Print the fields in successive locations. Pad to align if needed!
-  unsigned Size = DL.getTypeAllocSize(CS->getType());
+  uint64_t Size = DL.getTypeAllocSize(CS->getType());
   const StructLayout *Layout = DL.getStructLayout(CS->getType());
   uint64_t SizeSoFar = 0;
   for (unsigned I = 0, E = CS->getNumOperands(); I != E; ++I) {
diff --git a/llvm/test/CodeGen/X86/big-array-init.ll b/llvm/test/CodeGen/X86/big-array-init.ll
new file mode 100644
index 0000000000000..d4026901bfbf0
--- /dev/null
+++ b/llvm/test/CodeGen/X86/big-array-init.ll
@@ -0,0 +1,7 @@
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+
+; CHECK-LABEL: bad_int:
+; CHECK-NEXT: .long 1
+; CHECK-NEXT: .zero 4294967292
+; CHECK-NEXT: .size   bad_int, 4294967296
+@bad_int = global <{ i32, [1073741823 x i32] }> <{ i32 1, [1073741823 x i32] zeroinitializer }>, align 16

@MaskRay
Copy link
Member Author

MaskRay commented May 16, 2024

If approved, I'll manually merge this to credit @OfekShochat

Copy link
Collaborator

@efriedma-quic efriedma-quic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Created using spr 1.3.5-bogner
@MaskRay MaskRay merged commit 997eae3 into main May 16, 2024
3 of 4 checks passed
@MaskRay MaskRay deleted the users/MaskRay/spr/asmprinter-increase-upper-bound-for-size-in-global-structs branch May 16, 2024 21:41
@MaskRay
Copy link
Member Author

MaskRay commented May 16, 2024

Sorry, spr land changed the author. I will use git push for https://reviews.llvm.org/D133648

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.

None yet

4 participants