================
@@ -935,25 +935,80 @@ propagateMemProfMetadata(Function *Callee, CallBase &CB,
   }
 }
 
-/// Collect all calls that produce RetVal, following only pointer-preserving
-/// instructions (cast, phi, select).
-static void collectPointerReturningCalls(Value *RetVal,
-                                         SmallVectorImpl<CallBase *> &Out) {
+/// Returns true for a {begin pointer, size} pair. This is the only span shape
+/// returned by malloc_span functions whose begin pointer is known from the
+/// type: a {pointer, pointer} pair may be in either order, and a span coerced
+/// by the ABI (e.g. to [2 x i64] on AArch64) has no pointer field at all, so
+/// those are only followed when returned as a whole.
+static bool isPointerSizeSpan(Type *Ty) {
+  auto *STy = dyn_cast<StructType>(Ty);
+  return STy && STy->getNumElements() == 2 &&
+         STy->getElementType(0)->isPointerTy() &&
+         STy->getElementType(1)->isIntegerTy();
+}
+
+/// Collect the calls whose result RetVal returns, either as a whole or, for a
+/// {pointer, size} span, as its begin pointer. Follows casts, phis and
+/// selects; field 0 of such a span (extractvalue, insertvalue); and a local
+/// temporary the value is stored to at offset 0 and loaded from, as emitted
+/// for returned aggregates before SROA.
----------------
david-xl wrote:

Now uses FindAvailableLoadedValue. The unsupported lowerings (sret, memcpy'd 
temporaries, field-wise construction) are listed in the description.

https://github.com/llvm/llvm-project/pull/244314
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to