[PATCH] D146767: [NVPTX] Fix integer overflow affecting array size calculation.

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 24 10:35:47 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6a423ee34447: [NVPTX] Fix integer overflow affecting array size calculation. (authored by tra).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146767/new/

https://reviews.llvm.org/D146767

Files:
  llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  llvm/test/CodeGen/NVPTX/global-variable-big.ll


Index: llvm/test/CodeGen/NVPTX/global-variable-big.ll
===================================================================
--- llvm/test/CodeGen/NVPTX/global-variable-big.ll
+++ llvm/test/CodeGen/NVPTX/global-variable-big.ll
@@ -9,3 +9,10 @@
 ; (lsb) 0x0102'0304'0506...0F10 (msb)
 @gv = addrspace(1) externally_initialized global i128 21345817372864405881847059188222722561, align 16
 ; CHECK: .visible .global .align 16 .b8 gv[16] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
+
+; Make sure that we do not overflow on large number of elements.
+; CHECK-LABEL large_data
+; CHECK: .visible .global .align 1 .b8 large_data[4831838208]
+ at large_data = global [4831838208 x i8] zeroinitializer
+
+
Index: llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -1148,7 +1148,7 @@
       }
     }
   } else {
-    unsigned int ElementSize = 0;
+    uint64_t ElementSize = 0;
 
     // Although PTX has direct support for struct type and array type and
     // LLVM IR is very similar to PTX, the LLVM CodeGen does not support for


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146767.508154.patch
Type: text/x-patch
Size: 1188 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230324/7ccbab11/attachment.bin>


More information about the llvm-commits mailing list