[SLP] Explicit track required stacksave/alloca dependency
authorPhilip Reames <listmail@philipreames.com>
Sun, 20 Mar 2022 20:50:36 +0000 (13:50 -0700)
committerPhilip Reames <listmail@philipreames.com>
Sun, 20 Mar 2022 20:58:45 +0000 (13:58 -0700)
commitb7806c8b3764f04d02dc99b04f0cccff92e6c43e
treefa38ee3a151bdeea9f34a714d8cf3c438c46709f
parentc1a31ee65b3a2bf2b452febb99703b3fdfa43328
[SLP] Explicit track required stacksave/alloca dependency

The semantics of an inalloca alloca instruction requires that it not be reordered with a preceeding stacksave intrinsic call.  Unfortunately, there's no def/use edge or memory dependence edge.  (THe memory point is slightly subtle, but in general a new allocation can't alias with a call which executes strictly before it comes into existance.)

I'd tried to tackle this same case previously in 689babdf6, but the fix chosen there turned out to be incomplete.  As such, this change contains a fully revert of the first fix attempt.

This was noticed when investigating problems which surfaced with D118538, but this is definitely an existing bug.  This time around, I managed to reduce a couple of additional cases, including one which was being actively miscompiled even without the new scheduling change.  (See test diffs)

Compile time wise, we only spend extra time when seeing a stacksave (rare), and even then we walk the block at most once per schedule window extension.  Likely a non-issue.
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/stacksave-dependence.ll