[llvm] [AsmPrinter] Increase upper bound for size in global structs (PR #92334)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu May 16 14:38:57 PDT 2024


https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/92334

>From 157f371f1c16e5053eb5fca6fefaa152f5c85a8d Mon Sep 17 00:00:00 2001
From: OfekShochat <ofeksh.oss at gmail.com>
Date: Wed, 15 May 2024 18:51:24 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5-bogner
---
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 +-
 llvm/test/CodeGen/X86/big-array-init.ll    | 7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 llvm/test/CodeGen/X86/big-array-init.ll

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
+ at bad_int = global <{ i32, [1073741823 x i32] }> <{ i32 1, [1073741823 x i32] zeroinitializer }>, align 16



More information about the llvm-commits mailing list