[llvm] [SDAG] Only apply sincos/frexp stack slot folding to IR pointers (PR #115346)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 7 14:26:18 PST 2024


================
@@ -2518,7 +2518,12 @@ bool SelectionDAG::expandMultipleResultFPLibCall(
     SDValue StoreValue = ST->getValue();
     unsigned ResNo = StoreValue.getResNo();
     Type *StoreType = StoreValue.getValueType().getTypeForEVT(Ctx);
-    if (CallRetResNo == ResNo || !ST->isSimple() ||
+    // If the pointer value does not come from the IR, it could come from ABI
+    // lowering and may alias with the arguments of the library call if they are
+    // passed via the stack.
----------------
efriedma-quic wrote:

If I'm understanding correctly, the issue here is that the store destination could be part of the argument list of another call?  The correct way to handle that case should involve callseq_start/callseq_end. Assuming the libcall isn't nested inside another callseq_start/end, there should be a callseq_end and a callseq_start between the libcall and the store.  And those nodes should prevent the transform because they "alias" the store.

Blanket ignoring all non-IR values maybe works for this particular case, but I don't think it solves aliasing in general.

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


More information about the llvm-commits mailing list