-
Notifications
You must be signed in to change notification settings - Fork 15.6k
ScheduleDAG: Clear registers on DEBUG_VALUE_LIST correctly. #173133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
ScheduleDAG: Clear registers on DEBUG_VALUE_LIST correctly. #173133
Conversation
Created using spr 1.3.6-beta.1
|
@llvm/pr-subscribers-llvm-selectiondag Author: Peter Collingbourne (pcc) ChangesPreviously we were unconditionally setting operand 0 to a register which Exposed by #172962. No test because I'm not sure how to test this on Full diff: https://github.com/llvm/llvm-project/pull/173133.diff 1 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
index 4f4fb9c759ad7..c66549235a8a0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
@@ -1083,7 +1083,13 @@ EmitSchedule(MachineBasicBlock::iterator &InsertPos) {
// The DBG_VALUE was referencing a value produced by a terminator. By
// moving the DBG_VALUE, the referenced value also needs invalidating.
- MI.getOperand(0).ChangeToRegister(0, false);
+ if (MI.isDebugValueList()) {
+ for (auto &Op : MI.operands())
+ if (Op.isReg())
+ Op.ChangeToRegister(0, false);
+ } else {
+ MI.getOperand(0).ChangeToRegister(0, false);
+ }
MI.moveBefore(&*FirstTerm);
}
}
|
| if (MI.isDebugValueList()) { | ||
| for (auto &Op : MI.operands()) | ||
| if (Op.isReg()) | ||
| Op.ChangeToRegister(0, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Op.ChangeToRegister(0, false); | |
| Op.ChangeToRegister(Register(), false); |
| if (Op.isReg()) | ||
| Op.ChangeToRegister(0, false); | ||
| } else { | ||
| MI.getOperand(0).ChangeToRegister(0, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| MI.getOperand(0).ChangeToRegister(0, false); | |
| MI.getOperand(0).ChangeToRegister(Register(), false); |
| // moving the DBG_VALUE, the referenced value also needs invalidating. | ||
| MI.getOperand(0).ChangeToRegister(0, false); | ||
| if (MI.isDebugValueList()) { | ||
| for (auto &Op : MI.operands()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| for (auto &Op : MI.operands()) | |
| for (MachineOperand &Op : MI.operands()) |
Previously we were unconditionally setting operand 0 to a register which
is the metadata operand with DEBUG_VALUE_LIST, which led to assertion
failures. DEBUG_VALUE_LIST register operands start with operand 2,
so enumerate them and clear any that are already registers.
Exposed by #172962. No test because I'm not sure how to test this on
its own.