While investigating LLVM PR22316
http://llvm.org/bugs/show_bug.cgi?id=22316
I started wondering if it were not always preferable to emit the initial DBG_VALUEs for stack arguments as FI locations instead of describing the first register they get copied into. The advantage of doing this is that the arguments will be available as soon as the stack is setup. As illustrated by the testcase in the PR, the first copy of the FI into a register may be sunk by MachineSink.cpp into a later basic block. By describing the argument on the stack, we nicely circumvent this problem.
The COFF testcase change is the only testcase that broke with this change. Apparently it causes the order of the instructions in this function to get reshuffled without any functional change.
This breaks the test case, though, now it isn't shrink-wrapped. That indicates that DBG_VALUE instructions change the codegen of shrink-wrapping. =(
We probably just need to skip DBG_VALUE instructions when doing the shrink-wrapping analysis.