- 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.
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?