[PATCH] D61432: Non-8-bit bytes showcase

Daniel C Hood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 18 14:20:34 PDT 2019


Daniel added inline comments.


================
Comment at: include/llvm/IR/DataLayout.h:421
   unsigned getPointerTypeSize(Type *Ty) const {
-    return getPointerTypeSizeInBits(Ty) / 8;
+    return getPointerTypeSizeInBits(Ty) / BitsPerByte;
   }
----------------
JesperAntonsson wrote:
> probinson wrote:
> > riccibruno wrote:
> > > That's an expensive division...
> > Maybe derive a pointer-type-size-in-bytes calculated in the ctor.
> > Or, as a more generic solution, derive shift/mask values from bits-per-byte, so the refactoring can replace multiply/divide with shifts.  Or maybe with bitsToBytes and bytesToBits helper methods.
> Yes, or we could perhaps make this a static constant in DataLayout and, for now, leave it to downstream target to make it a variable.
This looks fine as long as performance doesn't get worse after refactor. I don't see a performance hit here.


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

https://reviews.llvm.org/D61432





More information about the llvm-commits mailing list