Cleaned up a little bit of redundant code in 'frame diagnose.`

llvm-svn: 281534
diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index b37ac7a..eb49724 100644
--- a/lldb/source/Target/StackFrame.cpp
+++ b/lldb/source/Target/StackFrame.cpp
@@ -1492,6 +1492,12 @@
 
   using namespace OperandMatchers;
 
+  const RegisterInfo *reg_info =
+      frame.GetRegisterContext()->GetRegisterInfoByName(reg.AsCString());
+  if (!reg_info) {
+    return ValueObjectSP();
+  }
+
   Instruction::Operand op =
       offset ? Instruction::Operand::BuildDereference(
                    Instruction::Operand::BuildSum(
@@ -1517,9 +1523,9 @@
 
   for (uint32_t ii = current_inst - 1; ii != (uint32_t)-1; --ii) {
     // This is not an exact algorithm, and it sacrifices accuracy for
-    // generality.
-    // Recognizing "mov" and "ld" instructions –– and which are their source and
-    // destination operands -- is something the disassembler should do for us.
+    // generality.  Recognizing "mov" and "ld" instructions –– and which are
+    // their source and destination operands -- is something the disassembler
+    // should do for us.
     InstructionSP instruction_sp =
         disassembler.GetInstructionList().GetInstructionAtIndex(ii);
 
@@ -1602,16 +1608,18 @@
     }
 
     Instruction::Operand *origin_operand = nullptr;
-    if (operands[0].m_type == Instruction::Operand::Type::Register &&
-        operands[0].m_clobbered == true && operands[0].m_register == reg) {
-      // operands[0] is a register operand
+    std::function<bool(const Instruction::Operand &)> clobbered_reg_matcher =
+        [reg_info](const Instruction::Operand &op) {
+          return MatchRegOp(*reg_info)(op) && op.m_clobbered;
+        };
+
+    if (clobbered_reg_matcher(operands[0])) {
       origin_operand = &operands[1];
-    } else if (operands[1].m_type == Instruction::Operand::Type::Register &&
-               operands[1].m_clobbered == true &&
-               operands[1].m_register == reg) {
+    }
+    else if (clobbered_reg_matcher(operands[1])) {
       origin_operand = &operands[0];
-      // operands[1] is a register operand
-    } else {
+    }
+    else {
       continue;
     }