[PATCH] D109458: [NVPTX] Simplify and generalize constant printer.

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 8 13:50:43 PDT 2021


tra added inline comments.


================
Comment at: llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp:1756
   if (isa<UndefValue>(CPV) || CPV->isNullValue()) {
-    int s = DL.getTypeAllocSize(CPV->getType());
-    if (s < Bytes)
-      s = Bytes;
-    aggBuffer->addZeros(s);
+    AggBuffer->addZeros(std::max(AllocSize, Bytes));
     return;
----------------
This (and the original code) looks suspicious. Why would we allow filling in more bytes than we were told to by the caller?
I think this should've been an `assert(AllocSize <= Bytes); addZeroes(Bytes);`

Or it was a typo and the code should've read `if (s > Bytes) s = Bytes` essentially only filling up to Bytes, but no more.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109458



More information about the llvm-commits mailing list