2009-05-15 17:23:25 +08:00
|
|
|
//===-- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework ------*- C++ -*--===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains support for writing dwarf debug info into asm files.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
|
|
|
|
#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2013-12-03 23:10:23 +08:00
|
|
|
#include "AsmPrinterHandler.h"
|
2014-05-01 05:34:11 +08:00
|
|
|
#include "DbgValueHistoryCalculator.h"
|
2014-04-02 05:49:04 +08:00
|
|
|
#include "DebugLocEntry.h"
|
2014-04-02 09:43:18 +08:00
|
|
|
#include "DebugLocList.h"
|
2014-04-24 07:37:35 +08:00
|
|
|
#include "DwarfAccelTable.h"
|
2015-01-14 19:23:27 +08:00
|
|
|
#include "DwarfFile.h"
|
2010-01-19 14:19:05 +08:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2015-04-16 06:29:27 +08:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2015-01-14 19:23:27 +08:00
|
|
|
#include "llvm/ADT/FoldingSet.h"
|
2014-03-19 04:58:35 +08:00
|
|
|
#include "llvm/ADT/MapVector.h"
|
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
|
|
|
#include "llvm/ADT/StringMap.h"
|
2015-01-06 05:29:41 +08:00
|
|
|
#include "llvm/CodeGen/DIE.h"
|
2012-12-04 15:12:27 +08:00
|
|
|
#include "llvm/CodeGen/LexicalScopes.h"
|
2014-05-31 05:10:13 +08:00
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2014-03-06 08:46:21 +08:00
|
|
|
#include "llvm/IR/DebugInfo.h"
|
2014-03-19 04:58:35 +08:00
|
|
|
#include "llvm/IR/DebugLoc.h"
|
2014-03-18 09:17:26 +08:00
|
|
|
#include "llvm/MC/MCDwarf.h"
|
2015-01-14 19:23:27 +08:00
|
|
|
#include "llvm/MC/MachineLocation.h"
|
2010-04-05 13:24:55 +08:00
|
|
|
#include "llvm/Support/Allocator.h"
|
2014-04-23 06:39:41 +08:00
|
|
|
#include <memory>
|
|
|
|
|
2009-05-15 17:23:25 +08:00
|
|
|
namespace llvm {
|
|
|
|
|
2014-03-18 10:34:52 +08:00
|
|
|
class AsmPrinter;
|
2014-03-08 06:40:37 +08:00
|
|
|
class ByteStreamer;
|
2012-01-27 04:44:57 +08:00
|
|
|
class ConstantInt;
|
|
|
|
class ConstantFP;
|
2014-03-19 04:37:10 +08:00
|
|
|
class DwarfCompileUnit;
|
|
|
|
class DwarfDebug;
|
|
|
|
class DwarfTypeUnit;
|
|
|
|
class DwarfUnit;
|
2009-05-15 17:23:25 +08:00
|
|
|
class MachineModuleInfo;
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief This class is used to record source line correspondence.
|
2013-09-12 02:05:11 +08:00
|
|
|
class SrcLineInfo {
|
2013-12-10 07:32:48 +08:00
|
|
|
unsigned Line; // Source line number.
|
|
|
|
unsigned Column; // Source column.
|
|
|
|
unsigned SourceID; // Source ID number.
|
|
|
|
MCSymbol *Label; // Label in code ID number.
|
2009-05-15 17:23:25 +08:00
|
|
|
public:
|
2010-03-14 16:15:55 +08:00
|
|
|
SrcLineInfo(unsigned L, unsigned C, unsigned S, MCSymbol *label)
|
2013-12-10 07:32:48 +08:00
|
|
|
: Line(L), Column(C), SourceID(S), Label(label) {}
|
2009-05-15 17:23:25 +08:00
|
|
|
|
|
|
|
// Accessors
|
|
|
|
unsigned getLine() const { return Line; }
|
|
|
|
unsigned getColumn() const { return Column; }
|
|
|
|
unsigned getSourceID() const { return SourceID; }
|
2010-03-14 16:15:55 +08:00
|
|
|
MCSymbol *getLabel() const { return Label; }
|
2009-05-15 17:23:25 +08:00
|
|
|
};
|
|
|
|
|
2011-04-13 06:53:02 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief This class is used to track local variable information.
|
2015-02-11 07:18:28 +08:00
|
|
|
///
|
2015-02-18 04:02:28 +08:00
|
|
|
/// - Variables whose location changes over time have a DotDebugLocOffset and
|
|
|
|
/// the other fields are not used.
|
2015-02-11 07:18:28 +08:00
|
|
|
///
|
|
|
|
/// - Variables that are described by multiple MMI table entries have multiple
|
|
|
|
/// expressions and frame indices.
|
2013-09-12 02:05:11 +08:00
|
|
|
class DbgVariable {
|
2015-04-16 06:29:27 +08:00
|
|
|
DIVariable Var; /// Variable Descriptor.
|
|
|
|
DILocation IA; /// Inlined at location.
|
2015-02-11 07:18:28 +08:00
|
|
|
SmallVector<DIExpression, 1> Expr; /// Complex address location expression.
|
|
|
|
DIE *TheDIE; /// Variable DIE.
|
|
|
|
unsigned DotDebugLocOffset; /// Offset in DotDebugLocEntries.
|
|
|
|
const MachineInstr *MInsn; /// DBG_VALUE instruction of the variable.
|
|
|
|
SmallVector<int, 1> FrameIndex; /// Frame index of the variable.
|
2013-10-05 09:43:03 +08:00
|
|
|
DwarfDebug *DD;
|
2013-12-10 07:32:48 +08:00
|
|
|
|
2011-04-13 06:53:02 +08:00
|
|
|
public:
|
2014-05-31 05:10:13 +08:00
|
|
|
/// Construct a DbgVariable from a DIVariable.
|
2015-04-16 06:29:27 +08:00
|
|
|
DbgVariable(DIVariable V, DILocation IA, DIExpression E, DwarfDebug *DD,
|
|
|
|
int FI = ~0)
|
|
|
|
: Var(V), IA(IA), Expr(1, E), TheDIE(nullptr), DotDebugLocOffset(~0U),
|
|
|
|
MInsn(nullptr), DD(DD) {
|
2015-02-11 07:18:28 +08:00
|
|
|
FrameIndex.push_back(FI);
|
2015-03-17 05:03:55 +08:00
|
|
|
assert(!E || E->isValid());
|
Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.
Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.
By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.
The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)
This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.
What this patch doesn't do:
This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.
http://reviews.llvm.org/D4919
rdar://problem/17994491
Thanks to dblaikie and dexonsmith for reviewing this patch!
Note: I accidentally committed a bogus older version of this patch previously.
llvm-svn: 218787
2014-10-02 02:55:02 +08:00
|
|
|
}
|
2011-04-13 06:53:02 +08:00
|
|
|
|
2014-05-31 05:10:13 +08:00
|
|
|
/// Construct a DbgVariable from a DEBUG_VALUE.
|
|
|
|
/// AbstractVar may be NULL.
|
2014-06-14 07:52:55 +08:00
|
|
|
DbgVariable(const MachineInstr *DbgValue, DwarfDebug *DD)
|
2015-02-18 04:02:28 +08:00
|
|
|
: Var(DbgValue->getDebugVariable()),
|
2015-04-17 06:12:59 +08:00
|
|
|
IA(DbgValue->getDebugLoc()->getInlinedAt()),
|
2015-02-18 04:02:28 +08:00
|
|
|
Expr(1, DbgValue->getDebugExpression()), TheDIE(nullptr),
|
|
|
|
DotDebugLocOffset(~0U), MInsn(DbgValue), DD(DD) {
|
2015-02-11 07:18:28 +08:00
|
|
|
FrameIndex.push_back(~0);
|
|
|
|
}
|
2014-05-31 05:10:13 +08:00
|
|
|
|
2011-04-13 06:53:02 +08:00
|
|
|
// Accessors.
|
2013-12-10 07:32:48 +08:00
|
|
|
DIVariable getVariable() const { return Var; }
|
2015-04-16 06:29:27 +08:00
|
|
|
DILocation getInlinedAt() const { return IA; }
|
2015-02-11 07:18:28 +08:00
|
|
|
const ArrayRef<DIExpression> getExpression() const { return Expr; }
|
2014-04-26 01:32:19 +08:00
|
|
|
void setDIE(DIE &D) { TheDIE = &D; }
|
2013-12-10 07:32:48 +08:00
|
|
|
DIE *getDIE() const { return TheDIE; }
|
|
|
|
void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; }
|
|
|
|
unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; }
|
2015-04-14 10:22:36 +08:00
|
|
|
StringRef getName() const { return Var->getName(); }
|
2013-12-10 07:32:48 +08:00
|
|
|
const MachineInstr *getMInsn() const { return MInsn; }
|
2015-02-11 07:18:28 +08:00
|
|
|
const ArrayRef<int> getFrameIndex() const { return FrameIndex; }
|
|
|
|
|
|
|
|
void addMMIEntry(const DbgVariable &V) {
|
|
|
|
assert( DotDebugLocOffset == ~0U && !MInsn && "not an MMI entry");
|
|
|
|
assert(V.DotDebugLocOffset == ~0U && !V.MInsn && "not an MMI entry");
|
|
|
|
assert(V.Var == Var && "conflicting DIVariable");
|
2015-04-16 06:29:27 +08:00
|
|
|
assert(V.IA == IA && "conflicting inlined-at location");
|
2015-02-11 07:18:28 +08:00
|
|
|
|
|
|
|
if (V.getFrameIndex().back() != ~0) {
|
|
|
|
auto E = V.getExpression();
|
|
|
|
auto FI = V.getFrameIndex();
|
|
|
|
Expr.append(E.begin(), E.end());
|
|
|
|
FrameIndex.append(FI.begin(), FI.end());
|
|
|
|
}
|
|
|
|
assert(Expr.size() > 1
|
2015-04-14 09:12:42 +08:00
|
|
|
? std::all_of(Expr.begin(), Expr.end(),
|
|
|
|
[](DIExpression &E) { return E->isBitPiece(); })
|
|
|
|
: (true && "conflicting locations for variable"));
|
2015-02-11 07:18:28 +08:00
|
|
|
}
|
|
|
|
|
2012-11-21 08:03:28 +08:00
|
|
|
// Translate tag to proper Dwarf tag.
|
2014-04-12 10:24:04 +08:00
|
|
|
dwarf::Tag getTag() const {
|
2015-04-14 10:22:36 +08:00
|
|
|
if (Var->getTag() == dwarf::DW_TAG_arg_variable)
|
2011-08-16 02:35:42 +08:00
|
|
|
return dwarf::DW_TAG_formal_parameter;
|
2012-11-21 08:03:28 +08:00
|
|
|
|
2011-08-16 02:35:42 +08:00
|
|
|
return dwarf::DW_TAG_variable;
|
|
|
|
}
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Return true if DbgVariable is artificial.
|
2013-12-10 07:32:48 +08:00
|
|
|
bool isArtificial() const {
|
2015-04-14 10:22:36 +08:00
|
|
|
if (Var->isArtificial())
|
2011-08-16 02:40:16 +08:00
|
|
|
return true;
|
2015-04-16 09:01:28 +08:00
|
|
|
if (getType()->isArtificial())
|
2011-08-16 02:40:16 +08:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2012-09-13 07:36:19 +08:00
|
|
|
|
2013-12-10 07:32:48 +08:00
|
|
|
bool isObjectPointer() const {
|
2015-04-14 10:22:36 +08:00
|
|
|
if (Var->isObjectPointer())
|
2012-09-13 07:36:19 +08:00
|
|
|
return true;
|
2015-04-16 09:01:28 +08:00
|
|
|
if (getType()->isObjectPointer())
|
2012-09-13 07:36:19 +08:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-21 08:03:28 +08:00
|
|
|
|
2013-12-10 07:32:48 +08:00
|
|
|
bool variableHasComplexAddress() const {
|
2015-04-07 07:27:40 +08:00
|
|
|
assert(Var && "Invalid complex DbgVariable!");
|
2015-02-11 07:18:28 +08:00
|
|
|
assert(Expr.size() == 1 &&
|
|
|
|
"variableHasComplexAddress() invoked on multi-FI variable");
|
2015-04-14 09:12:42 +08:00
|
|
|
return Expr.back()->getNumElements() > 0;
|
2011-04-13 06:53:02 +08:00
|
|
|
}
|
2014-03-18 10:34:58 +08:00
|
|
|
bool isBlockByrefVariable() const;
|
2011-04-13 06:53:02 +08:00
|
|
|
DIType getType() const;
|
2013-10-09 03:07:44 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
/// resolve - Look in the DwarfDebug map for the MDNode that
|
|
|
|
/// corresponds to the reference.
|
2015-04-16 10:24:01 +08:00
|
|
|
template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const;
|
2011-04-13 06:53:02 +08:00
|
|
|
};
|
|
|
|
|
2012-12-11 07:34:43 +08:00
|
|
|
|
2013-10-25 05:20:23 +08:00
|
|
|
/// \brief Helper used to pair up a symbol and its DWARF compile unit.
|
2013-09-20 07:21:01 +08:00
|
|
|
struct SymbolCU {
|
2013-12-10 07:57:44 +08:00
|
|
|
SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
|
2013-09-20 07:21:01 +08:00
|
|
|
const MCSymbol *Sym;
|
2013-12-10 07:57:44 +08:00
|
|
|
DwarfCompileUnit *CU;
|
2013-09-20 07:21:01 +08:00
|
|
|
};
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Collects and handles dwarf debug information.
|
2013-12-03 23:10:23 +08:00
|
|
|
class DwarfDebug : public AsmPrinterHandler {
|
2012-11-28 06:43:45 +08:00
|
|
|
// Target of Dwarf emission.
|
2010-04-05 08:13:49 +08:00
|
|
|
AsmPrinter *Asm;
|
2010-04-05 13:31:04 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
// Collected machine module information.
|
2010-04-05 08:13:49 +08:00
|
|
|
MachineModuleInfo *MMI;
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
// All DIEValues are allocated through this allocator.
|
2012-06-09 18:34:15 +08:00
|
|
|
BumpPtrAllocator DIEValueAllocator;
|
|
|
|
|
2013-12-10 07:57:44 +08:00
|
|
|
// Maps MDNode with its corresponding DwarfCompileUnit.
|
2014-01-30 06:06:23 +08:00
|
|
|
MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2013-12-10 07:57:44 +08:00
|
|
|
// Maps subprogram MDNode with its corresponding DwarfCompileUnit.
|
2014-10-11 00:59:52 +08:00
|
|
|
MapVector<const MDNode *, DwarfCompileUnit *> SPMap;
|
2011-08-17 06:09:43 +08:00
|
|
|
|
2013-12-10 07:57:44 +08:00
|
|
|
// Maps a CU DIE with its corresponding DwarfCompileUnit.
|
|
|
|
DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
|
2013-10-30 06:57:10 +08:00
|
|
|
|
2013-10-03 16:54:43 +08:00
|
|
|
// List of all labels used in aranges generation.
|
|
|
|
std::vector<SymbolCU> ArangeLabels;
|
2013-09-20 07:21:01 +08:00
|
|
|
|
2013-09-24 01:56:20 +08:00
|
|
|
// Size of each symbol emitted (for those symbols that have a specific size).
|
2013-12-10 07:32:48 +08:00
|
|
|
DenseMap<const MCSymbol *, uint64_t> SymSize;
|
2013-09-24 01:56:20 +08:00
|
|
|
|
2011-08-11 04:55:27 +08:00
|
|
|
LexicalScopes LScopes;
|
2010-03-25 23:09:44 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
// Collection of abstract variables.
|
2014-05-22 06:41:17 +08:00
|
|
|
DenseMap<const MDNode *, std::unique_ptr<DbgVariable>> AbstractVariables;
|
2014-06-14 06:18:23 +08:00
|
|
|
SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables;
|
2009-11-11 07:06:00 +08:00
|
|
|
|
2014-04-02 09:43:18 +08:00
|
|
|
// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
|
|
|
|
// can refer to them in spite of insertions into this list.
|
|
|
|
SmallVector<DebugLocList, 4> DotDebugLocEntries;
|
2010-05-26 07:40:22 +08:00
|
|
|
|
2012-12-21 05:58:40 +08:00
|
|
|
// This is a collection of subprogram MDNodes that are processed to
|
|
|
|
// create DIEs.
|
2010-06-29 02:25:03 +08:00
|
|
|
SmallPtrSet<const MDNode *, 16> ProcessedSPNodes;
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
// Maps instruction with label emitted before instruction.
|
2010-04-28 03:46:33 +08:00
|
|
|
DenseMap<const MachineInstr *, MCSymbol *> LabelsBeforeInsn;
|
2010-04-09 00:50:29 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
// Maps instruction with label emitted after instruction.
|
2010-04-28 03:46:33 +08:00
|
|
|
DenseMap<const MachineInstr *, MCSymbol *> LabelsAfterInsn;
|
2010-04-09 00:50:29 +08:00
|
|
|
|
2014-05-01 05:34:11 +08:00
|
|
|
// History of DBG_VALUE and clobber instructions for each user variable.
|
2014-05-01 07:02:40 +08:00
|
|
|
// Variables are listed in order of appearance.
|
2011-03-26 10:19:36 +08:00
|
|
|
DbgValueHistoryMap DbgValues;
|
2011-03-23 06:33:08 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
// Previous instruction's location information. This is used to determine
|
|
|
|
// label location to indicate scope boundries in dwarf debug info.
|
2010-04-03 03:42:39 +08:00
|
|
|
DebugLoc PrevInstLoc;
|
2010-04-17 07:33:45 +08:00
|
|
|
MCSymbol *PrevLabel;
|
2010-03-30 01:20:31 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
// This location indicates end of function prologue and beginning of function
|
|
|
|
// body.
|
2011-05-12 03:22:19 +08:00
|
|
|
DebugLoc PrologEndLoc;
|
|
|
|
|
2013-12-03 23:10:23 +08:00
|
|
|
// If nonnull, stores the current machine function we're processing.
|
|
|
|
const MachineFunction *CurFn;
|
|
|
|
|
|
|
|
// If nonnull, stores the current machine instruction we're processing.
|
|
|
|
const MachineInstr *CurMI;
|
|
|
|
|
2014-03-21 03:16:16 +08:00
|
|
|
// If nonnull, stores the CU in which the previous subprogram was contained.
|
|
|
|
const DwarfCompileUnit *PrevCU;
|
|
|
|
|
2011-11-03 04:55:33 +08:00
|
|
|
// As an optimization, there is no need to emit an entry in the directory
|
2013-07-03 09:57:23 +08:00
|
|
|
// table for the same directory as DW_AT_comp_dir.
|
2011-11-03 04:55:33 +08:00
|
|
|
StringRef CompilationDir;
|
|
|
|
|
2012-12-11 07:34:43 +08:00
|
|
|
// Holder for the file specific debug information.
|
2013-12-06 02:06:10 +08:00
|
|
|
DwarfFile InfoHolder;
|
2012-12-11 07:34:43 +08:00
|
|
|
|
2012-11-21 08:17:49 +08:00
|
|
|
// Holders for the various debug information flags that we might need to
|
|
|
|
// have exposed. See accessor functions below for description.
|
2012-11-30 06:56:13 +08:00
|
|
|
|
2013-07-03 09:57:26 +08:00
|
|
|
// Holder for imported entities.
|
|
|
|
typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32>
|
2013-12-10 07:32:48 +08:00
|
|
|
ImportedEntityMap;
|
2013-07-03 09:57:26 +08:00
|
|
|
ImportedEntityMap ScopesWithImportedEntities;
|
|
|
|
|
2013-12-18 07:32:35 +08:00
|
|
|
// Map from MDNodes for user-defined types to the type units that describe
|
|
|
|
// them.
|
|
|
|
DenseMap<const MDNode *, const DwarfTypeUnit *> DwarfTypeUnits;
|
2013-07-27 01:02:41 +08:00
|
|
|
|
2015-02-18 04:02:28 +08:00
|
|
|
SmallVector<std::pair<std::unique_ptr<DwarfTypeUnit>, DICompositeType>, 1>
|
|
|
|
TypeUnitsUnderConstruction;
|
2014-04-27 01:27:38 +08:00
|
|
|
|
2013-08-27 07:24:35 +08:00
|
|
|
// Whether to emit the pubnames/pubtypes sections.
|
|
|
|
bool HasDwarfPubSections;
|
|
|
|
|
2014-01-15 08:04:29 +08:00
|
|
|
// Whether or not to use AT_ranges for compilation units.
|
|
|
|
bool HasCURanges;
|
|
|
|
|
2014-01-28 08:49:26 +08:00
|
|
|
// Whether we emitted a function into a section other than the default
|
|
|
|
// text.
|
|
|
|
bool UsedNonDefaultText;
|
|
|
|
|
2015-03-05 04:55:11 +08:00
|
|
|
// Whether to use the GNU TLS opcode (instead of the standard opcode).
|
|
|
|
bool UseGNUTLSOpcode;
|
|
|
|
|
2013-08-27 07:24:35 +08:00
|
|
|
// Version of dwarf we're emitting.
|
|
|
|
unsigned DwarfVersion;
|
|
|
|
|
2013-11-22 06:56:11 +08:00
|
|
|
// Maps from a type identifier to the actual MDNode.
|
|
|
|
DITypeIdentifierMap TypeIdentifierMap;
|
|
|
|
|
2012-11-30 06:56:13 +08:00
|
|
|
// DWARF5 Experimental Options
|
2012-11-21 08:34:35 +08:00
|
|
|
bool HasDwarfAccelTables;
|
2012-12-11 03:51:21 +08:00
|
|
|
bool HasSplitDwarf;
|
2013-07-03 07:40:10 +08:00
|
|
|
|
2012-12-12 03:42:09 +08:00
|
|
|
// Separated Dwarf Variables
|
2012-12-11 03:51:13 +08:00
|
|
|
// In general these will all be for bits that are left in the
|
|
|
|
// original object file, rather than things that are meant
|
|
|
|
// to be in the .dwo sections.
|
|
|
|
|
2012-12-27 10:14:01 +08:00
|
|
|
// Holder for the skeleton information.
|
2013-12-06 02:06:10 +08:00
|
|
|
DwarfFile SkeletonHolder;
|
2012-12-11 03:51:13 +08:00
|
|
|
|
2014-03-19 08:11:28 +08:00
|
|
|
/// Store file names for type units under fission in a line table header that
|
|
|
|
/// will be emitted into debug_line.dwo.
|
|
|
|
// FIXME: replace this with a map from comp_dir to table so that we can emit
|
|
|
|
// multiple tables during LTO each of which uses directory 0, referencing the
|
|
|
|
// comp_dir of all the type units that use it.
|
2014-03-18 10:13:23 +08:00
|
|
|
MCDwarfDwoLineTable SplitTypeUnitFileTable;
|
2014-03-18 09:17:26 +08:00
|
|
|
|
2014-03-19 08:11:28 +08:00
|
|
|
// True iff there are multiple CUs in this module.
|
|
|
|
bool SingleCU;
|
Disable the -gmlt optimization implemented in r218129 under Darwin due to issues with dsymutil.
r218129 omits DW_TAG_subprograms which have no inlined subroutines when
emitting -gmlt data. This makes -gmlt very low cost for -O0 builds.
Darwin's dsymutil reasonably considers a CU empty if it has no
subprograms (which occurs with the above optimization in -O0 programs
without any force_inline function calls) and drops the line table, CU,
and everything in this situation, making backtraces impossible.
Until dsymutil is modified to account for this, disable this
optimization on Darwin to preserve the desired functionality.
(see r218545, which should be reverted after this patch, for other
discussion/details)
Footnote:
In the long term, it doesn't look like this scheme (of simplified debug
info to describe inlining to enable backtracing) is tenable, it is far
too size inefficient for optimized code (the DW_TAG_inlined_subprograms,
even once compressed, are nearly twice as large as the line table
itself (also compressed)) and we'll be considering things like Cary's
two level line table proposal to encode all this information directly in
the line table.
llvm-svn: 218702
2014-10-01 05:28:32 +08:00
|
|
|
bool IsDarwin;
|
2015-03-05 04:55:11 +08:00
|
|
|
bool IsPS4;
|
2014-03-19 08:11:28 +08:00
|
|
|
|
2014-04-24 05:20:10 +08:00
|
|
|
AddressPool AddrPool;
|
|
|
|
|
2014-04-24 07:37:35 +08:00
|
|
|
DwarfAccelTable AccelNames;
|
2014-04-24 08:53:32 +08:00
|
|
|
DwarfAccelTable AccelObjC;
|
2014-04-24 09:02:42 +08:00
|
|
|
DwarfAccelTable AccelNamespace;
|
2014-04-24 09:23:49 +08:00
|
|
|
DwarfAccelTable AccelTypes;
|
2014-04-24 07:37:35 +08:00
|
|
|
|
Recommit r212203: Don't try to construct debug LexicalScopes hierarchy for functions that do not have top level debug information.
Reverted by Eric Christopher (Thanks!) in r212203 after Bob Wilson
reported LTO issues. Duncan Exon Smith and Aditya Nandakumar helped
provide a reduced reproduction, though the failure wasn't too hard to
guess, and even easier with the example to confirm.
The assertion that the subprogram metadata associated with an
llvm::Function matches the scope data referenced by the DbgLocs on the
instructions in that function is not valid under LTO. In LTO, a C++
inline function might exist in multiple CUs and the subprogram metadata
nodes will refer to the same llvm::Function. In this case, depending on
the order of the CUs, the first intance of the subprogram metadata may
not be the one referenced by the instructions in that function and the
assertion will fail.
A test case (test/DebugInfo/cross-cu-linkonce-distinct.ll) is added, the
assertion removed and a comment added to explain this situation.
This was then reverted again in r213581 as it caused PR20367. The root
cause of this was the early exit in LiveDebugVariables meant that
spurious DBG_VALUE intrinsics that referenced dead variables were not
removed, causing an assertion/crash later on. The fix is to have
LiveDebugVariables strip all DBG_VALUE intrinsics in functions without
debug info as they're not needed anyway. Test case added to cover this
situation (that occurs when a debug-having function is inlined into a
nodebug function) in test/DebugInfo/X86/nodebug_with_debug_loc.ll
Original commit message:
If a function isn't actually in a CU's subprogram list in the debug info
metadata, ignore all the DebugLocs and don't try to build scopes, track
variables, etc.
While this is possibly a minor optimization, it's also a correctness fix
for an incoming patch that will add assertions to LexicalScopes and the
debug info verifier to ensure that all scope chains lead to debug info
for the current function.
Fix up a few test cases that had broken/incomplete debug info that could
violate this constraint.
Add a test case where this occurs by design (inlining a
debug-info-having function in an attribute nodebug function - we want
this to work because /if/ the nodebug function is then inlined into a
debug-info-having function, it should be fine (and will work fine - we
just stitch the scopes up as usual), but should the inlining not happen
we need to not assert fail either).
llvm-svn: 213952
2014-07-26 00:10:16 +08:00
|
|
|
DenseMap<const Function *, DISubprogram> FunctionDIs;
|
|
|
|
|
2014-03-19 08:11:28 +08:00
|
|
|
MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
|
|
|
|
|
2014-04-23 05:27:37 +08:00
|
|
|
const SmallVectorImpl<std::unique_ptr<DwarfUnit>> &getUnits() {
|
2013-12-10 07:32:48 +08:00
|
|
|
return InfoHolder.getUnits();
|
|
|
|
}
|
2013-11-27 03:14:34 +08:00
|
|
|
|
2015-04-16 06:29:27 +08:00
|
|
|
typedef DbgValueHistoryMap::InlinedVariable InlinedVariable;
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Find abstract variable associated with Var.
|
2015-04-16 06:29:27 +08:00
|
|
|
DbgVariable *getExistingAbstractVariable(InlinedVariable IV,
|
2014-06-05 07:50:52 +08:00
|
|
|
DIVariable &Cleansed);
|
2015-04-16 06:29:27 +08:00
|
|
|
DbgVariable *getExistingAbstractVariable(InlinedVariable IV);
|
2014-06-14 07:52:55 +08:00
|
|
|
void createAbstractVariable(const DIVariable &DV, LexicalScope *Scope);
|
2015-04-16 06:29:27 +08:00
|
|
|
void ensureAbstractVariableIsCreated(InlinedVariable Var,
|
2014-06-14 07:52:55 +08:00
|
|
|
const MDNode *Scope);
|
2015-04-16 06:29:27 +08:00
|
|
|
void ensureAbstractVariableIsCreatedIfScoped(InlinedVariable Var,
|
2014-06-14 07:52:55 +08:00
|
|
|
const MDNode *Scope);
|
2009-11-11 07:06:00 +08:00
|
|
|
|
2014-04-29 23:58:35 +08:00
|
|
|
/// \brief Construct a DIE for this abstract scope.
|
2014-10-10 04:36:27 +08:00
|
|
|
void constructAbstractSubprogramScopeDIE(LexicalScope *Scope);
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Compute the size and offset of a DIE given an incoming Offset.
|
2012-11-21 06:14:13 +08:00
|
|
|
unsigned computeSizeAndOffset(DIE *Die, unsigned Offset);
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Compute the size and offset of all the DIEs.
|
2009-11-21 10:48:08 +08:00
|
|
|
void computeSizeAndOffsets();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Collect info for variables that were optimized out.
|
2012-11-22 08:59:49 +08:00
|
|
|
void collectDeadVariables();
|
|
|
|
|
2014-06-14 06:18:23 +08:00
|
|
|
void finishVariableDefinitions();
|
|
|
|
|
DebugInfo: Lazily attach definition attributes to definitions.
This is a precursor to fixing inlined debug info where the concrete,
out-of-line definition may preceed any inlined usage. To cope with this,
the attributes that may appear on the concrete definition or the
abstract definition are delayed until the end of the module. Then, if an
abstract definition was created, it is referenced (and no other
attributes are added to the out-of-line definition), otherwise the
attributes are added directly to the out-of-line definition.
In a couple of cases this causes not just reordering of attributes, but
reordering of types. When the creation of the attribute is delayed, if
that creation would create a type (such as for a DW_AT_type attribute)
then other top level DIEs may've been constructed during the delay,
causing the referenced type to be created and added after those
intervening DIEs. In the extreme case, in cross-cu-inlining.ll, this
actually causes the DW_TAG_basic_type for "int" to move from one CU to
another.
llvm-svn: 209674
2014-05-28 02:37:43 +08:00
|
|
|
void finishSubprogramDefinitions();
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Finish off debug information after all functions have been
|
|
|
|
/// processed.
|
2012-11-22 08:59:49 +08:00
|
|
|
void finalizeModuleInfo();
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit the debug info section.
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugInfo();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit the abbreviation section.
|
2012-11-21 07:30:11 +08:00
|
|
|
void emitAbbreviations();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2014-09-12 05:12:48 +08:00
|
|
|
/// \brief Emit a specified accelerator table.
|
|
|
|
void emitAccel(DwarfAccelTable &Accel, const MCSection *Section,
|
2015-03-11 06:00:25 +08:00
|
|
|
StringRef TableName);
|
2014-09-12 05:12:48 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit visible names into a hashed accelerator table section.
|
2011-11-07 17:24:32 +08:00
|
|
|
void emitAccelNames();
|
2012-11-21 08:03:28 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit objective C classes and categories into a hashed
|
2011-11-07 17:24:32 +08:00
|
|
|
/// accelerator table section.
|
|
|
|
void emitAccelObjC();
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit namespace dies into a hashed accelerator table.
|
2011-11-07 17:24:32 +08:00
|
|
|
void emitAccelNamespaces();
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit type dies into a hashed accelerator table.
|
2011-11-07 17:24:32 +08:00
|
|
|
void emitAccelTypes();
|
2012-11-21 08:03:28 +08:00
|
|
|
|
2013-02-13 02:00:14 +08:00
|
|
|
/// \brief Emit visible names into a debug pubnames section.
|
2013-09-13 08:35:05 +08:00
|
|
|
/// \param GnuStyle determines whether or not we want to emit
|
|
|
|
/// additional information into the table ala newer gcc for gdb
|
|
|
|
/// index.
|
|
|
|
void emitDebugPubNames(bool GnuStyle = false);
|
2013-02-13 02:00:14 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit visible types into a debug pubtypes section.
|
2013-09-13 08:35:05 +08:00
|
|
|
/// \param GnuStyle determines whether or not we want to emit
|
|
|
|
/// additional information into the table ala newer gcc for gdb
|
|
|
|
/// index.
|
|
|
|
void emitDebugPubTypes(bool GnuStyle = false);
|
2009-11-24 09:14:22 +08:00
|
|
|
|
2014-11-02 14:16:39 +08:00
|
|
|
void emitDebugPubSection(
|
|
|
|
bool GnuStyle, const MCSection *PSec, StringRef Name,
|
|
|
|
const StringMap<const DIE *> &(DwarfCompileUnit::*Accessor)() const);
|
2014-03-12 07:18:15 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit visible names into a debug str section.
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugStr();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit visible names into a debug loc section.
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugLoc();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2014-04-02 09:50:20 +08:00
|
|
|
/// \brief Emit visible names into a debug loc dwo section.
|
|
|
|
void emitDebugLocDWO();
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit visible names into a debug aranges section.
|
2012-11-21 08:34:35 +08:00
|
|
|
void emitDebugARanges();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit visible names into a debug ranges section.
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugRanges();
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit inline info using custom format.
|
2009-11-21 10:48:08 +08:00
|
|
|
void emitDebugInlineInfo();
|
2009-05-21 07:19:06 +08:00
|
|
|
|
2012-12-11 03:51:21 +08:00
|
|
|
/// DWARF 5 Experimental Split Dwarf Emitters
|
2012-12-01 07:59:06 +08:00
|
|
|
|
2014-01-09 12:28:46 +08:00
|
|
|
/// \brief Initialize common features of skeleton units.
|
2014-04-26 02:26:14 +08:00
|
|
|
void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
|
2014-04-23 06:39:41 +08:00
|
|
|
std::unique_ptr<DwarfUnit> NewU);
|
2014-01-09 12:28:46 +08:00
|
|
|
|
2012-12-11 03:51:21 +08:00
|
|
|
/// \brief Construct the split debug info compile unit for the debug info
|
|
|
|
/// section.
|
2014-04-23 06:39:41 +08:00
|
|
|
DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
|
2012-12-01 07:59:06 +08:00
|
|
|
|
2014-01-10 09:38:41 +08:00
|
|
|
/// \brief Construct the split debug info compile unit for the debug info
|
|
|
|
/// section.
|
2014-04-23 06:39:41 +08:00
|
|
|
DwarfTypeUnit &constructSkeletonTU(DwarfTypeUnit &TU);
|
2014-01-10 09:38:41 +08:00
|
|
|
|
2012-12-01 07:59:06 +08:00
|
|
|
/// \brief Emit the debug info dwo section.
|
|
|
|
void emitDebugInfoDWO();
|
|
|
|
|
2012-12-20 06:02:53 +08:00
|
|
|
/// \brief Emit the debug abbrev dwo section.
|
|
|
|
void emitDebugAbbrevDWO();
|
|
|
|
|
2014-03-18 09:17:26 +08:00
|
|
|
/// \brief Emit the debug line dwo section.
|
|
|
|
void emitDebugLineDWO();
|
|
|
|
|
2012-12-27 10:14:01 +08:00
|
|
|
/// \brief Emit the debug str dwo section.
|
|
|
|
void emitDebugStrDWO();
|
|
|
|
|
2013-12-05 05:31:26 +08:00
|
|
|
/// Flags to let the linker know we have emitted new style pubnames. Only
|
|
|
|
/// emit it here if we don't have a skeleton CU for split dwarf.
|
2014-04-26 02:26:14 +08:00
|
|
|
void addGnuPubAttributes(DwarfUnit &U, DIE &D) const;
|
2013-12-05 05:31:26 +08:00
|
|
|
|
2013-12-10 07:57:44 +08:00
|
|
|
/// \brief Create new DwarfCompileUnit for the given metadata node with tag
|
2012-11-28 06:43:45 +08:00
|
|
|
/// DW_TAG_compile_unit.
|
2014-04-23 06:39:41 +08:00
|
|
|
DwarfCompileUnit &constructDwarfCompileUnit(DICompileUnit DIUnit);
|
2010-05-11 06:49:55 +08:00
|
|
|
|
2013-05-08 05:35:53 +08:00
|
|
|
/// \brief Construct imported_module or imported_declaration DIE.
|
2014-08-31 13:41:15 +08:00
|
|
|
void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
|
|
|
|
const MDNode *N);
|
2013-05-07 07:33:07 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Register a source line with debug info. Returns the unique
|
|
|
|
/// label that was emitted and which provides correspondence to the
|
|
|
|
/// source line list.
|
2011-05-12 03:22:19 +08:00
|
|
|
void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
|
|
|
|
unsigned Flags);
|
2012-11-21 08:03:28 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Indentify instructions that are marking the beginning of or
|
|
|
|
/// ending of a scope.
|
2010-04-09 02:43:56 +08:00
|
|
|
void identifyScopeMarkers();
|
2010-04-08 23:37:09 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Populate LexicalScope entries with variables' info.
|
2014-10-23 08:06:27 +08:00
|
|
|
void collectVariableInfo(DwarfCompileUnit &TheCU, DISubprogram SP,
|
2015-04-16 06:29:27 +08:00
|
|
|
DenseSet<InlinedVariable> &ProcessedVars);
|
2012-11-21 08:03:28 +08:00
|
|
|
|
2014-08-02 06:11:58 +08:00
|
|
|
/// \brief Build the location list for all DBG_VALUEs in the
|
|
|
|
/// function that describe the same variable.
|
|
|
|
void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
|
2014-08-06 07:14:16 +08:00
|
|
|
const DbgValueHistoryMap::InstrRanges &Ranges);
|
2014-08-02 06:11:58 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Collect variable information from the side table maintained
|
|
|
|
/// by MMI.
|
2015-04-16 06:29:27 +08:00
|
|
|
void collectVariableInfoFromMMITable(DenseSet<InlinedVariable> &P);
|
2011-03-26 10:19:36 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Ensure that a label will be emitted before MI.
|
2011-03-26 10:19:36 +08:00
|
|
|
void requestLabelBeforeInsn(const MachineInstr *MI) {
|
2014-04-28 12:05:08 +08:00
|
|
|
LabelsBeforeInsn.insert(std::make_pair(MI, nullptr));
|
2011-03-26 10:19:36 +08:00
|
|
|
}
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Ensure that a label will be emitted after MI.
|
2011-03-26 10:19:36 +08:00
|
|
|
void requestLabelAfterInsn(const MachineInstr *MI) {
|
2014-04-28 12:05:08 +08:00
|
|
|
LabelsAfterInsn.insert(std::make_pair(MI, nullptr));
|
2011-03-26 10:19:36 +08:00
|
|
|
}
|
|
|
|
|
2010-04-05 13:32:45 +08:00
|
|
|
public:
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Main entry points.
|
|
|
|
//
|
|
|
|
DwarfDebug(AsmPrinter *A, Module *M);
|
|
|
|
|
2014-05-01 04:34:31 +08:00
|
|
|
~DwarfDebug() override;
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit all Dwarf sections that should come prior to the
|
2010-04-05 13:32:45 +08:00
|
|
|
/// content.
|
2012-11-20 06:42:15 +08:00
|
|
|
void beginModule();
|
2010-04-05 13:32:45 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Emit all Dwarf sections that should come after the content.
|
2014-03-08 14:31:39 +08:00
|
|
|
void endModule() override;
|
2010-04-05 13:32:45 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Gather pre-function debug information.
|
2014-03-08 14:31:39 +08:00
|
|
|
void beginFunction(const MachineFunction *MF) override;
|
2010-04-05 13:32:45 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Gather and emit post-function debug information.
|
2014-03-08 14:31:39 +08:00
|
|
|
void endFunction(const MachineFunction *MF) override;
|
2009-05-15 17:23:25 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Process beginning of an instruction.
|
2014-03-08 14:31:39 +08:00
|
|
|
void beginInstruction(const MachineInstr *MI) override;
|
2009-11-11 07:06:00 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Process end of an instruction.
|
2014-03-08 14:31:39 +08:00
|
|
|
void endInstruction() override;
|
2011-04-13 06:53:02 +08:00
|
|
|
|
2013-07-27 01:02:41 +08:00
|
|
|
/// \brief Add a DIE to the set of types that we're going to pull into
|
|
|
|
/// type units.
|
2014-02-12 08:31:30 +08:00
|
|
|
void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
|
2014-04-26 02:26:14 +08:00
|
|
|
DIE &Die, DICompositeType CTy);
|
2013-07-27 01:02:41 +08:00
|
|
|
|
2013-09-20 07:21:01 +08:00
|
|
|
/// \brief Add a label so that arange data can be generated for it.
|
2013-10-03 16:54:43 +08:00
|
|
|
void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
|
2013-09-20 07:21:01 +08:00
|
|
|
|
2013-09-24 01:56:20 +08:00
|
|
|
/// \brief For symbols that have a size designated (e.g. common symbols),
|
|
|
|
/// this tracks that size.
|
2014-03-08 14:31:39 +08:00
|
|
|
void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
|
2013-12-10 07:32:48 +08:00
|
|
|
SymSize[Sym] = Size;
|
|
|
|
}
|
2013-09-24 01:56:20 +08:00
|
|
|
|
2015-03-05 04:55:11 +08:00
|
|
|
/// \brief Returns whether to use DW_OP_GNU_push_tls_address, instead of the
|
|
|
|
/// standard DW_OP_form_tls_address opcode
|
|
|
|
bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
|
|
|
|
|
2012-11-21 08:03:31 +08:00
|
|
|
// Experimental DWARF5 features.
|
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Returns whether or not to emit tables that dwarf consumers can
|
|
|
|
/// use to accelerate lookup.
|
2014-03-06 08:00:53 +08:00
|
|
|
bool useDwarfAccelTables() const { return HasDwarfAccelTables; }
|
2012-11-21 08:03:31 +08:00
|
|
|
|
2012-11-28 06:43:45 +08:00
|
|
|
/// \brief Returns whether or not to change the current debug info for the
|
2012-12-11 03:51:21 +08:00
|
|
|
/// split dwarf proposal support.
|
2014-03-06 08:00:53 +08:00
|
|
|
bool useSplitDwarf() const { return HasSplitDwarf; }
|
2013-07-03 07:40:10 +08:00
|
|
|
|
|
|
|
/// Returns the Dwarf Version.
|
|
|
|
unsigned getDwarfVersion() const { return DwarfVersion; }
|
2013-09-06 02:48:31 +08:00
|
|
|
|
2014-03-21 03:16:16 +08:00
|
|
|
/// Returns the previous CU that was being updated
|
|
|
|
const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
|
2014-09-10 07:13:01 +08:00
|
|
|
void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
|
2014-03-21 03:16:16 +08:00
|
|
|
|
2014-03-08 08:29:41 +08:00
|
|
|
/// Returns the entries for the .debug_loc section.
|
2014-04-02 09:43:18 +08:00
|
|
|
const SmallVectorImpl<DebugLocList> &
|
2014-03-25 06:38:38 +08:00
|
|
|
getDebugLocEntries() const {
|
2014-03-08 08:29:41 +08:00
|
|
|
return DotDebugLocEntries;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief Emit an entry for the debug loc section. This can be used to
|
|
|
|
/// handle an entry that's going to be emitted into the debug loc section.
|
2015-03-03 06:02:33 +08:00
|
|
|
void emitDebugLocEntry(ByteStreamer &Streamer,
|
|
|
|
const DebugLocEntry &Entry);
|
2014-08-02 06:11:58 +08:00
|
|
|
/// \brief emit a single value for the debug loc section.
|
|
|
|
void emitDebugLocValue(ByteStreamer &Streamer,
|
Debug Info: Move the complex expression handling (=the remainder) of
emitDebugLocValue() into DwarfExpression.
Ought to be NFC, but it actually uncovered a bug in the debug-loc-asan.ll
testcase. The testcase checks that the address of variable "y" is stored
at [RSP+16], which also lines up with the comment.
It also check(ed) that the *value* of "y" is stored in RDI before that,
but that is actually incorrect, since RDI is the very value that is
stored in [RSP+16]. Here's the assembler output:
movb 2147450880(%rcx), %r8b
#DEBUG_VALUE: bar:y <- RDI
cmpb $0, %r8b
movq %rax, 32(%rsp) # 8-byte Spill
movq %rsi, 24(%rsp) # 8-byte Spill
movq %rdi, 16(%rsp) # 8-byte Spill
.Ltmp3:
#DEBUG_VALUE: bar:y <- [RSP+16]
Fixed the comment to spell out the correct register and the check to
expect an address rather than a value.
Note that the range that is emitted for the RDI location was and is still
wrong, it claims to begin at the function prologue, but really it should
start where RDI is first assigned.
llvm-svn: 225851
2015-01-14 07:39:11 +08:00
|
|
|
const DebugLocEntry::Value &Value,
|
|
|
|
unsigned PieceOffsetInBits = 0);
|
2014-08-02 06:11:58 +08:00
|
|
|
/// Emits an optimal (=sorted) sequence of DW_OP_pieces.
|
|
|
|
void emitLocPieces(ByteStreamer &Streamer,
|
|
|
|
const DITypeIdentifierMap &Map,
|
|
|
|
ArrayRef<DebugLocEntry::Value> Values);
|
2014-03-08 08:29:41 +08:00
|
|
|
|
2014-04-02 00:17:41 +08:00
|
|
|
/// Emit the location for a debug loc entry, including the size header.
|
|
|
|
void emitDebugLocEntryLocation(const DebugLocEntry &Entry);
|
|
|
|
|
2013-10-05 08:32:34 +08:00
|
|
|
/// Find the MDNode for the given reference.
|
2015-04-07 12:14:33 +08:00
|
|
|
template <typename T> T *resolve(TypedDebugNodeRef<T> Ref) const {
|
|
|
|
return Ref.resolve(TypeIdentifierMap);
|
|
|
|
}
|
2013-09-06 02:48:31 +08:00
|
|
|
|
2014-03-18 10:34:58 +08:00
|
|
|
/// \brief Return the TypeIdentifierMap.
|
2014-03-19 04:39:54 +08:00
|
|
|
const DITypeIdentifierMap &getTypeIdentifierMap() const {
|
2014-03-18 10:34:58 +08:00
|
|
|
return TypeIdentifierMap;
|
|
|
|
}
|
|
|
|
|
2014-03-06 08:00:56 +08:00
|
|
|
/// Find the DwarfCompileUnit for the given CU Die.
|
|
|
|
DwarfCompileUnit *lookupUnit(const DIE *CU) const {
|
|
|
|
return CUDieMap.lookup(CU);
|
|
|
|
}
|
2013-09-10 03:05:21 +08:00
|
|
|
/// isSubprogramContext - Return true if Context is either a subprogram
|
|
|
|
/// or another context nested inside a subprogram.
|
|
|
|
bool isSubprogramContext(const MDNode *Context);
|
2014-04-24 05:20:10 +08:00
|
|
|
|
2014-04-26 02:52:29 +08:00
|
|
|
void addSubprogramNames(DISubprogram SP, DIE &Die);
|
2014-04-24 07:37:35 +08:00
|
|
|
|
2014-04-24 05:20:10 +08:00
|
|
|
AddressPool &getAddressPool() { return AddrPool; }
|
2014-04-24 07:37:35 +08:00
|
|
|
|
2014-04-26 02:52:29 +08:00
|
|
|
void addAccelName(StringRef Name, const DIE &Die);
|
2014-04-24 08:53:32 +08:00
|
|
|
|
2014-04-26 02:52:29 +08:00
|
|
|
void addAccelObjC(StringRef Name, const DIE &Die);
|
2014-04-24 09:02:42 +08:00
|
|
|
|
2014-04-26 02:52:29 +08:00
|
|
|
void addAccelNamespace(StringRef Name, const DIE &Die);
|
2014-04-24 09:23:49 +08:00
|
|
|
|
2014-04-26 02:52:29 +08:00
|
|
|
void addAccelType(StringRef Name, const DIE &Die, char Flags);
|
2014-10-05 00:24:00 +08:00
|
|
|
|
|
|
|
const MachineFunction *getCurrentFunction() const { return CurFn; }
|
2014-10-09 06:20:02 +08:00
|
|
|
|
2014-10-09 07:09:42 +08:00
|
|
|
iterator_range<ImportedEntityMap::const_iterator>
|
|
|
|
findImportedEntitiesForScope(const MDNode *Scope) const {
|
2014-10-09 06:20:02 +08:00
|
|
|
return make_range(std::equal_range(
|
|
|
|
ScopesWithImportedEntities.begin(), ScopesWithImportedEntities.end(),
|
2014-10-09 07:09:42 +08:00
|
|
|
std::pair<const MDNode *, const MDNode *>(Scope, nullptr),
|
|
|
|
less_first()));
|
2014-10-09 06:20:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// \brief A helper function to check whether the DIE for a given Scope is
|
|
|
|
/// going to be null.
|
|
|
|
bool isLexicalScopeDIENull(LexicalScope *Scope);
|
|
|
|
|
2014-10-10 00:50:53 +08:00
|
|
|
/// \brief Return Label preceding the instruction.
|
|
|
|
MCSymbol *getLabelBeforeInsn(const MachineInstr *MI);
|
|
|
|
|
|
|
|
/// \brief Return Label immediately following the instruction.
|
|
|
|
MCSymbol *getLabelAfterInsn(const MachineInstr *MI);
|
|
|
|
|
2014-10-09 06:20:02 +08:00
|
|
|
// FIXME: Sink these functions down into DwarfFile/Dwarf*Unit.
|
|
|
|
|
2014-10-10 04:21:36 +08:00
|
|
|
SmallPtrSet<const MDNode *, 16> &getProcessedSPNodes() {
|
|
|
|
return ProcessedSPNodes;
|
|
|
|
}
|
2009-11-11 07:06:00 +08:00
|
|
|
};
|
2009-05-15 17:23:25 +08:00
|
|
|
} // End of namespace llvm
|
|
|
|
|
|
|
|
#endif
|