mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[DebugInfo] Follow up c521e44defb5 with an API improvement
As mentioned post-commit in D85749, the 'substituteDebugValuesForInst' method added in c521e44defb5 would be better off with a limit on the number of operands to substitute. This handles the common case of "substitute the first operand between these two differing instructions", or possibly up to N first operands.
This commit is contained in:
parent
d345d7741b
commit
1d9d3c9eb5
@ -458,7 +458,11 @@ public:
|
|||||||
/// which has the same signature (i.e., def operands in the same place) but
|
/// which has the same signature (i.e., def operands in the same place) but
|
||||||
/// a modified instruction type, flags, or otherwise. An example: X86 moves
|
/// a modified instruction type, flags, or otherwise. An example: X86 moves
|
||||||
/// are sometimes transformed into equivalent LEAs.
|
/// are sometimes transformed into equivalent LEAs.
|
||||||
void substituteDebugValuesForInst(const MachineInstr &Old, MachineInstr &New);
|
/// If the two instructions are not the same opcode, limit which operands to
|
||||||
|
/// examine for substitutions to the first N operands by setting
|
||||||
|
/// \p MaxOperand.
|
||||||
|
void substituteDebugValuesForInst(const MachineInstr &Old, MachineInstr &New,
|
||||||
|
unsigned MaxOperand = UINT_MAX);
|
||||||
|
|
||||||
MachineFunction(Function &F, const LLVMTargetMachine &Target,
|
MachineFunction(Function &F, const LLVMTargetMachine &Target,
|
||||||
const TargetSubtargetInfo &STI, unsigned FunctionNum,
|
const TargetSubtargetInfo &STI, unsigned FunctionNum,
|
||||||
|
@ -955,7 +955,8 @@ void MachineFunction::makeDebugValueSubstitution(DebugInstrOperandPair A,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MachineFunction::substituteDebugValuesForInst(const MachineInstr &Old,
|
void MachineFunction::substituteDebugValuesForInst(const MachineInstr &Old,
|
||||||
MachineInstr &New) {
|
MachineInstr &New,
|
||||||
|
unsigned MaxOperand) {
|
||||||
// If the Old instruction wasn't tracked at all, there is no work to do.
|
// If the Old instruction wasn't tracked at all, there is no work to do.
|
||||||
unsigned OldInstrNum = Old.peekDebugInstrNum();
|
unsigned OldInstrNum = Old.peekDebugInstrNum();
|
||||||
if (!OldInstrNum)
|
if (!OldInstrNum)
|
||||||
@ -965,12 +966,16 @@ void MachineFunction::substituteDebugValuesForInst(const MachineInstr &Old,
|
|||||||
// Avoid creating new instr numbers unless we create a new substitution.
|
// Avoid creating new instr numbers unless we create a new substitution.
|
||||||
// While this has no functional effect, it risks confusing someone reading
|
// While this has no functional effect, it risks confusing someone reading
|
||||||
// MIR output.
|
// MIR output.
|
||||||
|
// Examine all the operands, or the first N specified by the caller.
|
||||||
|
MaxOperand = std::min(MaxOperand, Old.getNumOperands());
|
||||||
for (unsigned int I = 0; I < Old.getNumOperands(); ++I) {
|
for (unsigned int I = 0; I < Old.getNumOperands(); ++I) {
|
||||||
const auto &OldMO = Old.getOperand(I);
|
const auto &OldMO = Old.getOperand(I);
|
||||||
|
auto &NewMO = New.getOperand(I);
|
||||||
|
(void)NewMO;
|
||||||
|
|
||||||
if (!OldMO.isReg() || !OldMO.isDef())
|
if (!OldMO.isReg() || !OldMO.isDef())
|
||||||
continue;
|
continue;
|
||||||
assert(Old.getOperand(I).isDef());
|
assert(NewMO.isDef());
|
||||||
|
|
||||||
unsigned NewInstrNum = New.getDebugInstrNum();
|
unsigned NewInstrNum = New.getDebugInstrNum();
|
||||||
makeDebugValueSubstitution(std::make_pair(OldInstrNum, I),
|
makeDebugValueSubstitution(std::make_pair(OldInstrNum, I),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user