This is an archive of the discontinued LLVM Phabricator instance.

DBG_VALUE insertion for spills breaks bundles
AcceptedPublic

Authored by saurabhverma on Jan 9 2018, 7:32 AM.

Details

Summary
  • follow up from llvm-dev email thread, summary below **
  • Please note that this was discovered with a complex VLIW scheduling testcase in an out-of-tree target. I haven't managed to get an equivalent testcase for it with the upstream targets, but I am posting this patch to be taken up based on the fact that this error can (and does) result in inconsistent bundle flags and broken schedules. Even without the testcase, the code for DBG_VALUE insertion can be checked to see that this error can occur in the scenario described below **

http://lists.llvm.org/pipermail/llvm-dev/2018-January/120076.html

The insertion of DBG_VALUE instructions for spills does not seem to be handling insert locations inside bundles well. If the spill instruction is part of a bundle, the new DBG_VALUE is inserted after it, but does not have the bundling flags set. This essentially means that if we start with a set of bundled instructions:

MI1 [BundledSucc=true, BundledPred=false]
MI2 [BundledSucc=false, BundledPred=true]

Where MI1 is a spill, and MI2 is a different instruction, after ExtendRanges we end up with

MI1 [BundledSucc=true, BundledPred=false]
DBG_VALUE MI [BundledSucc=false, BundledPred=false]
MI2 [BundledSucc=false, BundledPred=true]

Since this happens after the final instruction scheduling, it results in broken schedules.
The patch checks if the DBG_VALUE node is inserted in the middle of a bundle and makes sure that its Bundle flags are set correctly, if so.

Diff Detail

Repository
rL LLVM

Event Timeline

saurabhverma created this revision.Jan 9 2018, 7:32 AM
saurabhverma edited the summary of this revision. (Show Details)
aprantl added inline comments.Jan 9 2018, 8:52 AM
lib/CodeGen/LiveDebugValues.cpp
676

If there is really no way to test this with in-tree targets, we should at the very least have a detailed comment here explaining why this is implemented this way. Could you please add a comment that explains the rationale like in the review description here?

Adding descriptive comment for the change

saurabhverma marked an inline comment as done.Jan 9 2018, 9:33 AM
aprantl accepted this revision.Jan 9 2018, 9:40 AM
aprantl added inline comments.
lib/CodeGen/LiveDebugValues.cpp
687

clang-format please

This revision is now accepted and ready to land.Jan 9 2018, 9:40 AM

I don't know if this makes any sense, but could we maybe test this by constructing a bundled spill in a MIR file for an in-tree target?

cc @thegameg

I don't know if this makes any sense, but could we maybe test this by constructing a bundled spill in a MIR file for an in-tree target?

cc @thegameg

Just noticed that we don't have any documentation on bundled instructions in MIRLangRef. Here is a patch: https://reviews.llvm.org/D41872.

Format fixes . Now passes clang-format

saurabhverma marked an inline comment as done.Jan 10 2018, 2:47 AM

Thanks for reviewing and approving the change. I don't have commit access so will request you to commit it please. I have taken care of the formatting and it now clears clang-format.

@saurabhverma have you looked into JDevlieghere's suggestion?

@saurabhverma have you looked into JDevlieghere's suggestion?

Hi @aprantl , Yes. that was the approach I had tried to generate the testcase, but did not have much success. Will give it another shot.

Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2023, 4:25 PM