[PATCH] D122758: DataLayout::getPointerSize() should always return a power of 2

Stephen Neuendorffer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 12:35:43 PDT 2022


stephenneuendorffer retitled this revision from "DataLayout::getPointerSize() should always return a power of 2 (#89)" to "DataLayout::getPointerSize() should always return a power of 2".
stephenneuendorffer updated this revision to Diff 419247.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122758

Files:
  llvm/include/llvm/IR/DataLayout.h
  llvm/lib/IR/DataLayout.cpp


Index: llvm/lib/IR/DataLayout.cpp
===================================================================
--- llvm/lib/IR/DataLayout.cpp
+++ llvm/lib/IR/DataLayout.cpp
@@ -706,7 +706,7 @@
 }
 
 unsigned DataLayout::getPointerSize(unsigned AS) const {
-  return divideCeil(getPointerAlignElem(AS).TypeBitWidth, 8);
+  return PowerOf2Ceil(divideCeil(getPointerAlignElem(AS).TypeBitWidth, 8));
 }
 
 unsigned DataLayout::getMaxIndexSize() const {
Index: llvm/include/llvm/IR/DataLayout.h
===================================================================
--- llvm/include/llvm/IR/DataLayout.h
+++ llvm/include/llvm/IR/DataLayout.h
@@ -373,7 +373,7 @@
   /// the backends/clients are updated.
   Align getPointerPrefAlignment(unsigned AS = 0) const;
 
-  /// Layout pointer size in bytes, rounded up to a whole
+  /// Layout pointer size in bytes, rounded up to a power of 2
   /// number of bytes.
   /// FIXME: The defaults need to be removed once all of
   /// the backends/clients are updated.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122758.419247.patch
Type: text/x-patch
Size: 991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220330/b49ed0fc/attachment.bin>


More information about the llvm-commits mailing list