This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo][X86] Fix handling of DBG_VALUE's in post-RA scheduler.
ClosedPublic

Authored by andrewng on Apr 6 2017, 5:27 AM.

Details

Summary

This patch fixes a bug with the updating of DBG_VALUE's in
BreakAntiDependencies. Previously, it would only attempt to update the first
DBG_VALUE following the instruction whose register is being changed,
potentially leaving DBG_VALUE's referring to the wrong register. Now the code
will attempt to update all DBG_VALUE's that immediately follow the instruction.

This issue was detected as a result of an optimized codegen difference with
"-g" where an X86 byte/word fixup was not performed due to a DBG_VALUE
referencing the wrong register.

Diff Detail

Repository
rL LLVM

Event Timeline

andrewng created this revision.Apr 6 2017, 5:27 AM
aprantl edited edge metadata.Apr 19 2017, 3:53 PM

Rather than scanning forward for DBG_VALUEs, is there a more systematic way to find them? E.g., by iterating over USEs? If not, doing it this way is probably fine.

test/CodeGen/X86/post-ra-sched-with-debug.mir
1 ↗(On Diff #94351)

I'm sure this testcase can be reduced further with some manual inlining.
The only variables being CHECKed are i and j.

181 ↗(On Diff #94351)

We probably can remove most of these attributes.

MatzeB accepted this revision.Apr 19 2017, 4:09 PM
MatzeB added a subscriber: MatzeB.

The change LGTM. The testcase is really long and will probably break easily if someone changes dependency breaking heuristics, so anything you can do to make it less complicated is apreciated!

lib/CodeGen/AntiDepBreaker.h
64–65 ↗(On Diff #94351)

This is not just an attempt, isn't it?

71–73 ↗(On Diff #94351)

You could use:

for (std::pair<MachineInstr *, MachineInstr *> P : make_range(DbgValues.crbegin(), DbgValues.crend)) { ... }
test/CodeGen/X86/post-ra-sched-with-debug.mir
1 ↗(On Diff #94351)

Please take a look at the "Simplifying MIR Files" documentation I wrote a few days ago:
http://llvm.org/docs/MIRLangRef.html#simplifying-mir-files

This revision is now accepted and ready to land.Apr 19 2017, 4:09 PM

Rather than scanning forward for DBG_VALUEs, is there a more systematic way to find them? E.g., by iterating over USEs? If not, doing it this way is probably fine.

I'm not sure as I'm still new to LLVM, but because these are physical registers, I don't think the USEs would work. But I agree that the current method doesn't seem so robust.

lib/CodeGen/AntiDepBreaker.h
64–65 ↗(On Diff #94351)

Yes, I will drop the "Attempt", as it's not really needed. I think I phrased it that way because the call to UpdateDbgValue may not actually do anything.

71–73 ↗(On Diff #94351)

OK, that makes sense as ranged for loops seems to be the way to go.

test/CodeGen/X86/post-ra-sched-with-debug.mir
1 ↗(On Diff #94351)

I will try to manually inline to see if it can be further reduced. I will also see if the MIR can be further simplified.

This revision was automatically updated to reflect the committed changes.