diff options
author | Stephen Tozer <Stephen.Tozer@sony.com> | 2022-12-19 15:44:16 +0000 |
---|---|---|
committer | Stephen Tozer <Stephen.Tozer@Sony.com> | 2022-12-19 17:14:25 +0000 |
commit | 6d169089f64c2be5b5107a8efd0e7ac614b50f71 (patch) | |
tree | 240e717377251a79bcb746df87c37fe40b189b1d /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | ecfed0ab3413b620a925daa85d23b7cbec5d8c3b (diff) | |
download | llvm-6d169089f64c2be5b5107a8efd0e7ac614b50f71.zip llvm-6d169089f64c2be5b5107a8efd0e7ac614b50f71.tar.gz llvm-6d169089f64c2be5b5107a8efd0e7ac614b50f71.tar.bz2 |
[DebugInfo] Add function to test debug values for equivalence
This patch adds a new function that can be used to check all the
properties, other than the machine values, of a pair of debug values for
equivalence. This is done by folding the "directness" into the
expression, converting the expression to variadic form if it is not
already in that form, and then comparing directly. In a few places which
check whether two debug values are identical to see if their ranges can
be merged, this function will correctly identify cases where two debug
values are expressed differently but have the same meaning, allowing
those ranges to be correctly merged.
Differential Revision: https://reviews.llvm.org/D136173
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 271cd01..53e67225 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -674,6 +674,25 @@ bool MachineInstr::isIdenticalTo(const MachineInstr &Other, return true; } +bool MachineInstr::isEquivalentDbgInstr(const MachineInstr &Other) const { + if (!isDebugValue() || !Other.isDebugValue()) + return false; + if (getDebugLoc() != Other.getDebugLoc()) + return false; + if (getDebugVariable() != Other.getDebugVariable()) + return false; + if (getNumDebugOperands() != Other.getNumDebugOperands()) + return false; + for (unsigned OpIdx = 0; OpIdx < getNumDebugOperands(); ++OpIdx) + if (!getDebugOperand(OpIdx).isIdenticalTo(Other.getDebugOperand(OpIdx))) + return false; + if (!DIExpression::isEqualExpression( + getDebugExpression(), isIndirectDebugValue(), + Other.getDebugExpression(), Other.isIndirectDebugValue())) + return false; + return true; +} + const MachineFunction *MachineInstr::getMF() const { return getParent()->getParent(); } |