[llvm] r371332 - [NFC] Make the describeLoadedValue() hook return machine operand objects

David Stenberg via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 8 07:05:11 PDT 2019


Author: dstenb
Date: Sun Sep  8 07:05:10 2019
New Revision: 371332

URL: http://llvm.org/viewvc/llvm-project?rev=371332&view=rev
Log:
[NFC] Make the describeLoadedValue() hook return machine operand objects

Summary:
This changes the ParamLoadedValue pair which the describeLoadedValue()
hook returns so that MachineOperand objects are returned instead of
pointers.

When describing call site values we may need to describe operands which
are not part of the instruction. One such example is zero-materializing
XORs on x86, which I have implemented support for in a child revision.
Instead of having to return a pointer to an operand stored somewhere
outside the instruction, start returning objects directly instead, as
that simplifies the code.

The MachineOperand class only holds POD members, and on x86-64 it is 32
bytes large. That combined with copy elision means that the overhead of
returning a machine operand object from the hook does not become very
large.

I benchmarked this on a 8-thread i7-8650U machine with 32 GB RAM. The
benchmark consisted of building a clang 8.0 binary configured with:

  -DCMAKE_BUILD_TYPE=RelWithDebInfo \
  -DLLVM_TARGETS_TO_BUILD=X86 \
  -DLLVM_USE_SANITIZER=Address \
  -DCMAKE_CXX_FLAGS="-Xclang -femit-debug-entry-values -stdlib=libc++"

The average wall clock time increased by 4 seconds, from 62:05 to
62:09, which is an 0.1% increase.

Reviewers: aprantl, vsk, djtodoro, NikolaPrica

Reviewed By: vsk

Subscribers: hiraditya, ychen, llvm-commits

Tags: #debug-info, #llvm

Differential Revision: https://reviews.llvm.org/D67261

Modified:
    llvm/trunk/include/llvm/CodeGen/TargetInstrInfo.h
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp
    llvm/trunk/lib/Target/X86/X86InstrInfo.cpp

Modified: llvm/trunk/include/llvm/CodeGen/TargetInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/TargetInstrInfo.h?rev=371332&r1=371331&r2=371332&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/TargetInstrInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/TargetInstrInfo.h Sun Sep  8 07:05:10 2019
@@ -60,7 +60,7 @@ class TargetSubtargetInfo;
 
 template <class T> class SmallVectorImpl;
 
-using ParamLoadedValue = std::pair<const MachineOperand*, DIExpression*>;
+using ParamLoadedValue = std::pair<MachineOperand, DIExpression*>;
 
 //---------------------------------------------------------------------------
 ///

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=371332&r1=371331&r2=371332&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Sun Sep  8 07:05:10 2019
@@ -655,12 +655,12 @@ static void collectCallSiteParameters(co
     unsigned Reg = Defs[0];
 
     if (auto ParamValue = TII->describeLoadedValue(*I)) {
-      if (ParamValue->first->isImm()) {
-        unsigned Val = ParamValue->first->getImm();
+      if (ParamValue->first.isImm()) {
+        unsigned Val = ParamValue->first.getImm();
         DbgValueLoc DbgLocVal(ParamValue->second, Val);
         finishCallSiteParam(DbgLocVal, Reg);
-      } else if (ParamValue->first->isReg()) {
-        Register RegLoc = ParamValue->first->getReg();
+      } else if (ParamValue->first.isReg()) {
+        Register RegLoc = ParamValue->first.getReg();
         unsigned SP = TLI->getStackPointerRegisterToSaveRestore();
         Register FP = TRI->getFrameRegister(*MF);
         bool IsSPorFP = (RegLoc == SP) || (RegLoc == FP);

Modified: llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp?rev=371332&r1=371331&r2=371332&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetInstrInfo.cpp Sun Sep  8 07:05:10 2019
@@ -1129,10 +1129,10 @@ TargetInstrInfo::describeLoadedValue(con
 
   if (isCopyInstr(MI, SrcRegOp, DestRegOp)) {
     Op = SrcRegOp;
-    return ParamLoadedValue(Op, Expr);
+    return ParamLoadedValue(*Op, Expr);
   } else if (MI.isMoveImmediate()) {
     Op = &MI.getOperand(1);
-    return ParamLoadedValue(Op, Expr);
+    return ParamLoadedValue(*Op, Expr);
   } else if (MI.hasOneMemOperand()) {
     int64_t Offset;
     const auto &TRI = MF->getSubtarget().getRegisterInfo();
@@ -1144,7 +1144,7 @@ TargetInstrInfo::describeLoadedValue(con
 
     Expr = DIExpression::prepend(Expr, DIExpression::DerefAfter, Offset);
     Op = BaseOp;
-    return ParamLoadedValue(Op, Expr);
+    return ParamLoadedValue(*Op, Expr);
   }
 
   return None;

Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=371332&r1=371331&r2=371332&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Sun Sep  8 07:05:10 2019
@@ -7545,7 +7545,7 @@ X86InstrInfo::describeLoadedValue(const
     DIExpression::appendOffset(Ops, Offset);
     Expr = DIExpression::get(MI.getMF()->getFunction().getContext(), Ops);
 
-    return ParamLoadedValue(Op, Expr);;
+    return ParamLoadedValue(*Op, Expr);;
   }
   default:
     return TargetInstrInfo::describeLoadedValue(MI);




More information about the llvm-commits mailing list