llvm.org GIT mirror llvm / 24d43bb
Revert "[DwarfDebug] Dump call site debug info" A build failure was found on the SystemZ platform. This reverts commit 9e7e73578e54cd22b3c7af4b54274d743b6607cc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@365886 91177308-0d34-0410-b5e6-96231b3b80d8 Djordje Todorovic a month ago
23 changed file(s) with 56 addition(s) and 1105 deletion(s). Raw diff Collapse all Expand all
47644764 ``DW_OP_entry_value`` may also appear after the ``AsmPrinter`` pass when
47654765 a call site parameter value (``DW_AT_call_site_parameter_value``)
47664766 is represented as entry value of the parameter.
4767 - ``DW_OP_reg`` (or ``DW_OP_regx``) represents a physical register location.
4768 The opcode is only generated by the ``AsmPrinter`` pass to describe
4769 call site parameter value which requires an expression over two registers.
47704767
47714768 DWARF specifies three kinds of simple location descriptions: Register, memory,
47724769 and implicit location descriptions. Note that a location description is
5959
6060 template class SmallVectorImpl;
6161
62 using ParamLoadedValue = std::pair;
63
6462 //---------------------------------------------------------------------------
6563 ///
6664 /// TargetInstrInfo - Interface to description of machine instruction set
16921690 return false;
16931691 }
16941692
1695 /// Produce RHS description of parameter's loading instruction \p MI.
1696 virtual Optional
1697 describeLoadedValue(const MachineInstr &MI) const;
1698
16991693 private:
17001694 unsigned CallFrameSetupOpcode, CallFrameDestroyOpcode;
17011695 unsigned CatchRetOpcode;
530530 /// prior to a call and is guaranteed to be restored (also by the caller)
531531 /// after the call.
532532 virtual bool isCallerPreservedPhysReg(unsigned PhysReg,
533 const MachineFunction &MF) const;
533 const MachineFunction &MF) const {
534 return false;
535 }
534536
535537 /// Prior to adding the live-out mask to a stackmap or patchpoint
536538 /// instruction, provide the target the opportunity to adjust it (mainly to
889889 ContextCU->addDIEEntry(*AbsDef, dwarf::DW_AT_object_pointer, *ObjectPointer);
890890 }
891891
892 dwarf::Tag DwarfCompileUnit::getDwarf5OrGNUCallSiteTag(dwarf::Tag Tag) {
893 bool ApplyGNUExtensions = DD->getDwarfVersion() == 4 && DD->tuneForGDB();
894 if (!ApplyGNUExtensions)
895 return Tag;
896 switch (Tag) {
897 case dwarf::DW_TAG_call_site:
898 return dwarf::DW_TAG_GNU_call_site;
899 case dwarf::DW_TAG_call_site_parameter:
900 return dwarf::DW_TAG_GNU_call_site_parameter;
901 default:
902 llvm_unreachable("unhandled call site tag");
903 }
904 }
905
906 dwarf::Attribute
907 DwarfCompileUnit::getDwarf5OrGNUCallSiteAttr(dwarf::Attribute Attr) {
908 bool ApplyGNUExtensions = DD->getDwarfVersion() == 4 && DD->tuneForGDB();
909 if (!ApplyGNUExtensions)
910 return Attr;
911 switch (Attr) {
912 case dwarf::DW_AT_call_all_calls:
913 return dwarf::DW_AT_GNU_all_call_sites;
914 case dwarf::DW_AT_call_target:
915 return dwarf::DW_AT_GNU_call_site_target;
916 case dwarf::DW_AT_call_origin:
917 return dwarf::DW_AT_abstract_origin;
918 case dwarf::DW_AT_call_pc:
919 return dwarf::DW_AT_low_pc;
920 case dwarf::DW_AT_call_value:
921 return dwarf::DW_AT_GNU_call_site_value;
922 case dwarf::DW_AT_call_tail_call:
923 return dwarf::DW_AT_GNU_tail_call;
924 default:
925 llvm_unreachable("unhandled call site attribute");
926 }
927 }
928
929 DIE &DwarfCompileUnit::constructCallSiteEntryDIE(
930 DIE &ScopeDIE, const DISubprogram *CalleeSP, bool IsTail,
931 const MCSymbol *PCAddr, const MCExpr *PCOffset, unsigned CallReg) {
892 DIE &DwarfCompileUnit::constructCallSiteEntryDIE(DIE &ScopeDIE,
893 const DISubprogram &CalleeSP,
894 bool IsTail,
895 const MCExpr *PCOffset) {
932896 // Insert a call site entry DIE within ScopeDIE.
933 DIE &CallSiteDIE = createAndAddDIE(
934 getDwarf5OrGNUCallSiteTag(dwarf::DW_TAG_call_site), ScopeDIE, nullptr);
935
936 if (CallReg) {
937 // Indirect call.
938 addAddress(CallSiteDIE,
939 getDwarf5OrGNUCallSiteAttr(dwarf::DW_AT_call_target),
940 MachineLocation(CallReg));
897 DIE &CallSiteDIE =
898 createAndAddDIE(dwarf::DW_TAG_call_site, ScopeDIE, nullptr);
899
900 // For the purposes of showing tail call frames in backtraces, a key piece of
901 // information is DW_AT_call_origin, a pointer to the callee DIE.
902 DIE *CalleeDIE = getOrCreateSubprogramDIE(&CalleeSP);
903 assert(CalleeDIE && "Could not create DIE for call site entry origin");
904 addDIEEntry(CallSiteDIE, dwarf::DW_AT_call_origin, *CalleeDIE);
905
906 if (IsTail) {
907 // Attach DW_AT_call_tail_call to tail calls for standards compliance.
908 addFlag(CallSiteDIE, dwarf::DW_AT_call_tail_call);
941909 } else {
942 DIE *CalleeDIE = getOrCreateSubprogramDIE(CalleeSP);
943 assert(CalleeDIE && "Could not create DIE for call site entry origin");
944 addDIEEntry(CallSiteDIE,
945 getDwarf5OrGNUCallSiteAttr(dwarf::DW_AT_call_origin),
946 *CalleeDIE);
947 }
948
949 if (IsTail)
950 // Attach DW_AT_call_tail_call to tail calls for standards compliance.
951 addFlag(CallSiteDIE,
952 getDwarf5OrGNUCallSiteAttr(dwarf::DW_AT_call_tail_call));
953
954 // Attach the return PC to allow the debugger to disambiguate call paths
955 // from one function to another.
956 if (DD->getDwarfVersion() == 4 && DD->tuneForGDB()) {
957 assert(PCAddr && "Missing PC information for a call");
958 addLabelAddress(CallSiteDIE, dwarf::DW_AT_low_pc, PCAddr);
959 } else if (!IsTail || DD->tuneForGDB()) {
910 // Attach the return PC to allow the debugger to disambiguate call paths
911 // from one function to another.
960912 assert(PCOffset && "Missing return PC information for a call");
961913 addAddressExpr(CallSiteDIE, dwarf::DW_AT_call_return_pc, PCOffset);
962914 }
963
964915 return CallSiteDIE;
965 }
966
967 void DwarfCompileUnit::constructCallSiteParmEntryDIEs(
968 DIE &CallSiteDIE, SmallVector &Params) {
969 for (auto &Param : Params) {
970 unsigned Register = Param.getRegister();
971 auto CallSiteDieParam =
972 DIE::get(DIEValueAllocator,
973 getDwarf5OrGNUCallSiteTag(dwarf::DW_TAG_call_site_parameter));
974 insertDIE(CallSiteDieParam);
975 addAddress(*CallSiteDieParam, dwarf::DW_AT_location,
976 MachineLocation(Register));
977
978 DIELoc *Loc = new (DIEValueAllocator) DIELoc;
979 DIEDwarfExpression DwarfExpr(*Asm, *this, *Loc);
980 DwarfExpr.setCallSiteParamValueFlag();
981
982 DwarfDebug::emitDebugLocValue(*Asm, nullptr, Param.getValue(), DwarfExpr);
983
984 addBlock(*CallSiteDieParam,
985 getDwarf5OrGNUCallSiteAttr(dwarf::DW_AT_call_value),
986 DwarfExpr.finalize());
987
988 CallSiteDIE.addChild(CallSiteDieParam);
989 }
990916 }
991917
992918 DIE *DwarfCompileUnit::constructImportedEntityDIE(
226226
227227 void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
228228
229 dwarf::Tag getDwarf5OrGNUCallSiteTag(dwarf::Tag Tag);
230 dwarf::Attribute getDwarf5OrGNUCallSiteAttr(dwarf::Attribute Attr);
231
232229 /// Construct a call site entry DIE describing a call within \p Scope to a
233230 /// callee described by \p CalleeSP. \p IsTail specifies whether the call is
234 /// a tail call. \p PCAddr (used for GDB + DWARF 4 tuning) points to
235 /// the PC value after the call instruction. \p PCOffset (used for
236 /// cases other than GDB + DWARF 4 tuning) must be non-zero for non-tail calls
237 /// (in the case of non-gdb tuning) or be the function-local offset to PC value
238 /// after the call instruction. \p CallReg is a register location
239 /// for an indirect call.
240 DIE &constructCallSiteEntryDIE(DIE &ScopeDIE, const DISubprogram *CalleeSP,
241 bool IsTail, const MCSymbol *PCAddr,
242 const MCExpr *PCOffset, unsigned CallReg);
243 void constructCallSiteParmEntryDIEs(DIE &CallSiteDIE,
244 SmallVector &Params);
231 /// a tail call. \p PCOffset must be non-zero for non-tail calls or be the
232 /// function-local offset to PC value after the call instruction.
233 DIE &constructCallSiteEntryDIE(DIE &ScopeDIE, const DISubprogram &CalleeSP,
234 bool IsTail, const MCExpr *PCOffset);
245235
246236 /// Construct import_module DIE.
247237 DIE *constructImportedEntityDIE(const DIImportedEntity *Module);
2525 #include "llvm/ADT/STLExtras.h"
2626 #include "llvm/ADT/SmallVector.h"
2727 #include "llvm/ADT/StringRef.h"
28 #include "llvm/ADT/Statistic.h"
2928 #include "llvm/ADT/Triple.h"
3029 #include "llvm/ADT/Twine.h"
3130 #include "llvm/BinaryFormat/Dwarf.h"
3938 #include "llvm/CodeGen/MachineModuleInfo.h"
4039 #include "llvm/CodeGen/MachineOperand.h"
4140 #include "llvm/CodeGen/TargetInstrInfo.h"
42 #include "llvm/CodeGen/TargetLowering.h"
4341 #include "llvm/CodeGen/TargetRegisterInfo.h"
4442 #include "llvm/CodeGen/TargetSubtargetInfo.h"
4543 #include "llvm/DebugInfo/DWARF/DWARFExpression.h"
8482
8583 #define DEBUG_TYPE "dwarfdebug"
8684
87 STATISTIC(NumCSParams, "Number of dbg call site params created");
88
8985 static cl::opt
9086 DisableDebugInfoPrinting("disable-debug-info-print", cl::Hidden,
9187 cl::desc("Disable debug info printing"));
554550 }
555551 }
556552
557 /// Try to interpret values loaded into registers that forward parameters
558 /// for \p CallMI. Store parameters with interpreted value into \p Params.
559 static void collectCallSiteParameters(const MachineInstr *CallMI,
560 ParamSet &Params) {
561 auto *MF = CallMI->getMF();
562 auto CalleesMap = MF->getCallSitesInfo();
563 auto CallFwdRegsInfo = CalleesMap.find(CallMI);
564
565 // There is no information for the call instruction.
566 if (CallFwdRegsInfo == CalleesMap.end())
567 return;
568
569 auto *MBB = CallMI->getParent();
570 const auto &TRI = MF->getSubtarget().getRegisterInfo();
571 const auto &TII = MF->getSubtarget().getInstrInfo();
572 const auto &TLI = MF->getSubtarget().getTargetLowering();
573
574 // Skip the call instruction.
575 auto I = std::next(CallMI->getReverseIterator());
576
577 DenseSet ArgsRegsForProcess;
578 for (auto ArgReg : CallFwdRegsInfo->second)
579 ArgsRegsForProcess.insert(ArgReg.Reg);
580
581 // If we did not find loading a value into forwarding registers
582 // that means we can try generating 'DW_OP_entry_value' for the argument
583 // if a call is within entry MBB.
584 DenseMap RegsForEntryValues;
585 bool ShouldTryEmitEntryVals = MBB->getIterator() == MF->begin();
586
587 // Return true if it is an instruction over a parameter's forwarding
588 // register that clobbers it.
589 auto shouldInterpret = [&](const MachineInstr &MI) -> unsigned {
590 if (MI.isDebugInstr())
591 return 0;
592 // If a MI clobbers a forwarding reg try to interpret
593 // a value loaded into the reg.
594 for (const MachineOperand &MO : MI.operands()) {
595 if (MO.isReg() && MO.isDef() && MO.getReg() &&
596 TRI->isPhysicalRegister(MO.getReg())) {
597 for (auto FwdReg : ArgsRegsForProcess)
598 if (TRI->regsOverlap(FwdReg, MO.getReg()))
599 return FwdReg;
600 }
601 }
602
603 return 0;
604 };
605
606 auto finishCallSiteParam = [&](DbgValueLoc &DbgLocVal, unsigned &Reg) {
607 unsigned FwdReg = Reg;
608 if (ShouldTryEmitEntryVals && RegsForEntryValues.count(Reg))
609 FwdReg = RegsForEntryValues[Reg];
610 DbgCallSiteParam CSParm(FwdReg, DbgLocVal);
611 Params.push_back(CSParm);
612 NumCSParams++;
613 };
614
615 // Search for a loading value in forwaring registers.
616 while (I != MBB->rend()) {
617 // If the next instruction is a call we can not
618 // interpret parameter's forwarding registers or
619 // we finished interpretation of all parameters.
620 if (I->isCall())
621 return;
622
623 if (ArgsRegsForProcess.empty())
624 return;
625
626 if (unsigned Reg = shouldInterpret(*I)) {
627 ArgsRegsForProcess.erase(Reg);
628 const MachineOperand *Op;
629 DIExpression *Expr;
630 if (auto ParamValue = TII->describeLoadedValue(*I)) {
631 Op = ParamValue->first;
632 Expr = ParamValue->second;
633 if (Op->isImm()) {
634 unsigned Val = Op->getImm();
635 DbgValueLoc DbgLocVal(Expr, Val);
636 finishCallSiteParam(DbgLocVal, Reg);
637 } else if (Op->isReg()) {
638 unsigned RegLoc = Op->getReg();
639 unsigned SP = TLI->getStackPointerRegisterToSaveRestore();
640 unsigned FP = TRI->getFrameRegister(*MF);
641 bool IsSPorFP = (RegLoc == SP) || (RegLoc == FP);
642 if (TRI->isCallerPreservedPhysReg(RegLoc, *MF) || IsSPorFP) {
643 DbgValueLoc DbgLocVal(Expr, MachineLocation(RegLoc, IsSPorFP));
644 finishCallSiteParam(DbgLocVal, Reg);
645 } else if (ShouldTryEmitEntryVals) {
646 ArgsRegsForProcess.insert(RegLoc);
647 RegsForEntryValues[RegLoc] = Reg;
648 }
649 }
650 }
651 }
652
653 ++I;
654 }
655
656 // Emit call site parameter's value as entry value.
657 if (ShouldTryEmitEntryVals) {
658 DIExpression *EntryExpr = DIExpression::get(MF->getFunction().getContext(),
659 {dwarf::DW_OP_entry_value, 1});
660 for (auto RegEntry : ArgsRegsForProcess) {
661 unsigned FwdReg = RegsForEntryValues.count(RegEntry)
662 ? RegsForEntryValues[RegEntry]
663 : RegEntry;
664 DbgValueLoc DbgLocVal(EntryExpr, MachineLocation(RegEntry));
665 DbgCallSiteParam CSParm(FwdReg, DbgLocVal);
666 Params.push_back(CSParm);
667 NumCSParams++;
668 }
669 }
670 }
671
672553 void DwarfDebug::constructCallSiteEntryDIEs(const DISubprogram &SP,
673554 DwarfCompileUnit &CU, DIE &ScopeDIE,
674555 const MachineFunction &MF) {
681562 // for both tail and non-tail calls. Don't use DW_AT_call_all_source_calls
682563 // because one of its requirements is not met: call site entries for
683564 // optimized-out calls are elided.
684 CU.addFlag(ScopeDIE,
685 CU.getDwarf5OrGNUCallSiteAttr(dwarf::DW_AT_call_all_calls));
565 CU.addFlag(ScopeDIE, dwarf::DW_AT_call_all_calls);
686566
687567 const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
688568 assert(TII && "TargetInstrInfo not found: cannot label tail calls");
689 bool ApplyGNUExtensions = getDwarfVersion() == 4 && tuneForGDB();
690569
691570 // Emit call site entries for each call or tail call in the function.
692571 for (const MachineBasicBlock &MBB : MF) {
701580 return;
702581
703582 // If this is a direct call, find the callee's subprogram.
704 // In the case of an indirect call find the register that holds
705 // the callee.
706583 const MachineOperand &CalleeOp = MI.getOperand(0);
707 if (!CalleeOp.isGlobal() && !CalleeOp.isReg())
584 if (!CalleeOp.isGlobal())
708585 continue;
709
710 unsigned CallReg = 0;
711 const DISubprogram *CalleeSP = nullptr;
712 const Function *CalleeDecl = nullptr;
713 if (CalleeOp.isReg()) {
714 CallReg = CalleeOp.getReg();
715 if (!CallReg)
716 continue;
717 } else {
718 CalleeDecl = dyn_cast(CalleeOp.getGlobal());
719 if (!CalleeDecl || !CalleeDecl->getSubprogram())
720 continue;
721 CalleeSP = CalleeDecl->getSubprogram();
722 }
586 const Function *CalleeDecl = dyn_cast(CalleeOp.getGlobal());
587 if (!CalleeDecl || !CalleeDecl->getSubprogram())
588 continue;
723589
724590 // TODO: Omit call site entries for runtime calls (objc_msgSend, etc).
591 // TODO: Add support for indirect calls.
725592
726593 bool IsTail = TII->isTailCall(MI);
727594
728 // For tail calls, for non-gdb tuning, no return PC information is needed.
729 // For regular calls (and tail calls in GDB tuning), the return PC
730 // is needed to disambiguate paths in the call graph which could lead to
731 // some target function.
595 // For tail calls, no return PC information is needed. For regular calls,
596 // the return PC is needed to disambiguate paths in the call graph which
597 // could lead to some target function.
732598 const MCExpr *PCOffset =
733 (IsTail && !tuneForGDB()) ? nullptr
734 : getFunctionLocalOffsetAfterInsn(&MI);
735
736 // Address of a call-like instruction for a normal call or a jump-like
737 // instruction for a tail call. This is needed for GDB + DWARF 4 tuning.
738 const MCSymbol *PCAddr =
739 ApplyGNUExtensions ? const_cast(getLabelAfterInsn(&MI))
740 : nullptr;
741
742 assert((IsTail || PCOffset || PCAddr) &&
743 "Call without return PC information");
744
599 IsTail ? nullptr : getFunctionLocalOffsetAfterInsn(&MI);
600
601 assert((IsTail || PCOffset) && "Call without return PC information");
745602 LLVM_DEBUG(dbgs() << "CallSiteEntry: " << MF.getName() << " -> "
746 << (CalleeDecl ? CalleeDecl->getName()
747 : StringRef(MF.getSubtarget()
748 .getRegisterInfo()
749 ->getName(CallReg)))
750 << (IsTail ? " [IsTail]" : "") << "\n");
751
752 DIE &CallSiteDIE =
753 CU.constructCallSiteEntryDIE(ScopeDIE, CalleeSP, IsTail, PCAddr,
754 PCOffset, CallReg);
755
756 // For now only GDB supports call site parameter debug info.
757 if (Asm->TM.Options.EnableDebugEntryValues &&
758 tuneForGDB()) {
759 ParamSet Params;
760 // Try to interpret values of call site parameters.
761 collectCallSiteParameters(&MI, Params);
762 CU.constructCallSiteParmEntryDIEs(CallSiteDIE, Params);
763 }
603 << CalleeDecl->getName() << (IsTail ? " [tail]" : "")
604 << "\n");
605 CU.constructCallSiteEntryDIE(ScopeDIE, *CalleeDecl->getSubprogram(),
606 IsTail, PCOffset);
764607 }
765608 }
766609 }
253253 }
254254 };
255255
256 /// Used for tracking debug info about call site parameters.
257 class DbgCallSiteParam {
258 private:
259 unsigned Register;
260 DbgValueLoc Value;
261 public:
262 DbgCallSiteParam(unsigned Reg, DbgValueLoc Val)
263 : Register(Reg), Value(Val) {}
264
265 unsigned getRegister() { return Register; }
266 DbgValueLoc getValue() { return Value; }
267 };
268
269 /// Collection used for storing debug call site parameters.
270 using ParamSet = SmallVector;
271
272256 /// Helper used to pair up a symbol and its DWARF compile unit.
273257 struct SymbolCU {
274258 SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
240240 return false;
241241 }
242242
243 // Handle simple register locations. If we are supposed to
244 // emit a call site parameter expression and if that expression
245 // is just a register location, emit it with addBReg and offset 0,
246 // because we should emit a DWARF expression representing a value,
247 // rather than a location.
248 if (!isMemoryLocation() && !HasComplexExpression &&
249 (!isParameterValue() || isEntryValue())) {
243 // Handle simple register locations.
244 if (!isMemoryLocation() && !HasComplexExpression) {
250245 for (auto &Reg : DwarfRegs) {
251246 if (Reg.DwarfRegNo >= 0)
252247 addReg(Reg.DwarfRegNo, Reg.Comment);
253248 addOpPiece(Reg.Size);
254249 }
255250
256 if (isEntryValue() && !isParameterValue() && DwarfVersion >= 4)
251 if (isEntryValue() && DwarfVersion >= 4)
257252 emitOp(dwarf::DW_OP_stack_value);
258253
259254 DwarfRegs.clear();
344339
345340 while (ExprCursor) {
346341 auto Op = ExprCursor.take();
347 uint64_t OpNum = Op->getOp();
348 if (OpNum >= dwarf::DW_OP_reg0 && OpNum <= dwarf::DW_OP_reg31) {
349 if (isParameterValue())
350 addBReg(OpNum - dwarf::DW_OP_reg0, 0);
351 else
352 emitOp(OpNum);
353 continue;
354 }
355
356 switch (OpNum) {
342 switch (Op->getOp()) {
357343 case dwarf::DW_OP_LLVM_fragment: {
358344 unsigned SizeInBits = Op->getArg(1);
359345 unsigned FragmentOffset = Op->getArg(0);
402388 case dwarf::DW_OP_lit0:
403389 case dwarf::DW_OP_not:
404390 case dwarf::DW_OP_dup:
405 emitOp(OpNum);
391 emitOp(Op->getOp());
406392 break;
407393 case dwarf::DW_OP_deref:
408394 assert(!isRegisterLocation());
471457 case dwarf::DW_OP_LLVM_tag_offset:
472458 TagOffset = Op->getArg(0);
473459 break;
474 case dwarf::DW_OP_regx:
475 if (isParameterValue()) {
476 emitOp(dwarf::DW_OP_bregx);
477 emitUnsigned(Op->getArg(0));
478 emitSigned(Op->getArg(1));
479 } else {
480 emitOp(dwarf::DW_OP_regx);
481 emitUnsigned(Op->getArg(0));
482 }
483 break;
484460 default:
485461 llvm_unreachable("unhandled opcode found in expression");
486462 }
487463 }
488464
489 if (isImplicitLocation() && !isParameterValue())
465 if (isImplicitLocation())
490466 // Turn this into an implicit location description.
491467 addStackValue();
492468 }
119119 enum { Unknown = 0, Register, Memory, Implicit };
120120
121121 /// The flags of location description being produced.
122 enum { EntryValue = 1, CallSiteParamValue };
122 enum { EntryValue = 1 };
123123
124124 unsigned LocationKind : 3;
125125 unsigned LocationFlags : 2;
144144
145145 bool isEntryValue() const {
146146 return LocationFlags & EntryValue;
147 }
148
149 bool isParameterValue() {
150 return LocationFlags & CallSiteParamValue;
151147 }
152148
153149 Optional TagOffset;
267263 LocationFlags |= EntryValue;
268264 }
269265
270 /// Lock this down to become a call site parameter location.
271 void setCallSiteParamValueFlag() {
272 LocationFlags |= CallSiteParamValue;
273 }
274
275266 /// Emit a machine register location. As an optimization this may also consume
276267 /// the prefix of a DwarfExpression if a more efficient representation for
277268 /// combining the register location and the first operation exists.
202202 return;
203203 }
204204 MDNodeToDieMap.insert(std::make_pair(Desc, D));
205 }
206
207 void DwarfUnit::insertDIE(DIE *D) {
208 MDNodeToDieMap.insert(std::make_pair(nullptr, D));
209205 }
210206
211207 void DwarfUnit::addFlag(DIE &Die, dwarf::Attribute Attribute) {
125125 /// type system, since DIEs for the type system can be shared across CUs and
126126 /// the mappings are kept in DwarfDebug.
127127 void insertDIE(const DINode *Desc, DIE *D);
128
129 void insertDIE(DIE *D);
130128
131129 /// Add a flag that is true to the DIE.
132130 void addFlag(DIE &Die, dwarf::Attribute Attribute);
2222 #include "llvm/CodeGen/TargetRegisterInfo.h"
2323 #include "llvm/CodeGen/TargetSchedule.h"
2424 #include "llvm/IR/DataLayout.h"
25 #include "llvm/IR/DebugInfoMetadata.h"
2625 #include "llvm/MC/MCAsmInfo.h"
2726 #include "llvm/MC/MCInstrItineraries.h"
2827 #include "llvm/Support/CommandLine.h"
11201119 return (DefCycle != -1 && DefCycle <= 1);
11211120 }
11221121
1123 Optional
1124 TargetInstrInfo::describeLoadedValue(const MachineInstr &MI) const {
1125 const MachineOperand *Op = nullptr;
1126 DIExpression *Expr = nullptr;
1127
1128 const MachineOperand *SrcRegOp, *DestRegOp;
1129 const MachineFunction *MF = MI.getMF();
1130 if (isCopyInstr(MI, SrcRegOp, DestRegOp)) {
1131 Expr = DIExpression::get(MF->getFunction().getContext(), {});
1132 Op = SrcRegOp;
1133 return ParamLoadedValue(Op, Expr);
1134 } else if (MI.isMoveImmediate()) {
1135 Expr = DIExpression::get(MF->getFunction().getContext(), {});
1136 Op = &MI.getOperand(1);
1137 return ParamLoadedValue(Op, Expr);
1138 } else if (MI.hasOneMemOperand()) {
1139 int64_t Offset;
1140 const auto &TRI = MF->getSubtarget().getRegisterInfo();
1141 const auto &TII = MF->getSubtarget().getInstrInfo();
1142 const MachineOperand *BaseOp;
1143 if (!TII->getMemOperandWithOffset(MI, BaseOp, Offset, TRI))
1144 return None;
1145 unsigned CastedOffset = static_cast(Offset);
1146 if (Offset > 0)
1147 Expr = DIExpression::get(
1148 MF->getFunction().getContext(),
1149 {dwarf::DW_OP_plus_uconst, CastedOffset, dwarf::DW_OP_deref});
1150 else
1151 Expr = DIExpression::get(MF->getFunction().getContext(),
1152 {dwarf::DW_OP_constu, -CastedOffset,
1153 dwarf::DW_OP_minus, dwarf::DW_OP_deref});
1154
1155 Op = BaseOp;
1156 return ParamLoadedValue(Op, Expr);
1157 }
1158
1159 return None;
1160 }
1161
11621122 /// Both DefMI and UseMI must be valid. By default, call directly to the
11631123 /// itinerary. This may be overriden by the target.
11641124 int TargetInstrInfo::getOperandLatency(const InstrItineraryData *ItinData,
432432 return false;
433433 }
434434
435 bool
436 TargetRegisterInfo::isCallerPreservedPhysReg(unsigned PhysReg,
437 const MachineFunction &MF) const {
438 if (PhysReg == 0)
439 return false;
440 const uint32_t *callerPreservedRegs =
441 getCallPreservedMask(MF, MF.getFunction().getCallingConv());
442 if (callerPreservedRegs) {
443 assert(isPhysicalRegister(PhysReg) && "Expected physical register");
444 return (callerPreservedRegs[PhysReg / 32] >> PhysReg % 32) & 1;
445 }
446 return false;
447 }
448
449435 bool TargetRegisterInfo::canRealignStack(const MachineFunction &MF) const {
450436 return !MF.getFunction().hasFnAttribute("no-realign-stack");
451437 }
732732 case DW_AT_call_data_value:
733733 // Extensions.
734734 case DW_AT_GNU_call_site_value:
735 case DW_AT_GNU_call_site_target:
736735 return true;
737736 default:
738737 return false;
832832 case dwarf::DW_OP_LLVM_fragment:
833833 return 3;
834834 case dwarf::DW_OP_constu:
835 case dwarf::DW_OP_consts:
836835 case dwarf::DW_OP_deref_size:
837836 case dwarf::DW_OP_plus_uconst:
838837 case dwarf::DW_OP_LLVM_tag_offset:
839838 case dwarf::DW_OP_entry_value:
840 case dwarf::DW_OP_regx:
841839 return 2;
842840 default:
843841 return 1;
850848 if (I->get() + I->getSize() > E->get())
851849 return false;
852850
853 uint64_t Op = I->getOp();
854 if (Op >= dwarf::DW_OP_reg0 && Op <= dwarf::DW_OP_reg31)
855 continue;
856
857851 // Check that the operand is valid.
858 switch (Op) {
852 switch (I->getOp()) {
859853 default:
860854 return false;
861855 case dwarf::DW_OP_LLVM_fragment:
910904 case dwarf::DW_OP_lit0:
911905 case dwarf::DW_OP_not:
912906 case dwarf::DW_OP_dup:
913 case dwarf::DW_OP_regx:
914907 break;
915908 }
916909 }
2929 #include "llvm/CodeGen/StackMaps.h"
3030 #include "llvm/IR/DerivedTypes.h"
3131 #include "llvm/IR/Function.h"
32 #include "llvm/IR/DebugInfoMetadata.h"
32 #include "llvm/IR/LLVMContext.h"
3333 #include "llvm/MC/MCAsmInfo.h"
3434 #include "llvm/MC/MCExpr.h"
3535 #include "llvm/MC/MCInst.h"
73227322 }
73237323 }
73247324
7325 Optional
7326 X86InstrInfo::describeLoadedValue(const MachineInstr &MI) const {
7327 const MachineOperand *Op = nullptr;
7328 DIExpression *Expr = nullptr;
7329
7330 switch (MI.getOpcode()) {
7331 case X86::LEA32r:
7332 case X86::LEA64r:
7333 case X86::LEA64_32r: {
7334 // Operand 4 could be global address. For now we do not support
7335 // such situation.
7336 if (!MI.getOperand(4).isImm() || !MI.getOperand(2).isImm())
7337 return None;
7338
7339 const MachineOperand &Op1 = MI.getOperand(1);
7340 const MachineOperand &Op2 = MI.getOperand(3);
7341 const TargetRegisterInfo *TRI = &getRegisterInfo();
7342 assert(Op2.isReg() &&
7343 (Op2.getReg() == X86::NoRegister ||
7344 TargetRegisterInfo::isPhysicalRegister(Op2.getReg())));
7345
7346 // Omit situations like:
7347 // %rsi = lea %rsi, 4, ...
7348 if ((Op1.isReg() && Op1.getReg() == MI.getOperand(0).getReg()) ||
7349 Op2.getReg() == MI.getOperand(0).getReg())
7350 return None;
7351 else if ((Op1.isReg() && Op1.getReg() != X86::NoRegister &&
7352 TRI->regsOverlap(Op1.getReg(), MI.getOperand(0).getReg())) ||
7353 (Op2.getReg() != X86::NoRegister &&
7354 TRI->regsOverlap(Op2.getReg(), MI.getOperand(0).getReg())))
7355 return None;
7356
7357 int64_t Coef = MI.getOperand(2).getImm();
7358 int64_t Offset = MI.getOperand(4).getImm();
7359 SmallVector Elements;
7360
7361 if ((Op1.isReg() && Op1.getReg() != X86::NoRegister)) {
7362 Op = &Op1;
7363 } else if (Op1.isFI())
7364 Op = &Op1;
7365
7366 if (Op && Op->isReg() && Op->getReg() == Op2.getReg() && Coef > 0) {
7367 Elements.push_back(dwarf::DW_OP_constu);
7368 Elements.push_back(Coef + 1);
7369 Elements.push_back(dwarf::DW_OP_mul);
7370 } else {
7371 if (Op && Op2.getReg() != X86::NoRegister) {
7372 int dwarfReg = TRI->getDwarfRegNum(Op2.getReg(), false);
7373 if (dwarfReg < 0)
7374 return None;
7375 else if (dwarfReg < 32)
7376 Elements.push_back(dwarf::DW_OP_reg0 + dwarfReg);
7377 else {
7378 Elements.push_back(dwarf::DW_OP_regx);
7379 Elements.push_back(dwarfReg);
7380 }
7381 } else if (!Op) {
7382 assert(Op2.getReg() != X86::NoRegister);
7383 Op = &Op2;
7384 }
7385
7386 if (Coef > 1) {
7387 assert(Op2.getReg() != X86::NoRegister);
7388 Elements.push_back(dwarf::DW_OP_constu);
7389 Elements.push_back(Coef);
7390 Elements.push_back(dwarf::DW_OP_mul);
7391 }
7392
7393 if (((Op1.isReg() && Op1.getReg() != X86::NoRegister) || Op1.isFI()) &&
7394 Op2.getReg() != X86::NoRegister) {
7395 Elements.push_back(dwarf::DW_OP_plus);
7396 }
7397 }
7398
7399 if (Offset < 0) {
7400 Elements.push_back(dwarf::DW_OP_constu);
7401 Elements.push_back(-Offset);
7402 Elements.push_back(dwarf::DW_OP_minus);
7403 } else if (Offset > 0) {
7404 Elements.push_back(dwarf::DW_OP_constu);
7405 Elements.push_back(Offset);
7406 Elements.push_back(dwarf::DW_OP_plus);
7407 }
7408
7409 Expr = DIExpression::get(MI.getMF()->getFunction().getContext(), Elements);
7410 return ParamLoadedValue(Op, Expr);;
7411 }
7412 default:
7413 return TargetInstrInfo::describeLoadedValue(MI);
7414 }
7415 }
7416
74177325 /// This is an architecture-specific helper function of reassociateOps.
74187326 /// Set special operand attributes for new instructions after reassociation.
74197327 void X86InstrInfo::setSpecialOperandAttr(MachineInstr &OldMI1,
526526 #define GET_INSTRINFO_HELPER_DECLS
527527 #include "X86GenInstrInfo.inc"
528528
529 Optional
530 describeLoadedValue(const MachineInstr &MI) const override;
531
532529 protected:
533530 /// Commutes the operands in the given instruction by changing the operands
534531 /// order and/or changing the instruction's opcode and/or the immediate value
+0
-200
test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir less more
None # RUN: llc -debug-entry-values -start-after=machineverifier -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
1 #
2 # CHECK: DW_TAG_GNU_call_site
3 # CHECK-NEXT: DW_AT_abstract_origin {{.*}} "foo"
4 # CHECK-NEXT: DW_AT_low_pc
5 # CHECK-EMPTY:
6 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
7 # CHECK-NEXT: DW_AT_location (DW_OP_reg2 RCX)
8 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg14 R14+0)
9 # CHECK-EMPTY:
10 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
11 # CHECK-NEXT: DW_AT_location (DW_OP_reg1 RDX)
12 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8)
13 # CHECK-EMPTY:
14 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
15 # CHECK-NEXT: DW_AT_location (DW_OP_reg5 RDI)
16 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg4 RSI))
17 # CHECK: DW_TAG_GNU_call_site
18 # CHECK-NEXT: DW_AT_abstract_origin {{.*}}"foo"
19 # CHECK-NEXT: DW_AT_low_pc
20 # CHECK-EMPTY:
21 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
22 # CHECK-NEXT: DW_AT_location (DW_OP_reg2 RCX)
23 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8, DW_OP_deref)
24 # CHECK-EMPTY:
25 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
26 # CHECK-NEXT: DW_AT_location (DW_OP_reg4 RSI)
27 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit4)
28 # CHECK-NOT: DW_TAG_GNU_call_site_parameter
29 #
30 # Check that call site interpretation analysis can interpret instructions such
31 # as move immediate, register to register moves, stack loading and LEA
32 # instructions. Last negative check should verify that we are not producing
33 # interpretation for RDX register since its loaded value is call clobberable.
34 # Also check that we are generating proper call site debug entities.
35 --- |
36 ; ModuleID = 'dbgcall-site-interpretation.c'
37 source_filename = "dbgcall-site-interpretation.c"
38 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
39 target triple = "x86_64-unknown-linux-gnu"
40
41 ; Function Attrs: nounwind uwtable
42 define dso_local i32 @baa(i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4) local_unnamed_addr !dbg !9 {
43 entry:
44 %arg3.addr = alloca i32, align 4
45 %local2 = alloca i32, align 4
46 call void @llvm.dbg.value(metadata i32 %arg1, metadata !14, metadata !DIExpression()), !dbg !21
47 call void @llvm.dbg.value(metadata i32 %arg2, metadata !15, metadata !DIExpression()), !dbg !21
48 call void @llvm.dbg.value(metadata i32 %arg3, metadata !16, metadata !DIExpression()), !dbg !21
49 store i32 %arg3, i32* %arg3.addr, align 4
50 call void @llvm.dbg.value(metadata i32 %arg4, metadata !17, metadata !DIExpression()), !dbg !21
51 %0 = bitcast i32* %local2 to i8*, !dbg !21
52 call void @llvm.dbg.value(metadata i32* %arg3.addr, metadata !16, metadata !DIExpression(DW_OP_deref)), !dbg !21
53 %call = call i32 @foo(i32 %arg1, i32 %arg2, i32* nonnull %arg3.addr, i32 %arg4), !dbg !21
54 call void @llvm.dbg.value(metadata i32 %call, metadata !18, metadata !DIExpression()), !dbg !21
55 %cmp = icmp sgt i32 %arg1, %arg2, !dbg !21
56 %1 = load i32, i32* %arg3.addr, align 4, !dbg !21
57 call void @llvm.dbg.value(metadata i32 %1, metadata !16, metadata !DIExpression()), !dbg !21
58 %add = add nsw i32 %1, %arg1, !dbg !21
59 %add1 = add nsw i32 %arg4, %arg2, !dbg !21
60 %local1.0 = select i1 %cmp, i32 %add, i32 %add1, !dbg !21
61 call void @llvm.dbg.value(metadata i32 %local1.0, metadata !18, metadata !DIExpression()), !dbg !21
62 %rem = srem i32 %1, %arg1, !dbg !21
63 %tobool = icmp eq i32 %rem, 0, !dbg !21
64 %mul = mul nsw i32 %1, %arg1, !dbg !21
65 %add3 = add nsw i32 %1, %arg4, !dbg !21
66 %storemerge = select i1 %tobool, i32 %mul, i32 %add3, !dbg !21
67 call void @llvm.dbg.value(metadata i32 %storemerge, metadata !19, metadata !DIExpression()), !dbg !21
68 store i32 %storemerge, i32* %local2, align 4, !dbg !21
69 %cmp6 = icmp slt i32 %storemerge, %arg4, !dbg !21
70 %local3.0.v = select i1 %cmp6, i32 %local1.0, i32 %arg1, !dbg !21
71 %local3.0 = mul nsw i32 %local3.0.v, %storemerge, !dbg !21
72 call void @llvm.dbg.value(metadata i32 %local3.0, metadata !20, metadata !DIExpression()), !dbg !21
73 call void @llvm.dbg.value(metadata i32* %local2, metadata !19, metadata !DIExpression(DW_OP_deref)), !dbg !21
74 %call12 = call i32 @foo(i32 %local1.0, i32 4, i32* nonnull %local2, i32 %local3.0), !dbg !21
75 call void @llvm.dbg.value(metadata i32 %call12, metadata !14, metadata !DIExpression()), !dbg !21
76 %add13 = add nsw i32 %call12, 4, !dbg !21
77 ret i32 %add13, !dbg !21
78 }
79
80 declare !dbg !4 dso_local i32 @foo(i32, i32, i32*, i32) local_unnamed_addr
81
82 ; Function Attrs: nounwind readnone speculatable
83 declare void @llvm.dbg.value(metadata, metadata, metadata)
84
85 !llvm.dbg.cu = !{!0}
86 !llvm.module.flags = !{!5, !6, !7}
87 !llvm.ident = !{!8}
88
89 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
90 !1 = !DIFile(filename: "dbgcall-site-interpretation.c", directory: "/dir")
91 !2 = !{}
92 !3 = !{!4}
93 !4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 9, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
94 !5 = !{i32 2, !"Dwarf Version", i32 4}
95 !6 = !{i32 2, !"Debug Info Version", i32 3}
96 !7 = !{i32 1, !"wchar_size", i32 4}
97 !8 = !{!"clang version 9.0.0"}
98 !9 = distinct !DISubprogram(name: "baa", scope: !1, file: !1, line: 10, type: !10, scopeLine: 10, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13)
99 !10 = !DISubroutineType(types: !11)
100 !11 = !{!12, !12, !12, !12, !12}
101 !12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
102 !13 = !{!14, !15, !16, !17, !18, !19, !20}
103 !14 = !DILocalVariable(name: "arg1", arg: 1, scope: !9, file: !1, line: 10, type: !12)
104 !15 = !DILocalVariable(name: "arg2", arg: 2, scope: !9, file: !1, line: 10, type: !12, flags: DIFlagArgumentNotModified)
105 !16 = !DILocalVariable(name: "arg3", arg: 3, scope: !9, file: !1, line: 10, type: !12)
106 !17 = !DILocalVariable(name: "arg4", arg: 4, scope: !9, file: !1, line: 10, type: !12, flags: DIFlagArgumentNotModified)
107 !18 = !DILocalVariable(name: "local1", scope: !9, file: !1, line: 11, type: !12)
108 !19 = !DILocalVariable(name: "local2", scope: !9, file: !1, line: 11, type: !12)
109 !20 = !DILocalVariable(name: "local3", scope: !9, file: !1, line: 11, type: !12)
110 !21 = !DILocation(line: 10, column: 13, scope: !9)
111
112 ...
113 ---
114 name: baa
115 liveins:
116 - { reg: '$edi', virtual-reg: '' }
117 - { reg: '$esi', virtual-reg: '' }
118 - { reg: '$edx', virtual-reg: '' }
119 - { reg: '$ecx', virtual-reg: '' }
120 callSites:
121 - { bb: 0, offset: 23, fwdArgRegs:
122 - { arg: 0, reg: '$edi' }
123 - { arg: 1, reg: '$esi' }
124 - { arg: 2, reg: '$rdx' }
125 - { arg: 3, reg: '$ecx' } }
126 - { bb: 0, offset: 49, fwdArgRegs:
127 - { arg: 0, reg: '$edi' }
128 - { arg: 1, reg: '$esi' }
129 - { arg: 2, reg: '$rdx' }
130 - { arg: 3, reg: '$ecx' } }
131 body: |
132 bb.0.entry:
133 liveins: $ecx, $edi, $edx, $esi, $r15, $r14, $rbx
134
135 DBG_VALUE $edi, $noreg, !14, !DIExpression(), debug-location !21
136 DBG_VALUE $esi, $noreg, !15, !DIExpression(), debug-location !21
137 DBG_VALUE $edx, $noreg, !16, !DIExpression(), debug-location !21
138 DBG_VALUE $ecx, $noreg, !17, !DIExpression(), debug-location !21
139 frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
140 CFI_INSTRUCTION def_cfa_offset 16
141 frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
142 CFI_INSTRUCTION def_cfa_offset 24
143 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
144 CFI_INSTRUCTION def_cfa_offset 32
145 $rsp = frame-setup SUB64ri8 $rsp, 16, implicit-def dead $eflags
146 CFI_INSTRUCTION def_cfa_offset 48
147 CFI_INSTRUCTION offset $rbx, -32
148 CFI_INSTRUCTION offset $r14, -24
149 CFI_INSTRUCTION offset $r15, -16
150 $r14d = MOV32rr $ecx, implicit-def $r14
151 DBG_VALUE $edx, $noreg, !16, !DIExpression(), debug-location !21
152 $r15d = MOV32rr $esi, implicit-def $r15
153 $ebx = MOV32rr $edi, implicit-def $rbx
154 $edi = MOV32rr $esi
155 MOV32mr $rsp, 1, $noreg, 8, $noreg, killed renamable $edx :: (store 4 into %ir.arg3.addr)
156 renamable $rdx = LEA64r $rsp, 1, $noreg, 8, $noreg
157 renamable $ecx = MOV32rr $r14d,
158 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit $rdx, implicit $ecx, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, implicit-def $rax, debug-location !21
159 DBG_VALUE $noreg, $noreg, !18, !DIExpression(), debug-location !21
160 $rdx = MOV64rr renamable $rax
161 $ecx = KILL renamable $ecx, implicit-def $rcx
162 renamable $eax = LEA64_32r renamable $rcx, 1, renamable $rbx, 0, $noreg, debug-location !21
163 renamable $edi = LEA64_32r renamable $r14, 1, renamable $r15, 0, $noreg, debug-location !21
164 CMP32rr renamable $ebx, renamable $r15d, implicit-def $eflags, implicit killed $r15, debug-location !21
165 renamable $edi = CMOV32rr killed renamable $edi, killed renamable $eax, 15, implicit killed $eflags, debug-location !21
166 DBG_VALUE $edi, $noreg, !18, !DIExpression(), debug-location !21
167 $eax = MOV32rr $ecx, debug-location !21
168 CDQ implicit-def $eax, implicit-def $edx, implicit $eax, debug-location !21
169 IDIV32r renamable $ebx, implicit-def dead $eax, implicit-def $edx, implicit-def dead $eflags, implicit $eax, implicit $edx, debug-location !21
170 $eax = MOV32rr $ecx, debug-location !21
171 renamable $eax = nsw IMUL32rr killed renamable $eax, renamable $ebx, implicit-def dead $eflags, debug-location !21
172 renamable $ecx = nsw ADD32rr renamable $ecx, renamable $r14d, implicit-def dead $eflags, implicit killed $rcx, implicit-def $rcx, debug-location !21
173 TEST32rr killed renamable $edx, renamable $edx, implicit-def $eflags, debug-location !21
174 renamable $ecx = CMOV32rr renamable $ecx, killed renamable $eax, 4, implicit killed $eflags, implicit killed $rcx, implicit-def $rcx, debug-location !21
175 DBG_VALUE $ecx, $noreg, !19, !DIExpression(), debug-location !21
176 MOV32mr $rsp, 1, $noreg, 12, $noreg, renamable $ecx, debug-location !21 :: (store 4 into %ir.local2)
177 CMP32rr renamable $ecx, renamable $r14d, implicit-def $eflags, implicit killed $r14, debug-location !21
178 renamable $ebx = CMOV32rr renamable $ebx, renamable $edi, 12, implicit killed $eflags, implicit killed $rbx, implicit-def $rbx, debug-location !21
179 renamable $ecx = nsw IMUL32rr renamable $ecx, renamable $ebx, implicit-def dead $eflags, implicit killed $rbx, implicit killed $rcx, implicit-def $rcx, debug-location !21
180 DBG_VALUE $rsp, $noreg, !19, !DIExpression(DW_OP_plus_uconst, 12, DW_OP_deref), debug-location !21
181 DBG_VALUE $ecx, $noreg, !20, !DIExpression(), debug-location !21
182 $esi = MOV32ri 4, debug-location !21
183 renamable $ecx = MOV32rm $rsp, 1, $noreg, 8, $noreg, implicit-def $rcx, debug-location !21 :: (dereferenceable load 4 from %ir.arg3.addr)
184 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit $rdx, implicit $ecx, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, implicit-def $rax, debug-location !21
185 DBG_VALUE $eax, $noreg, !14, !DIExpression(), debug-location !21
186 renamable $eax = nsw ADD32ri8 killed renamable $eax, 4, implicit-def dead $eflags, debug-location !21
187 $rsp = frame-destroy ADD64ri8 $rsp, 16, implicit-def dead $eflags, debug-location !21
188 CFI_INSTRUCTION def_cfa_offset 32, debug-location !21
189 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !21
190 CFI_INSTRUCTION def_cfa_offset 24, debug-location !21
191 $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !21
192 DBG_VALUE $ecx, $noreg, !17, !DIExpression(DW_OP_entry_value, 1), debug-location !21
193 CFI_INSTRUCTION def_cfa_offset 16, debug-location !21
194 $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !21
195 DBG_VALUE $esi, $noreg, !15, !DIExpression(DW_OP_entry_value, 1), debug-location !21
196 CFI_INSTRUCTION def_cfa_offset 8, debug-location !21
197 RETQ $eax, debug-location !21
198
199 ...
+0
-140
test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir less more
None # RUN: llc -debug-entry-values -start-after=machineverifier -filetype=obj %s -o -| llvm-dwarfdump -| FileCheck %s
1 # CHECK: DW_TAG_GNU_call_site
2 # CHECK-NEXT: DW_AT_abstract_origin {{.*}} "foo")
3 # CHECK-NEXT: DW_AT_low_pc {{.*}}
4 # CHECK-EMPTY:
5 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
6 # CHECK-NEXT: DW_AT_location (DW_OP_reg9 R9)
7 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg15 R15+10)
8 # CHECK-EMPTY:
9 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
10 # CHECK-NEXT: DW_AT_location (DW_OP_reg8 R8)
11 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg15 R15+0, DW_OP_lit2, DW_OP_mul, DW_OP_lit8, DW_OP_plus)
12 # CHECK-EMPTY:
13 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
14 # CHECK-NEXT: DW_AT_location (DW_OP_reg1 RDX)
15 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg14 R14+0, DW_OP_lit5, DW_OP_mul, DW_OP_lit8, DW_OP_plus)
16 # CHECK-EMPTY:
17 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
18 # CHECK-NEXT: DW_AT_location (DW_OP_reg4 RSI)
19 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg14 R14+0)
20 # CHECK-EMPTY:
21 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
22 # CHECK-NEXT: DW_AT_location (DW_OP_reg5 RDI)
23 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg14 R14+0, DW_OP_breg15 R15+0, DW_OP_lit2, DW_OP_mul, DW_OP_plus, DW_OP_lit4, DW_OP_plus)
24 # CHECK-EMPTY:
25 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
26 # CHECK-NEXT: DW_AT_location (DW_OP_reg2 RCX)
27 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg14 R14+0, DW_OP_breg15 R15+0, DW_OP_plus)
28 # CHECK: DW_TAG_GNU_call_site
29 # CHECK-NEXT: DW_AT_abstract_origin {{.*}} "foo2")
30 # CHECK-NEXT: DW_AT_low_pc {{.*}}
31 # CHECK-EMPTY:
32 # CHECK-NEXT: DW_TAG_GNU_call_site_parameter
33 # CHECK-NEXT: DW_AT_location (DW_OP_reg5 RDI)
34 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg14 R14+0, DW_OP_lit2, DW_OP_mul)
35 --- |
36 ; ModuleID = 'dbgcall-site-lea-interpretation.ll'
37 source_filename = "dbgcall-site-lea-interpretation.c"
38 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
39 target triple = "x86_64-unknown-linux-gnu"
40
41 define dso_local i32 @baa(i32 %arg1, i32 %arg2, i32 %arg3) local_unnamed_addr !dbg !10 {
42 entry:
43 %arg1.addr = alloca i32, align 4
44 %arg3.addr = alloca i32, align 4
45 %local1 = alloca i32, align 4
46 store i32 %arg1, i32* %arg1.addr, align 4
47 store i32 %arg3, i32* %arg3.addr, align 4
48 %0 = bitcast i32* %local1 to i8*, !dbg !14
49 %mul = mul nsw i32 %arg3, %arg1, !dbg !14
50 store i32 %mul, i32* %local1, align 4, !dbg !14
51 %add = add nsw i32 %arg2, %arg1, !dbg !14
52 %sub = sub nsw i32 %add, %arg3, !dbg !14
53 %call = call i32 @foo(i32 %mul, i32 %sub, i32* nonnull %local1, i32* nonnull %arg1.addr, i32* nonnull %arg3.addr, i32 %add), !dbg !14
54 %1 = load i32, i32* %local1, align 4, !dbg !14
55 %add2 = add nsw i32 %1, %call, !dbg !14
56 store i32 %add2, i32* %local1, align 4, !dbg !14
57 %call3 = call i32 @foo2(i32* nonnull %local1), !dbg !14
58 %2 = load i32, i32* %local1, align 4, !dbg !14
59 ret i32 %2, !dbg !14
60 }
61
62 declare !dbg !4 dso_local i32 @foo(i32, i32, i32*, i32*, i32*, i32) local_unnamed_addr
63
64 declare !dbg !5 dso_local i32 @foo2(i32*) local_unnamed_addr
65
66 !llvm.dbg.cu = !{!0}
67 !llvm.module.flags = !{!6, !7, !8}
68 !llvm.ident = !{!9}
69
70 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
71 !1 = !DIFile(filename: "dbgcall-site-lea-interpretation.c", directory: "/dir")
72 !2 = !{}
73 !3 = !{!4, !5}
74 !4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
75 !5 = !DISubprogram(name: "foo2", scope: !1, file: !1, line: 9, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
76 !6 = !{i32 2, !"Dwarf Version", i32 4}
77 !7 = !{i32 2, !"Debug Info Version", i32 3}
78 !8 = !{i32 1, !"wchar_size", i32 4}
79 !9 = !{!"clang version 9.0.0"}
80 !10 = distinct !DISubprogram(name: "baa", scope: !1, file: !1, line: 11, type: !11, scopeLine: 11, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
81 !11 = !DISubroutineType(types: !12)
82 !12 = !{!13, !13, !13, !13}
83 !13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
84 !14 = !DILocation(line: 11, column: 13, scope: !10)
85
86 ...
87 ---
88 name: baa
89 liveins:
90 - { reg: '$edi', virtual-reg: '' }
91 - { reg: '$esi', virtual-reg: '' }
92 - { reg: '$edx', virtual-reg: '' }
93 callSites:
94 - { bb: 0, offset: 21, fwdArgRegs:
95 - { arg: 0, reg: '$edi' }
96 - { arg: 1, reg: '$esi' }
97 - { arg: 2, reg: '$rdx' }
98 - { arg: 3, reg: '$rcx' }
99 - { arg: 4, reg: '$r8' }
100 - { arg: 5, reg: '$r9d' } }
101 - { bb: 0, offset: 24, fwdArgRegs:
102 - { arg: 0, reg: '$rdi' } }
103 body: |
104 bb.0.entry:
105 liveins: $edi, $edx, $esi, $rbx
106
107 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
108 CFI_INSTRUCTION def_cfa_offset 16
109 $rsp = frame-setup SUB64ri8 $rsp, 16, implicit-def dead $eflags
110 CFI_INSTRUCTION def_cfa_offset 32
111 CFI_INSTRUCTION offset $rbx, -16
112 $r9d = MOV32rr $esi
113 $r14 = MOV64rr $rsi
114 $r15 = MOV64rr $rdi
115 MOV32mr $rsp, 1, $noreg, 12, $noreg, renamable $edi :: (store 4 into %ir.arg1.addr)
116 MOV32mr $rsp, 1, $noreg, 8, $noreg, renamable $edx :: (store 4 into %ir.arg3.addr)
117 renamable $r9d = nsw ADD32rr killed renamable $r9d, renamable $edi, implicit-def dead $eflags, debug-location !14
118 $esi = MOV32rr $r9d, debug-location !14
119 renamable $esi = nsw SUB32rr killed renamable $esi, renamable $edx, implicit-def dead $eflags, debug-location !14
120 renamable $edx = nsw IMUL32rr killed renamable $edx, killed renamable $edi, implicit-def dead $eflags, debug-location !14
121 MOV32mr $rsp, 1, $noreg, 4, $noreg, renamable $edx, debug-location !14 :: (store 4 into %ir.local1)
122 renamable $rcx = LEA64r $r14, 1, $r15, 0, $noreg
123 renamable $rdi = LEA64r $r14, 2, $r15, 4, $noreg
124 renamable $rsi = LEA64r $r14, 1, $noreg, 0, $noreg
125 renamable $rdx = LEA64r $r14, 4, $r14, 8, $noreg
126 renamable $r8 = LEA64r $noreg, 2, $r15, 8, $noreg
127 renamable $r9 = LEA64r $noreg, 1, $r15, 10, $noreg, implicit-def $r9d
128 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit $esi, implicit $rdx, implicit $rcx, implicit $r8, implicit $r9d, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !14
129 ADD32mr $rsp, 1, $noreg, 4, $noreg, killed renamable $eax, implicit-def dead $eflags, debug-location !14 :: (store 4 into %ir.local1), (dereferenceable load 4 from %ir.local1)
130 $rdi = LEA64r $r14, 1, killed $r14, 0, $noreg
131 CALL64pcrel32 @foo2, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp, implicit-def dead $eax, debug-location !14
132 renamable $eax = MOV32rm $rsp, 1, $noreg, 4, $noreg, debug-location !14 :: (dereferenceable load 4 from %ir.local1)
133 $rsp = frame-destroy ADD64ri8 $rsp, 16, implicit-def dead $eflags, debug-location !14
134 CFI_INSTRUCTION def_cfa_offset 16, debug-location !14
135 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !14
136 CFI_INSTRUCTION def_cfa_offset 8, debug-location !14
137 RETQ $eax, debug-location !14
138
139 ...
+0
-158
test/DebugInfo/MIR/X86/debug-call-site-param.mir less more
None # RUN: llc -debug-entry-values -filetype=obj -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s| llvm-dwarfdump - | FileCheck %s
1 #
2 # extern void foo(int *a, int b, int c, int d, int e, int f);
3 # extern int getVal();
4 #
5 # void baa(int arg1, int arg2, int arg3) {
6 # int local1 = getVal();
7 # foo(&local1, arg2, 10, 15, arg3 + 3, arg1 + arg2);
8 # }
9 #
10 # CHECK: DW_TAG_GNU_call_site
11 # CHECK: DW_AT_abstract_origin {{.*}} "getVal"
12 #
13 # CHECK: DW_TAG_GNU_call_site
14 # CHECK: DW_AT_abstract_origin {{.*}} "foo"
15 # CHECK: DW_TAG_GNU_call_site_parameter
16 # CHECK-NEXT: DW_AT_location (DW_OP_reg2 RCX)
17 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit15)
18 # CHECK: DW_TAG_GNU_call_site_parameter
19 # CHECK-NEXT: DW_AT_location (DW_OP_reg1 RDX)
20 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit10)
21 # CHECK: DW_TAG_GNU_call_site_parameter
22 # CHECK-NEXT: DW_AT_location (DW_OP_reg4 RSI)
23 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg3 RBX+0)
24 # CHECK: DW_TAG_GNU_call_site_parameter
25 # CHECK-NEXT: DW_AT_location (DW_OP_reg5 RDI)
26 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +12)
27 # CHECK: DW_TAG_GNU_call_site_parameter
28 # CHECK-NEXT: DW_AT_location (DW_OP_reg9 R9)
29 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg15 R15+0, DW_OP_breg3 RBX+0, DW_OP_plus)
30 # CHECK: DW_TAG_GNU_call_site_parameter
31 # CHECK-NEXT: DW_AT_location (DW_OP_reg8 R8)
32 # CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_breg14 R14+3)
33
34 --- |
35 ; ModuleID = 'test.c'
36 source_filename = "test.c"
37 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
38 target triple = "x86_64-unknown-linux-gnu"
39
40 ; Function Attrs: nounwind uwtable
41 define dso_local void @baa(i32 %arg1, i32 %arg2, i32 %arg3) local_unnamed_addr !dbg !10 {
42 entry:
43 %local1 = alloca i32, align 4
44 call void @llvm.dbg.value(metadata i32 %arg1, metadata !15, metadata !DIExpression()), !dbg !19
45 call void @llvm.dbg.value(metadata i32 %arg2, metadata !16, metadata !DIExpression()), !dbg !20
46 call void @llvm.dbg.value(metadata i32 %arg3, metadata !17, metadata !DIExpression()), !dbg !21
47 %0 = bitcast i32* %local1 to i8*, !dbg !22
48 %call = tail call i32 (...) @getVal(), !dbg !23
49 call void @llvm.dbg.value(metadata i32 %call, metadata !18, metadata !DIExpression()), !dbg !24
50 store i32 %call, i32* %local1, align 4, !dbg !24
51 %add = add nsw i32 %arg3, 3, !dbg !24
52 %add1 = add nsw i32 %arg2, %arg1, !dbg !24
53 call void @llvm.dbg.value(metadata i32* %local1, metadata !18, metadata !DIExpression(DW_OP_deref)), !dbg !24
54 call void @foo(i32* nonnull %local1, i32 %arg2, i32 10, i32 15, i32 %add, i32 %add1), !dbg !24
55 ret void, !dbg !24
56 }
57
58 declare !dbg !4 dso_local i32 @getVal(...) local_unnamed_addr
59
60 declare !dbg !5 dso_local void @foo(i32*, i32, i32, i32, i32, i32) local_unnamed_addr
61
62 ; Function Attrs: nounwind readnone speculatable
63 declare void @llvm.dbg.value(metadata, metadata, metadata)
64
65 !llvm.dbg.cu = !{!0}
66 !llvm.module.flags = !{!6, !7, !8}
67 !llvm.ident = !{!9}
68
69 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
70 !1 = !DIFile(filename: "test.c", directory: "/dir")
71 !2 = !{}
72 !3 = !{!4, !5}
73 !4 = !DISubprogram(name: "getVal", scope: !1, file: !1, line: 2, spFlags: DISPFlagOptimized, retainedNodes: !2)
74 !5 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
75 !6 = !{i32 2, !"Dwarf Version", i32 4}
76 !7 = !{i32 2, !"Debug Info Version", i32 3}
77 !8 = !{i32 1, !"wchar_size", i32 4}
78 !9 = !{!"clang version 9.0.0"}
79 !10 = distinct !DISubprogram(name: "baa", scope: !1, file: !1, line: 4, type: !11, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)
80 !11 = !DISubroutineType(types: !12)
81 !12 = !{null, !13, !13, !13}
82 !13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
83 !14 = !{!15, !16, !17, !18}
84 !15 = !DILocalVariable(name: "arg1", arg: 1, scope: !10, file: !1, line: 4, type: !13, flags: DIFlagArgumentNotModified)
85 !16 = !DILocalVariable(name: "arg2", arg: 2, scope: !10, file: !1, line: 4, type: !13, flags: DIFlagArgumentNotModified)
86 !17 = !DILocalVariable(name: "arg3", arg: 3, scope: !10, file: !1, line: 4, type: !13, flags: DIFlagArgumentNotModified)
87 !18 = !DILocalVariable(name: "local1", scope: !10, file: !1, line: 5, type: !13)
88 !19 = !DILocation(line: 4, column: 14, scope: !10)
89 !20 = !DILocation(line: 4, column: 24, scope: !10)
90 !21 = !DILocation(line: 4, column: 34, scope: !10)
91 !22 = !DILocation(line: 5, column: 3, scope: !10)
92 !23 = !DILocation(line: 5, column: 16, scope: !10)
93 !24 = !DILocation(line: 5, column: 7, scope: !10)
94
95 ...
96 ---
97 name: baa
98 liveins:
99 - { reg: '$edi', virtual-reg: '' }
100 - { reg: '$esi', virtual-reg: '' }
101 - { reg: '$edx', virtual-reg: '' }
102 callSites:
103 - { bb: 0, offset: 21, fwdArgRegs: [] }
104 - { bb: 0, offset: 31, fwdArgRegs:
105 - { arg: 0, reg: '$rdi' }
106 - { arg: 1, reg: '$esi' }
107 - { arg: 2, reg: '$edx' }
108 - { arg: 3, reg: '$ecx' }
109 - { arg: 4, reg: '$r8d' }
110 - { arg: 5, reg: '$r9d' } }
111 body: |
112 bb.0.entry:
113 liveins: $edi, $edx, $esi, $r15, $r14, $rbx
114
115 DBG_VALUE $edi, $noreg, !15, !DIExpression(), debug-location !19
116 DBG_VALUE $esi, $noreg, !16, !DIExpression(), debug-location !20
117 DBG_VALUE $edx, $noreg, !17, !DIExpression(), debug-location !21
118 frame-setup PUSH64r killed $r15, implicit-def $rsp, implicit $rsp
119 CFI_INSTRUCTION def_cfa_offset 16
120 frame-setup PUSH64r killed $r14, implicit-def $rsp, implicit $rsp
121 CFI_INSTRUCTION def_cfa_offset 24
122 frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp
123 CFI_INSTRUCTION def_cfa_offset 32
124 $rsp = frame-setup SUB64ri8 $rsp, 16, implicit-def dead $eflags
125 CFI_INSTRUCTION def_cfa_offset 48
126 CFI_INSTRUCTION offset $rbx, -32
127 CFI_INSTRUCTION offset $r14, -24
128 CFI_INSTRUCTION offset $r15, -16
129 $r14d = MOV32rr $edx, implicit-def $r14
130 $ebx = MOV32rr $esi, implicit-def $rbx
131 $r15d = MOV32rr $edi, implicit-def $r15
132 DBG_VALUE $r14d, $noreg, !17, !DIExpression(), debug-location !21
133 DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !20
134 DBG_VALUE $r15d, $noreg, !15, !DIExpression(), debug-location !19
135 dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !23
136 CALL64pcrel32 @getVal, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !23
137 DBG_VALUE $eax, $noreg, !18, !DIExpression(), debug-location !24
138 MOV32mr $rsp, 1, $noreg, 12, $noreg, killed renamable $eax, debug-location !24 :: (store 4 into %ir.local1)
139 renamable $r8d = LEA64_32r killed renamable $r14, 1, $noreg, 3, $noreg, debug-location !24
140 renamable $r9d = LEA64_32r killed renamable $r15, 1, renamable $rbx, 0, $noreg, debug-location !24
141 DBG_VALUE $rsp, $noreg, !18, !DIExpression(DW_OP_plus_uconst, 12, DW_OP_deref), debug-location !24
142 renamable $rdi = LEA64r $rsp, 1, $noreg, 12, $noreg
143 $esi = MOV32rr $ebx, implicit killed $rbx, debug-location !24
144 $edx = MOV32ri 10, debug-location !24
145 $ecx = MOV32ri 15, debug-location !24
146 CALL64pcrel32 @foo, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit $esi, implicit $edx, implicit killed $ecx, implicit $r8d, implicit $r9d, implicit-def $rsp, implicit-def $ssp, debug-location !24
147 $rsp = frame-destroy ADD64ri8 $rsp, 16, implicit-def dead $eflags, debug-location !24
148 CFI_INSTRUCTION def_cfa_offset 32, debug-location !24
149 $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !24
150 CFI_INSTRUCTION def_cfa_offset 24, debug-location !24
151 $r14 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !24
152 CFI_INSTRUCTION def_cfa_offset 16, debug-location !24
153 $r15 = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !24
154 CFI_INSTRUCTION def_cfa_offset 8, debug-location !24
155 RETQ debug-location !24
156
157 ...
1313
1414 ; REQUIRES: object-emission
1515 ; RUN: %llc_dwarf -mtriple=x86_64-- < %s -o - | FileCheck %s -check-prefix=ASM
16 ; RUN: %llc_dwarf -debugger-tune=lldb -mtriple=x86_64-- < %s -filetype=obj -o %t.o
16 ; RUN: %llc_dwarf -mtriple=x86_64-- < %s -filetype=obj -o %t.o
1717 ; RUN: llvm-dwarfdump %t.o -o - | FileCheck %s -check-prefix=OBJ -implicit-check-not=DW_TAG_call_site
1818 ; RUN: llvm-dwarfdump -verify %t.o 2>&1 | FileCheck %s -check-prefix=VERIFY
1919 ; RUN: llvm-dwarfdump -statistics %t.o | FileCheck %s -check-prefix=STATS
2020 ; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis -o /dev/null
2121
2222 ; VERIFY: No errors.
23 ; STATS: "call site DIEs":6
23 ; STATS: "call site entries":5
2424
2525 @sink = global i32 0, align 4, !dbg !0
2626
8484 ; OBJ: DW_TAG_call_site
8585 ; OBJ: DW_AT_call_origin ([[foo_sp]])
8686 ; OBJ: DW_AT_call_return_pc
87 ; OBJ: DW_TAG_call_site
88 ; OBJ: DW_AT_call_target
89 ; OBJ: DW_AT_call_return_pc
9087 define i32 @main() !dbg !29 {
9188 entry:
9289 call void @_Z3foov(), !dbg !32
+0
-76
test/tools/llvm-dwarfdump/X86/stats-dbg-callsite-info.ll less more
None ; RUN: llc -debug-entry-values %s -o - -filetype=obj \
1 ; RUN: | llvm-dwarfdump -statistics - | FileCheck %s
2 ;
3 ; The LLVM IR file was generated on this source code by using
4 ; option '-femit-param-entry-values'.
5 ;
6 ; extern void foo(int *a, int b, int c, int d, int e, int f);
7 ; extern int getVal();
8 ;
9 ; void baa(int arg1, int arg2, int arg3) {
10 ; int local1 = getVal();
11 ; foo(&local1, arg2, 10, 15, arg3 + 3, arg1 + arg2);
12 ; }
13 ;
14 ; CHECK: "call site DIEs":2
15 ; CHECK-SAME: "call site parameter DIEs":6
16 ;
17 ; ModuleID = 'test.c'
18 source_filename = "test.c"
19 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
20 target triple = "x86_64-unknown-linux-gnu"
21
22 ; Function Attrs: nounwind uwtable
23 define dso_local void @baa(i32 %arg1, i32 %arg2, i32 %arg3) local_unnamed_addr #0 !dbg !10 {
24 entry:
25 %local1 = alloca i32, align 4
26 call void @llvm.dbg.value(metadata i32 %arg1, metadata !15, metadata !DIExpression()), !dbg !19
27 call void @llvm.dbg.value(metadata i32 %arg2, metadata !16, metadata !DIExpression()), !dbg !20
28 call void @llvm.dbg.value(metadata i32 %arg3, metadata !17, metadata !DIExpression()), !dbg !21
29 %0 = bitcast i32* %local1 to i8*, !dbg !22
30 %call = tail call i32 (...) @getVal(), !dbg !23
31 call void @llvm.dbg.value(metadata i32 %call, metadata !18, metadata !DIExpression()), !dbg !24
32 store i32 %call, i32* %local1, align 4, !dbg !24
33 %add = add nsw i32 %arg3, 3, !dbg !24
34 %add1 = add nsw i32 %arg2, %arg1, !dbg !24
35 call void @llvm.dbg.value(metadata i32* %local1, metadata !18, metadata !DIExpression(DW_OP_deref)), !dbg !24
36 call void @foo(i32* nonnull %local1, i32 %arg2, i32 10, i32 15, i32 %add, i32 %add1), !dbg !24
37 ret void, !dbg !24
38 }
39
40 declare !dbg !4 dso_local i32 @getVal(...) local_unnamed_addr
41
42 declare !dbg !5 dso_local void @foo(i32*, i32, i32, i32, i32, i32) local_unnamed_addr
43
44 ; Function Attrs: nounwind readnone speculatable
45 declare void @llvm.dbg.value(metadata, metadata, metadata)
46
47 !llvm.dbg.cu = !{!0}
48 !llvm.module.flags = !{!6, !7, !8}
49 !llvm.ident = !{!9}
50
51 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, nameTableKind: None)
52 !1 = !DIFile(filename: "test.c", directory: "/dir")
53 !2 = !{}
54 !3 = !{!4, !5}
55 !4 = !DISubprogram(name: "getVal", scope: !1, file: !1, line: 2, spFlags: DISPFlagOptimized, retainedNodes: !2)
56 !5 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2)
57 !6 = !{i32 2, !"Dwarf Version", i32 4}
58 !7 = !{i32 2, !"Debug Info Version", i32 3}
59 !8 = !{i32 1, !"wchar_size", i32 4}
60 !9 = !{!"clang version 9.0.0"}
61 !10 = distinct !DISubprogram(name: "baa", scope: !1, file: !1, line: 4, type: !11, scopeLine: 4, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !14)
62 !11 = !DISubroutineType(types: !12)
63 !12 = !{null, !13, !13, !13}
64 !13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
65 !14 = !{!15, !16, !17, !18}
66 !15 = !DILocalVariable(name: "arg1", arg: 1, scope: !10, file: !1, line: 4, type: !13, flags: DIFlagArgumentNotModified)
67 !16 = !DILocalVariable(name: "arg2", arg: 2, scope: !10, file: !1, line: 4, type: !13, flags: DIFlagArgumentNotModified)
68 !17 = !DILocalVariable(name: "arg3", arg: 3, scope: !10, file: !1, line: 4, type: !13, flags: DIFlagArgumentNotModified)
69 !18 = !DILocalVariable(name: "local1", scope: !10, file: !1, line: 5, type: !13)
70 !19 = !DILocation(line: 4, column: 14, scope: !10)
71 !20 = !DILocation(line: 4, column: 24, scope: !10)
72 !21 = !DILocation(line: 4, column: 34, scope: !10)
73 !22 = !DILocation(line: 5, column: 3, scope: !10)
74 !23 = !DILocation(line: 5, column: 16, scope: !10)
75 !24 = !DILocation(line: 5, column: 7, scope: !10)
5555 /// Total number of PC range bytes in each variable's enclosing scope,
5656 /// starting from the first definition of the variable.
5757 unsigned ScopeBytesFromFirstDefinition = 0;
58 /// Total number of call site entries (DW_AT_call_file & DW_AT_call_line).
58 /// Total number of call site entries (DW_TAG_call_site) or
59 /// (DW_AT_call_file & DW_AT_call_line).
5960 unsigned CallSiteEntries = 0;
60 /// Total number of call site DIEs (DW_TAG_call_site).
61 unsigned CallSiteDIEs = 0;
62 /// Total number of call site parameter DIEs (DW_TAG_call_site_parameter).
63 unsigned CallSiteParamDIEs = 0;
6461 /// Total byte size of concrete functions. This byte size includes
6562 /// inline functions contained in the concrete functions.
6663 uint64_t FunctionSize = 0;
9693 uint64_t BytesCovered = 0;
9794 uint64_t OffsetToFirstDefinition = 0;
9895
99 if (Die.getTag() == dwarf::DW_TAG_call_site ||
100 Die.getTag() == dwarf::DW_TAG_GNU_call_site) {
101 GlobalStats.CallSiteDIEs++;
102 return;
103 }
104
105 if (Die.getTag() == dwarf::DW_TAG_call_site_parameter ||
106 Die.getTag() == dwarf::DW_TAG_GNU_call_site_parameter) {
107 GlobalStats.CallSiteParamDIEs++;
96 if (Die.getTag() == dwarf::DW_TAG_call_site) {
97 GlobalStats.CallSiteEntries++;
10898 return;
10999 }
110100
396386 printDatum(OS, "source variables", VarParamTotal);
397387 printDatum(OS, "variables with location", VarParamWithLoc);
398388 printDatum(OS, "call site entries", GlobalStats.CallSiteEntries);
399 printDatum(OS, "call site DIEs", GlobalStats.CallSiteDIEs);
400 printDatum(OS, "call site parameter DIEs", GlobalStats.CallSiteParamDIEs);
401389 printDatum(OS, "scope bytes total",
402390 GlobalStats.ScopeBytesFromFirstDefinition);
403391 printDatum(OS, "scope bytes covered", GlobalStats.ScopeBytesCovered);