Skip to content

Commit 8b70139

Browse files
committedSep 8, 2019
[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 llvm-svn: 371332
1 parent df2501a commit 8b70139

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed
 

‎llvm/include/llvm/CodeGen/TargetInstrInfo.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class TargetSubtargetInfo;
6060

6161
template <class T> class SmallVectorImpl;
6262

63-
using ParamLoadedValue = std::pair<const MachineOperand*, DIExpression*>;
63+
using ParamLoadedValue = std::pair<MachineOperand, DIExpression*>;
6464

6565
//---------------------------------------------------------------------------
6666
///

‎llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -655,12 +655,12 @@ static void collectCallSiteParameters(const MachineInstr *CallMI,
655655
unsigned Reg = Defs[0];
656656

657657
if (auto ParamValue = TII->describeLoadedValue(*I)) {
658-
if (ParamValue->first->isImm()) {
659-
unsigned Val = ParamValue->first->getImm();
658+
if (ParamValue->first.isImm()) {
659+
unsigned Val = ParamValue->first.getImm();
660660
DbgValueLoc DbgLocVal(ParamValue->second, Val);
661661
finishCallSiteParam(DbgLocVal, Reg);
662-
} else if (ParamValue->first->isReg()) {
663-
Register RegLoc = ParamValue->first->getReg();
662+
} else if (ParamValue->first.isReg()) {
663+
Register RegLoc = ParamValue->first.getReg();
664664
unsigned SP = TLI->getStackPointerRegisterToSaveRestore();
665665
Register FP = TRI->getFrameRegister(*MF);
666666
bool IsSPorFP = (RegLoc == SP) || (RegLoc == FP);

‎llvm/lib/CodeGen/TargetInstrInfo.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1129,10 +1129,10 @@ TargetInstrInfo::describeLoadedValue(const MachineInstr &MI) const {
11291129

11301130
if (isCopyInstr(MI, SrcRegOp, DestRegOp)) {
11311131
Op = SrcRegOp;
1132-
return ParamLoadedValue(Op, Expr);
1132+
return ParamLoadedValue(*Op, Expr);
11331133
} else if (MI.isMoveImmediate()) {
11341134
Op = &MI.getOperand(1);
1135-
return ParamLoadedValue(Op, Expr);
1135+
return ParamLoadedValue(*Op, Expr);
11361136
} else if (MI.hasOneMemOperand()) {
11371137
int64_t Offset;
11381138
const auto &TRI = MF->getSubtarget().getRegisterInfo();
@@ -1144,7 +1144,7 @@ TargetInstrInfo::describeLoadedValue(const MachineInstr &MI) const {
11441144

11451145
Expr = DIExpression::prepend(Expr, DIExpression::DerefAfter, Offset);
11461146
Op = BaseOp;
1147-
return ParamLoadedValue(Op, Expr);
1147+
return ParamLoadedValue(*Op, Expr);
11481148
}
11491149

11501150
return None;

‎llvm/lib/Target/X86/X86InstrInfo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -7545,7 +7545,7 @@ X86InstrInfo::describeLoadedValue(const MachineInstr &MI) const {
75457545
DIExpression::appendOffset(Ops, Offset);
75467546
Expr = DIExpression::get(MI.getMF()->getFunction().getContext(), Ops);
75477547

7548-
return ParamLoadedValue(Op, Expr);;
7548+
return ParamLoadedValue(*Op, Expr);;
75497549
}
75507550
default:
75517551
return TargetInstrInfo::describeLoadedValue(MI);

0 commit comments

Comments
 (0)