This is an archive of the discontinued LLVM Phabricator instance.

EmitFuncArgumentDbgValue: Prefer stack slots over registers for stack arguments
ClosedPublic

Authored by aprantl on Dec 12 2017, 2:27 PM.

Details

Summary

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.

Diff Detail

Event Timeline

aprantl created this revision.Dec 12 2017, 2:27 PM
davide added a subscriber: davide.Dec 12 2017, 2:30 PM
aprantl updated this revision to Diff 126631.Dec 12 2017, 2:30 PM

Add context to diff.

rnk added inline comments.Dec 12 2017, 5:29 PM
test/DebugInfo/COFF/fpo-shrink-wrap.ll
16

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.

aprantl added inline comments.Dec 12 2017, 5:48 PM
test/DebugInfo/COFF/fpo-shrink-wrap.ll
16

Oh! Good catch. That's I bug I should fix regardless!

rnk accepted this revision.Dec 14 2017, 10:36 AM

lgtm

This revision is now accepted and ready to land.Dec 14 2017, 10:36 AM
This revision was automatically updated to reflect the committed changes.