[PATCH] D139034: [IR] GEP: Fix byte-offsets in vectors of overaligned types

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 5 03:54:19 PST 2022


nikic added a comment.

I think the general idea behind this change is correct. Vectors should indeed be tightly packed and ignore ABI alignment of the element type.

However, I'm afraid that the patch in the current form will make the situation worse by introducing inconsistent treatment in different places. We have a lot more code that is repeating basically the same pattern (getAllocSize on the GTI indexed type). BasicAA would be an obvious example, but I see quite a few more uses spread over the codebase from a grep on `getTypeAllocSize(GTI`.

I think that ideally we would add a `gep_offset_iterator` which exposes the GEP as an addition of scaled multiplies and constants only and hides the type-related details. This can be used in most places and would give a central place to update the offset calculation logic.



================
Comment at: llvm/lib/Transforms/Scalar/SROA.cpp:1542
+  }
+#endif
+
----------------
This entire function is unused if opaque pointers are used, so I don't think it makes much sense to add this assertion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139034



More information about the llvm-commits mailing list