[llvm-branch-commits] [llvm] [DirectX] Teach MemIntrinsics about structs and nested arrays (PR #173078)

Ashley Coleman via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Dec 22 10:13:28 PST 2025


================
@@ -109,6 +109,24 @@ static Type *getPointeeType(Value *Ptr, const DataLayout &DL) {
   llvm_unreachable("Could not calculate pointee type");
 }
 
+static size_t flattenTypes(Type *ContainerTy, const DataLayout &DL,
+                           SmallVectorImpl<std::pair<Type *, size_t>> &FlatTys,
+                           size_t NextOffset = 0) {
+  if (auto *AT = dyn_cast<ArrayType>(ContainerTy)) {
+    for (uint64_t I = 0, E = AT->getNumElements(); I != E; ++I)
+      NextOffset = flattenTypes(AT->getElementType(), DL, FlatTys, NextOffset);
+    return NextOffset;
----------------
V-FEXrt wrote:

its not really clear to me what is getting returned here. `NextOffset` seems to be an accumulator of sorts for the recursion but the early exit cases don't consider the value passed in and the non-exit case doesn't recurse

https://github.com/llvm/llvm-project/pull/173078


More information about the llvm-branch-commits mailing list