================
@@ -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.
----------------
melver wrote:

This ties the generic inliner to what Clang happens to emit at -O0 for one
attribute on particular ABIs ([2 x i64] on AArch64, field-wise stores on
x86-64). Other lowerings are silently not covered: sret returns (32-bit
targets, MSVC, non-trivially-copyable span types), a temporary filled by
memcpy, NRVO. The description should list these, since users will see the
fallback token there without explanation.

For forwarding one store to a load in the whole-value case,
FindAvailableLoadedValue() (llvm/Analysis/Loads.h) exists and respects
control flow within the block; please use it rather than a hand-written user
walk.

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