================
@@ -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
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to