2017-08-17 21:26:39 +00:00
|
|
|
//===- llvm/CodeGen/DwarfDebug.h - Dwarf Debug Framework --------*- C++ -*-===//
|
2009-05-15 09:23:25 +00:00
|
|
|
//
|
|
|
|
// 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-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
|
|
|
|
#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2017-08-17 21:26:39 +00:00
|
|
|
#include "AddressPool.h"
|
2018-07-24 06:17:45 +00:00
|
|
|
#include "DbgValueHistoryCalculator.h"
|
2016-02-10 20:55:49 +00:00
|
|
|
#include "DebugHandlerBase.h"
|
AsmPrinter: Create a unified .debug_loc stream
This commit removes `DebugLocList` and replaces it with
`DebugLocStream`.
- `DebugLocEntry` no longer contains its byte/comment streams.
- The `DebugLocEntry` list for a variable/inlined-at pair is allocated
on the stack, and released right after `DebugLocEntry::finalize()`
(possible because of the refactoring in r231023). Now, only one
list is in memory at a time now.
- There's a single unified stream for the `.debug_loc` section that
persists, stored in the new `DebugLocStream` data structure.
The last point is important: this collapses the nested `SmallVector<>`s
from `DebugLocList` into unified streams. We previously had something
like the following:
vec<tuple<Label, CU,
vec<tuple<BeginSym, EndSym,
vec<Value>,
vec<char>,
vec<string>>>>>
A `SmallVector` can avoid allocations, but is statically fairly large
for a vector: three pointers plus the size of the small storage, which
is the number of elements in small mode times the element size).
Nesting these is expensive, since an inner vector's size contributes to
the element size of an outer one. (Nesting any vector is expensive...)
In the old data structure, the outer vector's *element* size was 632B,
excluding allocation costs for when the middle and inner vectors
exceeded their small sizes. 312B of this was for the "three" pointers
in the vector-tree beneath it. If you assume 1M functions with an
average of 10 variable/inlined-at pairs each (in an LTO scenario),
that's almost 6GB (besides inner allocations), with almost 3GB for the
"three" pointers.
This came up in a heap profile a little while ago of a `clang -flto -g`
bootstrap, with `DwarfDebug::collectVariableInfo()` using something like
10-15% of the total memory.
With this commit, we have:
tuple<vec<tuple<Label, CU, Offset>>,
vec<tuple<BeginSym, EndSym, Offset, Offset>>,
vec<char>,
vec<string>>
The offsets are used to create `ArrayRef` slices of adjacent
`SmallVector`s. This reduces the number of vectors to four (unrelated
to the number of variable/inlined-at pairs), and caps the number of
allocations at the same number.
Besides saving memory and limiting allocations, this is NFC.
I don't know my way around this code very well yet, but I wonder if we
could go further: why stream to a side-table, instead of directly to the
output stream?
llvm-svn: 235229
2015-04-17 21:34:47 +00:00
|
|
|
#include "DebugLocStream.h"
|
2015-01-14 11:23:27 +00:00
|
|
|
#include "DwarfFile.h"
|
2017-08-17 21:26:39 +00:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2010-01-19 06:19:05 +00:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2015-04-15 22:29:27 +00:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2014-03-18 20:58:35 +00:00
|
|
|
#include "llvm/ADT/MapVector.h"
|
2017-08-17 21:26:39 +00:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2016-12-15 23:37:38 +00:00
|
|
|
#include "llvm/ADT/SetVector.h"
|
2014-03-18 20:58:35 +00:00
|
|
|
#include "llvm/ADT/SmallPtrSet.h"
|
2017-08-17 21:26:39 +00:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2014-03-18 20:58:35 +00:00
|
|
|
#include "llvm/ADT/StringMap.h"
|
2017-08-17 21:26:39 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/BinaryFormat/Dwarf.h"
|
2018-01-29 14:52:41 +00:00
|
|
|
#include "llvm/CodeGen/AccelTable.h"
|
2014-05-30 21:10:13 +00:00
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2017-08-17 21:26:39 +00:00
|
|
|
#include "llvm/IR/DebugInfoMetadata.h"
|
2014-03-18 20:58:35 +00:00
|
|
|
#include "llvm/IR/DebugLoc.h"
|
2017-08-17 21:26:39 +00:00
|
|
|
#include "llvm/IR/Metadata.h"
|
2014-03-18 01:17:26 +00:00
|
|
|
#include "llvm/MC/MCDwarf.h"
|
2010-04-05 05:24:55 +00:00
|
|
|
#include "llvm/Support/Allocator.h"
|
2015-12-16 19:58:30 +00:00
|
|
|
#include "llvm/Target/TargetOptions.h"
|
2017-08-17 21:26:39 +00:00
|
|
|
#include <cassert>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <limits>
|
2014-04-22 22:39:41 +00:00
|
|
|
#include <memory>
|
2017-08-17 21:26:39 +00:00
|
|
|
#include <utility>
|
|
|
|
#include <vector>
|
2014-04-22 22:39:41 +00:00
|
|
|
|
2009-05-15 09:23:25 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2014-03-18 02:34:52 +00:00
|
|
|
class AsmPrinter;
|
2014-03-07 22:40:37 +00:00
|
|
|
class ByteStreamer;
|
AsmPrinter: Create a unified .debug_loc stream
This commit removes `DebugLocList` and replaces it with
`DebugLocStream`.
- `DebugLocEntry` no longer contains its byte/comment streams.
- The `DebugLocEntry` list for a variable/inlined-at pair is allocated
on the stack, and released right after `DebugLocEntry::finalize()`
(possible because of the refactoring in r231023). Now, only one
list is in memory at a time now.
- There's a single unified stream for the `.debug_loc` section that
persists, stored in the new `DebugLocStream` data structure.
The last point is important: this collapses the nested `SmallVector<>`s
from `DebugLocList` into unified streams. We previously had something
like the following:
vec<tuple<Label, CU,
vec<tuple<BeginSym, EndSym,
vec<Value>,
vec<char>,
vec<string>>>>>
A `SmallVector` can avoid allocations, but is statically fairly large
for a vector: three pointers plus the size of the small storage, which
is the number of elements in small mode times the element size).
Nesting these is expensive, since an inner vector's size contributes to
the element size of an outer one. (Nesting any vector is expensive...)
In the old data structure, the outer vector's *element* size was 632B,
excluding allocation costs for when the middle and inner vectors
exceeded their small sizes. 312B of this was for the "three" pointers
in the vector-tree beneath it. If you assume 1M functions with an
average of 10 variable/inlined-at pairs each (in an LTO scenario),
that's almost 6GB (besides inner allocations), with almost 3GB for the
"three" pointers.
This came up in a heap profile a little while ago of a `clang -flto -g`
bootstrap, with `DwarfDebug::collectVariableInfo()` using something like
10-15% of the total memory.
With this commit, we have:
tuple<vec<tuple<Label, CU, Offset>>,
vec<tuple<BeginSym, EndSym, Offset, Offset>>,
vec<char>,
vec<string>>
The offsets are used to create `ArrayRef` slices of adjacent
`SmallVector`s. This reduces the number of vectors to four (unrelated
to the number of variable/inlined-at pairs), and caps the number of
allocations at the same number.
Besides saving memory and limiting allocations, this is NFC.
I don't know my way around this code very well yet, but I wonder if we
could go further: why stream to a side-table, instead of directly to the
output stream?
llvm-svn: 235229
2015-04-17 21:34:47 +00:00
|
|
|
class DebugLocEntry;
|
2017-08-17 21:26:39 +00:00
|
|
|
class DIE;
|
2014-03-18 20:37:10 +00:00
|
|
|
class DwarfCompileUnit;
|
|
|
|
class DwarfTypeUnit;
|
|
|
|
class DwarfUnit;
|
2017-08-17 21:26:39 +00:00
|
|
|
class LexicalScope;
|
|
|
|
class MachineFunction;
|
|
|
|
class MCSection;
|
|
|
|
class MCSymbol;
|
|
|
|
class MDNode;
|
|
|
|
class Module;
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2011-04-12 22:53:02 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
/// This class is used to track local variable information.
|
2015-02-10 23:18:28 +00:00
|
|
|
///
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
/// Variables can be created from allocas, in which case they're generated from
|
|
|
|
/// the MMI table. Such variables can have multiple expressions and frame
|
2017-02-17 19:42:32 +00:00
|
|
|
/// indices.
|
2015-02-10 23:18:28 +00:00
|
|
|
///
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
/// Variables can be created from \c DBG_VALUE instructions. Those whose
|
|
|
|
/// location changes over time use \a DebugLocListIndex, while those with a
|
|
|
|
/// single instruction use \a MInsn and (optionally) a single entry of \a Expr.
|
|
|
|
///
|
|
|
|
/// Variables that have been optimized out use none of these fields.
|
2018-07-24 06:17:45 +00:00
|
|
|
class DbgVariable {
|
|
|
|
const DILocalVariable *Var; /// Variable Descriptor.
|
|
|
|
const DILocation *IA; /// Inlined at location.
|
|
|
|
DIE *TheDIE = nullptr; /// Variable DIE.
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
unsigned DebugLocListIndex = ~0u; /// Offset in DebugLocs.
|
|
|
|
const MachineInstr *MInsn = nullptr; /// DBG_VALUE instruction.
|
2017-02-17 19:42:32 +00:00
|
|
|
|
|
|
|
struct FrameIndexExpr {
|
|
|
|
int FI;
|
|
|
|
const DIExpression *Expr;
|
|
|
|
};
|
|
|
|
mutable SmallVector<FrameIndexExpr, 1>
|
|
|
|
FrameIndexExprs; /// Frame index + expression.
|
2013-12-09 23:32:48 +00:00
|
|
|
|
2011-04-12 22:53:02 +00:00
|
|
|
public:
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
/// Construct a DbgVariable.
|
|
|
|
///
|
|
|
|
/// Creates a variable without any DW_AT_location. Call \a initializeMMI()
|
|
|
|
/// for MMI entries, or \a initializeDbgValue() for DBG_VALUE instructions.
|
2016-04-23 21:08:00 +00:00
|
|
|
DbgVariable(const DILocalVariable *V, const DILocation *IA)
|
2018-07-24 06:17:45 +00:00
|
|
|
: Var(V), IA(IA) {}
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
|
|
|
|
/// Initialize from the MMI table.
|
|
|
|
void initializeMMI(const DIExpression *E, int FI) {
|
2017-02-17 19:42:32 +00:00
|
|
|
assert(FrameIndexExprs.empty() && "Already initialized?");
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
assert(!MInsn && "Already initialized?");
|
|
|
|
|
|
|
|
assert((!E || E->isValid()) && "Expected valid expression");
|
2017-08-17 21:26:39 +00:00
|
|
|
assert(FI != std::numeric_limits<int>::max() && "Expected valid index");
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
|
2017-02-17 19:42:32 +00:00
|
|
|
FrameIndexExprs.push_back({FI, E});
|
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-01 18:55:02 +00:00
|
|
|
}
|
2011-04-12 22:53:02 +00:00
|
|
|
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
/// Initialize from a DBG_VALUE instruction.
|
|
|
|
void initializeDbgValue(const MachineInstr *DbgValue) {
|
2017-02-17 19:42:32 +00:00
|
|
|
assert(FrameIndexExprs.empty() && "Already initialized?");
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
assert(!MInsn && "Already initialized?");
|
|
|
|
|
2018-07-24 06:17:45 +00:00
|
|
|
assert(Var == DbgValue->getDebugVariable() && "Wrong variable");
|
|
|
|
assert(IA == DbgValue->getDebugLoc()->getInlinedAt() && "Wrong inlined-at");
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
|
|
|
|
MInsn = DbgValue;
|
|
|
|
if (auto *E = DbgValue->getDebugExpression())
|
|
|
|
if (E->getNumElements())
|
2017-02-17 19:42:32 +00:00
|
|
|
FrameIndexExprs.push_back({0, E});
|
2015-02-10 23:18:28 +00:00
|
|
|
}
|
2014-05-30 21:10:13 +00:00
|
|
|
|
2011-04-12 22:53:02 +00:00
|
|
|
// Accessors.
|
2018-07-24 06:17:45 +00:00
|
|
|
const DILocalVariable *getVariable() const { return Var; }
|
|
|
|
const DILocation *getInlinedAt() const { return IA; }
|
2017-08-17 21:26:39 +00:00
|
|
|
|
2016-02-17 22:19:59 +00:00
|
|
|
const DIExpression *getSingleExpression() const {
|
2017-02-17 19:42:32 +00:00
|
|
|
assert(MInsn && FrameIndexExprs.size() <= 1);
|
|
|
|
return FrameIndexExprs.size() ? FrameIndexExprs[0].Expr : nullptr;
|
2016-02-17 22:19:59 +00:00
|
|
|
}
|
2017-08-17 21:26:39 +00:00
|
|
|
|
2018-07-24 06:17:45 +00:00
|
|
|
void setDIE(DIE &D) { TheDIE = &D; }
|
|
|
|
DIE *getDIE() const { return TheDIE; }
|
AsmPrinter: Create a unified .debug_loc stream
This commit removes `DebugLocList` and replaces it with
`DebugLocStream`.
- `DebugLocEntry` no longer contains its byte/comment streams.
- The `DebugLocEntry` list for a variable/inlined-at pair is allocated
on the stack, and released right after `DebugLocEntry::finalize()`
(possible because of the refactoring in r231023). Now, only one
list is in memory at a time now.
- There's a single unified stream for the `.debug_loc` section that
persists, stored in the new `DebugLocStream` data structure.
The last point is important: this collapses the nested `SmallVector<>`s
from `DebugLocList` into unified streams. We previously had something
like the following:
vec<tuple<Label, CU,
vec<tuple<BeginSym, EndSym,
vec<Value>,
vec<char>,
vec<string>>>>>
A `SmallVector` can avoid allocations, but is statically fairly large
for a vector: three pointers plus the size of the small storage, which
is the number of elements in small mode times the element size).
Nesting these is expensive, since an inner vector's size contributes to
the element size of an outer one. (Nesting any vector is expensive...)
In the old data structure, the outer vector's *element* size was 632B,
excluding allocation costs for when the middle and inner vectors
exceeded their small sizes. 312B of this was for the "three" pointers
in the vector-tree beneath it. If you assume 1M functions with an
average of 10 variable/inlined-at pairs each (in an LTO scenario),
that's almost 6GB (besides inner allocations), with almost 3GB for the
"three" pointers.
This came up in a heap profile a little while ago of a `clang -flto -g`
bootstrap, with `DwarfDebug::collectVariableInfo()` using something like
10-15% of the total memory.
With this commit, we have:
tuple<vec<tuple<Label, CU, Offset>>,
vec<tuple<BeginSym, EndSym, Offset, Offset>>,
vec<char>,
vec<string>>
The offsets are used to create `ArrayRef` slices of adjacent
`SmallVector`s. This reduces the number of vectors to four (unrelated
to the number of variable/inlined-at pairs), and caps the number of
allocations at the same number.
Besides saving memory and limiting allocations, this is NFC.
I don't know my way around this code very well yet, but I wonder if we
could go further: why stream to a side-table, instead of directly to the
output stream?
llvm-svn: 235229
2015-04-17 21:34:47 +00:00
|
|
|
void setDebugLocListIndex(unsigned O) { DebugLocListIndex = O; }
|
|
|
|
unsigned getDebugLocListIndex() const { return DebugLocListIndex; }
|
2018-07-24 06:17:45 +00:00
|
|
|
StringRef getName() const { return Var->getName(); }
|
2013-12-09 23:32:48 +00:00
|
|
|
const MachineInstr *getMInsn() const { return MInsn; }
|
2017-02-17 19:42:32 +00:00
|
|
|
/// Get the FI entries, sorted by fragment offset.
|
|
|
|
ArrayRef<FrameIndexExpr> getFrameIndexExprs() const;
|
|
|
|
bool hasFrameIndexExprs() const { return !FrameIndexExprs.empty(); }
|
2017-10-10 07:46:17 +00:00
|
|
|
void addMMIEntry(const DbgVariable &V);
|
2015-02-10 23:18:28 +00:00
|
|
|
|
2012-11-21 00:03:28 +00:00
|
|
|
// Translate tag to proper Dwarf tag.
|
2014-04-12 02:24:04 +00:00
|
|
|
dwarf::Tag getTag() const {
|
2015-07-31 18:58:39 +00:00
|
|
|
// FIXME: Why don't we just infer this tag and store it all along?
|
2018-07-24 06:17:45 +00:00
|
|
|
if (Var->isParameter())
|
2011-08-15 18:35:42 +00:00
|
|
|
return dwarf::DW_TAG_formal_parameter;
|
2012-11-21 00:03:28 +00:00
|
|
|
|
2011-08-15 18:35:42 +00:00
|
|
|
return dwarf::DW_TAG_variable;
|
|
|
|
}
|
2017-08-17 21:26:39 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Return true if DbgVariable is artificial.
|
2013-12-09 23:32:48 +00:00
|
|
|
bool isArtificial() const {
|
2018-07-24 06:17:45 +00:00
|
|
|
if (Var->isArtificial())
|
2011-08-15 18:40:16 +00:00
|
|
|
return true;
|
2015-04-16 01:01:28 +00:00
|
|
|
if (getType()->isArtificial())
|
2011-08-15 18:40:16 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2012-09-12 23:36:19 +00:00
|
|
|
|
2013-12-09 23:32:48 +00:00
|
|
|
bool isObjectPointer() const {
|
2018-07-24 06:17:45 +00:00
|
|
|
if (Var->isObjectPointer())
|
2012-09-12 23:36:19 +00:00
|
|
|
return true;
|
2015-04-16 01:01:28 +00:00
|
|
|
if (getType()->isObjectPointer())
|
2012-09-12 23:36:19 +00:00
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2012-11-21 00:03:28 +00:00
|
|
|
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
bool hasComplexAddress() const {
|
|
|
|
assert(MInsn && "Expected DBG_VALUE, not MMI variable");
|
2017-02-17 19:42:32 +00:00
|
|
|
assert((FrameIndexExprs.empty() ||
|
|
|
|
(FrameIndexExprs.size() == 1 &&
|
|
|
|
FrameIndexExprs[0].Expr->getNumElements())) &&
|
|
|
|
"Invalid Expr for DBG_VALUE");
|
|
|
|
return !FrameIndexExprs.empty();
|
2011-04-12 22:53:02 +00:00
|
|
|
}
|
2017-08-17 21:26:39 +00:00
|
|
|
|
2014-03-18 02:34:58 +00:00
|
|
|
bool isBlockByrefVariable() const;
|
2015-04-29 16:38:44 +00:00
|
|
|
const DIType *getType() const;
|
2013-10-08 19:07:44 +00:00
|
|
|
|
|
|
|
private:
|
2016-04-23 21:08:00 +00:00
|
|
|
template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
|
|
|
|
return Ref.resolve();
|
|
|
|
}
|
2011-04-12 22:53:02 +00:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Helper used to pair up a symbol and its DWARF compile unit.
|
2013-09-19 23:21:01 +00:00
|
|
|
struct SymbolCU {
|
2013-12-09 23:57:44 +00:00
|
|
|
SymbolCU(DwarfCompileUnit *CU, const MCSymbol *Sym) : Sym(Sym), CU(CU) {}
|
2017-08-17 21:26:39 +00:00
|
|
|
|
2013-09-19 23:21:01 +00:00
|
|
|
const MCSymbol *Sym;
|
2013-12-09 23:57:44 +00:00
|
|
|
DwarfCompileUnit *CU;
|
2013-09-19 23:21:01 +00:00
|
|
|
};
|
|
|
|
|
2018-04-04 14:42:14 +00:00
|
|
|
/// The kind of accelerator tables we should emit.
|
|
|
|
enum class AccelTableKind {
|
|
|
|
Default, ///< Platform default.
|
|
|
|
None, ///< None.
|
|
|
|
Apple, ///< .apple_names, .apple_namespaces, .apple_types, .apple_objc.
|
|
|
|
Dwarf, ///< DWARF v5 .debug_names.
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Collects and handles dwarf debug information.
|
2016-02-10 20:55:49 +00:00
|
|
|
class DwarfDebug : public DebugHandlerBase {
|
2015-07-13 18:25:29 +00:00
|
|
|
/// All DIEValues are allocated through this allocator.
|
2012-06-09 10:34:15 +00:00
|
|
|
BumpPtrAllocator DIEValueAllocator;
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Maps MDNode with its corresponding DwarfCompileUnit.
|
2014-01-29 22:06:23 +00:00
|
|
|
MapVector<const MDNode *, DwarfCompileUnit *> CUMap;
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Maps a CU DIE with its corresponding DwarfCompileUnit.
|
2013-12-09 23:57:44 +00:00
|
|
|
DenseMap<const DIE *, DwarfCompileUnit *> CUDieMap;
|
2013-10-29 22:57:10 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// List of all labels used in aranges generation.
|
2013-10-03 08:54:43 +00:00
|
|
|
std::vector<SymbolCU> ArangeLabels;
|
2013-09-19 23:21:01 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Size of each symbol emitted (for those symbols that have a specific size).
|
2013-12-09 23:32:48 +00:00
|
|
|
DenseMap<const MCSymbol *, uint64_t> SymSize;
|
2013-09-23 17:56:20 +00:00
|
|
|
|
2018-07-24 06:17:45 +00:00
|
|
|
/// Collection of abstract variables.
|
|
|
|
SmallVector<std::unique_ptr<DbgVariable>, 64> ConcreteVariables;
|
2009-11-10 23:06:00 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Collection of DebugLocEntry. Stored in a linked list so that DIELocLists
|
|
|
|
/// can refer to them in spite of insertions into this list.
|
AsmPrinter: Create a unified .debug_loc stream
This commit removes `DebugLocList` and replaces it with
`DebugLocStream`.
- `DebugLocEntry` no longer contains its byte/comment streams.
- The `DebugLocEntry` list for a variable/inlined-at pair is allocated
on the stack, and released right after `DebugLocEntry::finalize()`
(possible because of the refactoring in r231023). Now, only one
list is in memory at a time now.
- There's a single unified stream for the `.debug_loc` section that
persists, stored in the new `DebugLocStream` data structure.
The last point is important: this collapses the nested `SmallVector<>`s
from `DebugLocList` into unified streams. We previously had something
like the following:
vec<tuple<Label, CU,
vec<tuple<BeginSym, EndSym,
vec<Value>,
vec<char>,
vec<string>>>>>
A `SmallVector` can avoid allocations, but is statically fairly large
for a vector: three pointers plus the size of the small storage, which
is the number of elements in small mode times the element size).
Nesting these is expensive, since an inner vector's size contributes to
the element size of an outer one. (Nesting any vector is expensive...)
In the old data structure, the outer vector's *element* size was 632B,
excluding allocation costs for when the middle and inner vectors
exceeded their small sizes. 312B of this was for the "three" pointers
in the vector-tree beneath it. If you assume 1M functions with an
average of 10 variable/inlined-at pairs each (in an LTO scenario),
that's almost 6GB (besides inner allocations), with almost 3GB for the
"three" pointers.
This came up in a heap profile a little while ago of a `clang -flto -g`
bootstrap, with `DwarfDebug::collectVariableInfo()` using something like
10-15% of the total memory.
With this commit, we have:
tuple<vec<tuple<Label, CU, Offset>>,
vec<tuple<BeginSym, EndSym, Offset, Offset>>,
vec<char>,
vec<string>>
The offsets are used to create `ArrayRef` slices of adjacent
`SmallVector`s. This reduces the number of vectors to four (unrelated
to the number of variable/inlined-at pairs), and caps the number of
allocations at the same number.
Besides saving memory and limiting allocations, this is NFC.
I don't know my way around this code very well yet, but I wonder if we
could go further: why stream to a side-table, instead of directly to the
output stream?
llvm-svn: 235229
2015-04-17 21:34:47 +00:00
|
|
|
DebugLocStream DebugLocs;
|
2010-05-25 23:40:22 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// This is a collection of subprogram MDNodes that are processed to
|
|
|
|
/// create DIEs.
|
2016-12-15 23:37:38 +00:00
|
|
|
SetVector<const DISubprogram *, SmallVector<const DISubprogram *, 16>,
|
|
|
|
SmallPtrSet<const DISubprogram *, 16>>
|
|
|
|
ProcessedSPNodes;
|
2010-06-28 18:25:03 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// If nonnull, stores the current machine function we're processing.
|
2017-08-17 21:26:39 +00:00
|
|
|
const MachineFunction *CurFn = nullptr;
|
2013-12-03 15:10:23 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// If nonnull, stores the CU in which the previous subprogram was contained.
|
2014-03-20 19:16:16 +00:00
|
|
|
const DwarfCompileUnit *PrevCU;
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// As an optimization, there is no need to emit an entry in the directory
|
|
|
|
/// table for the same directory as DW_AT_comp_dir.
|
2011-11-02 20:55:33 +00:00
|
|
|
StringRef CompilationDir;
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Holder for the file specific debug information.
|
2013-12-05 18:06:10 +00:00
|
|
|
DwarfFile InfoHolder;
|
2012-12-10 23:34:43 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Holders for the various debug information flags that we might need to
|
|
|
|
/// have exposed. See accessor functions below for description.
|
2015-07-01 18:07:16 +00:00
|
|
|
|
2016-02-11 19:57:46 +00:00
|
|
|
/// Map from MDNodes for user-defined types to their type signatures. Also
|
|
|
|
/// used to keep track of which types we have emitted type units for.
|
|
|
|
DenseMap<const MDNode *, uint64_t> TypeSignatures;
|
2013-07-26 17:02:41 +00:00
|
|
|
|
2015-04-20 21:17:32 +00:00
|
|
|
SmallVector<
|
2015-04-29 16:38:44 +00:00
|
|
|
std::pair<std::unique_ptr<DwarfTypeUnit>, const DICompositeType *>, 1>
|
2015-02-17 20:02:28 +00:00
|
|
|
TypeUnitsUnderConstruction;
|
2014-04-26 17:27:38 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Whether to use the GNU TLS opcode (instead of the standard opcode).
|
2015-03-04 20:55:11 +00:00
|
|
|
bool UseGNUTLSOpcode;
|
|
|
|
|
2016-05-17 21:07:16 +00:00
|
|
|
/// Whether to use DWARF 2 bitfields (instead of the DWARF 4 format).
|
|
|
|
bool UseDWARF2Bitfields;
|
|
|
|
|
2016-04-18 22:41:41 +00:00
|
|
|
/// Whether to emit all linkage names, or just abstract subprograms.
|
|
|
|
bool UseAllLinkageNames;
|
2015-08-11 21:36:45 +00:00
|
|
|
|
2018-02-20 15:28:08 +00:00
|
|
|
/// Use inlined strings.
|
|
|
|
bool UseInlineStrings = false;
|
|
|
|
|
2018-03-20 16:04:40 +00:00
|
|
|
/// Whether to emit DWARF pub sections or not.
|
|
|
|
bool UsePubSections = true;
|
|
|
|
|
2018-03-20 20:21:38 +00:00
|
|
|
/// Allow emission of .debug_ranges section.
|
|
|
|
bool UseRangesSection = true;
|
|
|
|
|
2018-03-23 13:35:54 +00:00
|
|
|
/// True if the sections itself must be used as references and don't create
|
|
|
|
/// temp symbols inside DWARF sections.
|
|
|
|
bool UseSectionsAsReferences = false;
|
|
|
|
|
2018-06-29 14:23:28 +00:00
|
|
|
///Allow emission of the .debug_loc section.
|
|
|
|
bool UseLocSection = true;
|
|
|
|
|
[DebugInfo] Generate .debug_names section when it makes sense
Summary:
This patch makes us generate the debug_names section in response to some
user-facing commands (previously it was only generated if explicitly
selected via the -accel-tables option).
My goal was to make this work for DWARF>=5 (as it's an official part of
that standard), and also, as an extension, for DWARF<5 if one is
explicitly tuning for lldb as a debugger (because it brings a large
performance improvement there).
This is slightly complicated by the fact that the debug_names tables are
incompatible with the DWARF v4 type units (they assume that the type
units are in the debug_info section), and unfortunately, right now we
generate DWARF v4-style type units even for -gdwarf-5. For this reason,
I disable all accelerator tables if the user requested type unit
generation. I do this even for apple tables, as they have the same
problem (in fact generating type units for apple targets makes us crash
even before we get around to emitting the accelerator tables).
Reviewers: JDevlieghere, aprantl, dblaikie, echristo, probinson
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D49420
llvm-svn: 337544
2018-07-20 12:59:05 +00:00
|
|
|
/// Generate DWARF v4 type units.
|
|
|
|
bool GenerateTypeUnits;
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// DWARF5 Experimental Options
|
|
|
|
/// @{
|
2018-04-04 14:54:08 +00:00
|
|
|
AccelTableKind TheAccelTableKind;
|
2016-05-24 21:19:28 +00:00
|
|
|
bool HasAppleExtensionAttributes;
|
2012-12-10 19:51:21 +00:00
|
|
|
bool HasSplitDwarf;
|
2013-07-02 23:40:10 +00:00
|
|
|
|
2018-01-26 18:52:58 +00:00
|
|
|
/// Whether to generate the DWARF v5 string offsets table.
|
|
|
|
/// It consists of a series of contributions, each preceded by a header.
|
|
|
|
/// The pre-DWARF v5 string offsets table for split dwarf is, in contrast,
|
|
|
|
/// a monolithic sequence of string offsets.
|
|
|
|
bool UseSegmentedStringOffsetsTable;
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Separated Dwarf Variables
|
|
|
|
/// 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-10 19:51:13 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Holder for the skeleton information.
|
2013-12-05 18:06:10 +00:00
|
|
|
DwarfFile SkeletonHolder;
|
2012-12-10 19:51:13 +00:00
|
|
|
|
2015-07-13 18:25:29 +00: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 02:13:23 +00:00
|
|
|
MCDwarfDwoLineTable SplitTypeUnitFileTable;
|
2015-07-13 18:25:29 +00:00
|
|
|
/// @}
|
2017-11-15 10:57:05 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// True iff there are multiple CUs in this module.
|
2014-03-19 00:11:28 +00:00
|
|
|
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-09-30 21:28:32 +00:00
|
|
|
bool IsDarwin;
|
2014-03-19 00:11:28 +00:00
|
|
|
|
2014-04-23 21:20:10 +00:00
|
|
|
AddressPool AddrPool;
|
|
|
|
|
2018-04-04 14:42:14 +00:00
|
|
|
/// Accelerator tables.
|
|
|
|
AccelTable<DWARF5AccelTableData> AccelDebugNames;
|
[CodeGen] Refactor AppleAccelTable
Summary:
This commit separates the abstract accelerator table data structure
from the code for writing out an on-disk representation of a specific
accelerator table format. The idea is that former (now called
AccelTable<T>) can be reused for the DWARF v5 accelerator tables
as-is, without any further customizations.
Some bits of the emission code (now living in the EmissionContext class)
can be reused for DWARF v5 as well, but the subtle differences in the
layout of various subtables mean the sharing is not always possible.
(Also, the individual emit*** functions are fairly simple so there's a
tradeoff between making a bigger general-purpose function, and two
smaller targeted functions.)
Another advantage of this setup is that more of the serialization logic
can be hidden in the .cpp file -- I have moved declarations of the
header and all the emission functions there.
Reviewers: JDevlieghere, aprantl, probinson, dblaikie
Subscribers: echristo, clayborg, vleschuk, llvm-commits
Differential Revision: https://reviews.llvm.org/D43285
llvm-svn: 325516
2018-02-19 16:12:20 +00:00
|
|
|
AccelTable<AppleAccelTableOffsetData> AccelNames;
|
|
|
|
AccelTable<AppleAccelTableOffsetData> AccelObjC;
|
|
|
|
AccelTable<AppleAccelTableOffsetData> AccelNamespace;
|
|
|
|
AccelTable<AppleAccelTableTypeData> AccelTypes;
|
2014-04-23 23:37:35 +00:00
|
|
|
|
2015-07-15 22:04:54 +00:00
|
|
|
// Identify a debugger for "tuning" the debug info.
|
2017-08-17 21:26:39 +00:00
|
|
|
DebuggerKind DebuggerTuning = DebuggerKind::Default;
|
2015-07-15 22:04:54 +00:00
|
|
|
|
2014-03-19 00:11:28 +00:00
|
|
|
MCDwarfDwoLineTable *getDwoLineTable(const DwarfCompileUnit &);
|
|
|
|
|
2016-02-11 19:57:46 +00:00
|
|
|
const SmallVectorImpl<std::unique_ptr<DwarfCompileUnit>> &getUnits() {
|
2013-12-09 23:32:48 +00:00
|
|
|
return InfoHolder.getUnits();
|
|
|
|
}
|
2013-11-26 19:14:34 +00:00
|
|
|
|
2017-08-17 21:26:39 +00:00
|
|
|
using InlinedVariable = DbgValueHistoryMap::InlinedVariable;
|
2015-04-15 22:29:27 +00:00
|
|
|
|
2018-07-24 06:17:45 +00:00
|
|
|
void ensureAbstractVariableIsCreated(DwarfCompileUnit &CU, InlinedVariable IV,
|
|
|
|
const MDNode *Scope);
|
|
|
|
void ensureAbstractVariableIsCreatedIfScoped(DwarfCompileUnit &CU, InlinedVariable IV,
|
|
|
|
const MDNode *Scope);
|
2009-11-10 23:06:00 +00:00
|
|
|
|
2018-07-24 06:17:45 +00:00
|
|
|
DbgVariable *createConcreteVariable(DwarfCompileUnit &TheCU,
|
|
|
|
LexicalScope &Scope, InlinedVariable IV);
|
AsmPrinter: Rewrite initialization of DbgVariable, NFC
There are three types of `DbgVariable`:
- alloca variables, created based on the MMI table,
- register variables, created based on DBG_VALUE instructions, and
- optimized-out variables.
This commit reconfigures `DbgVariable` to make it easier to tell which
kind we have, and make initialization a little clearer.
For MMI/alloca variables, `FrameIndex.size()` must always equal
`Expr.size()`, and there shouldn't be an `MInsn`. For register
variables (with a `MInsn`), `FrameIndex` must be empty, and `Expr`
should have 0 or 1 element depending on whether it has a complex
expression (registers with multiple locations use `DebugLocListIndex`).
Optimized-out variables shouldn't have any of these fields.
Moreover, this separates DBG_VALUE initialization until after the
variable is created, simplifying logic in a future commit that changes
`collectVariableInfo()` to stop creating empty .debug_loc entries/lists.
llvm-svn: 240243
2015-06-21 16:50:43 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Construct a DIE for this abstract scope.
|
2017-05-12 01:13:45 +00:00
|
|
|
void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope);
|
2014-10-09 20:36:27 +00:00
|
|
|
|
2018-07-20 15:24:13 +00:00
|
|
|
template <typename DataT>
|
|
|
|
void addAccelNameImpl(AccelTable<DataT> &AppleAccel, StringRef Name,
|
|
|
|
const DIE &Die);
|
2018-04-18 12:11:59 +00:00
|
|
|
|
2018-07-24 06:17:45 +00:00
|
|
|
void finishVariableDefinitions();
|
2014-06-13 22:18:23 +00:00
|
|
|
|
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-27 18:37:43 +00:00
|
|
|
void finishSubprogramDefinitions();
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Finish off debug information after all functions have been
|
2012-11-27 22:43:45 +00:00
|
|
|
/// processed.
|
2012-11-22 00:59:49 +00:00
|
|
|
void finalizeModuleInfo();
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit the debug info section.
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitDebugInfo();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit the abbreviation section.
|
2012-11-20 23:30:11 +00:00
|
|
|
void emitAbbreviations();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2018-01-26 18:52:58 +00:00
|
|
|
/// Emit the string offsets table header.
|
|
|
|
void emitStringOffsetsTableHeader();
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit a specified accelerator table.
|
2018-01-29 14:52:34 +00:00
|
|
|
template <typename AccelTableT>
|
|
|
|
void emitAccel(AccelTableT &Accel, MCSection *Section, StringRef TableName);
|
2014-09-11 21:12:48 +00:00
|
|
|
|
2018-04-04 14:42:14 +00:00
|
|
|
/// Emit DWARF v5 accelerator table.
|
|
|
|
void emitAccelDebugNames();
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit visible names into a hashed accelerator table section.
|
2011-11-07 09:24:32 +00:00
|
|
|
void emitAccelNames();
|
2012-11-21 00:03:28 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit objective C classes and categories into a hashed
|
2011-11-07 09:24:32 +00:00
|
|
|
/// accelerator table section.
|
|
|
|
void emitAccelObjC();
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit namespace dies into a hashed accelerator table.
|
2011-11-07 09:24:32 +00:00
|
|
|
void emitAccelNamespaces();
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit type dies into a hashed accelerator table.
|
2011-11-07 09:24:32 +00:00
|
|
|
void emitAccelTypes();
|
2012-11-21 00:03:28 +00:00
|
|
|
|
2017-09-12 21:50:41 +00:00
|
|
|
/// Emit visible names and types into debug pubnames and pubtypes sections.
|
|
|
|
void emitDebugPubSections();
|
2013-02-12 18:00:14 +00:00
|
|
|
|
2017-09-12 21:50:41 +00:00
|
|
|
void emitDebugPubSection(bool GnuStyle, StringRef Name,
|
|
|
|
DwarfCompileUnit *TheU,
|
|
|
|
const StringMap<const DIE *> &Globals);
|
2014-03-11 23:18:15 +00:00
|
|
|
|
2016-01-24 08:18:55 +00:00
|
|
|
/// Emit null-terminated strings into a debug str section.
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitDebugStr();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2016-01-07 14:28:20 +00:00
|
|
|
/// Emit variable locations into a debug loc section.
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitDebugLoc();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2016-01-07 14:28:20 +00:00
|
|
|
/// Emit variable locations into a debug loc dwo section.
|
2014-04-02 01:50:20 +00:00
|
|
|
void emitDebugLocDWO();
|
|
|
|
|
2016-01-07 14:28:20 +00:00
|
|
|
/// Emit address ranges into a debug aranges section.
|
2012-11-21 00:34:35 +00:00
|
|
|
void emitDebugARanges();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2016-01-07 14:28:20 +00:00
|
|
|
/// Emit address ranges into a debug ranges section.
|
2009-11-21 02:48:08 +00:00
|
|
|
void emitDebugRanges();
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2018-07-12 18:18:21 +00:00
|
|
|
/// Emit range lists into a DWARF v5 debug rnglists section.
|
|
|
|
void emitDebugRnglists();
|
|
|
|
|
2016-01-07 14:28:20 +00:00
|
|
|
/// Emit macros into a debug macinfo section.
|
|
|
|
void emitDebugMacinfo();
|
2016-02-01 14:09:41 +00:00
|
|
|
void emitMacro(DIMacro &M);
|
|
|
|
void emitMacroFile(DIMacroFile &F, DwarfCompileUnit &U);
|
|
|
|
void handleMacroNodes(DIMacroNodeArray Nodes, DwarfCompileUnit &U);
|
2016-01-07 14:28:20 +00:00
|
|
|
|
2012-12-10 19:51:21 +00:00
|
|
|
/// DWARF 5 Experimental Split Dwarf Emitters
|
2012-11-30 23:59:06 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Initialize common features of skeleton units.
|
2014-04-25 18:26:14 +00:00
|
|
|
void initSkeletonUnit(const DwarfUnit &U, DIE &Die,
|
2016-02-11 19:57:46 +00:00
|
|
|
std::unique_ptr<DwarfCompileUnit> NewU);
|
2014-01-09 04:28:46 +00:00
|
|
|
|
2018-07-26 03:21:40 +00:00
|
|
|
/// Construct the split debug info compile unit for the debug info
|
|
|
|
/// section.
|
2014-04-22 22:39:41 +00:00
|
|
|
DwarfCompileUnit &constructSkeletonCU(const DwarfCompileUnit &CU);
|
2012-11-30 23:59:06 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit the debug info dwo section.
|
2012-11-30 23:59:06 +00:00
|
|
|
void emitDebugInfoDWO();
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit the debug abbrev dwo section.
|
2012-12-19 22:02:53 +00:00
|
|
|
void emitDebugAbbrevDWO();
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit the debug line dwo section.
|
2014-03-18 01:17:26 +00:00
|
|
|
void emitDebugLineDWO();
|
|
|
|
|
2018-01-26 18:52:58 +00:00
|
|
|
/// Emit the dwo stringoffsets table header.
|
|
|
|
void emitStringOffsetsTableHeaderDWO();
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit the debug str dwo section.
|
2012-12-27 02:14:01 +00:00
|
|
|
void emitDebugStrDWO();
|
|
|
|
|
2013-12-04 21:31:26 +00: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.
|
2017-05-25 18:50:28 +00:00
|
|
|
void addGnuPubAttributes(DwarfCompileUnit &U, DIE &D) const;
|
2013-12-04 21:31:26 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Create new DwarfCompileUnit for the given metadata node with tag
|
2012-11-27 22:43:45 +00:00
|
|
|
/// DW_TAG_compile_unit.
|
2017-05-26 18:52:56 +00:00
|
|
|
DwarfCompileUnit &getOrCreateDwarfCompileUnit(const DICompileUnit *DIUnit);
|
2010-05-10 22:49:55 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Construct imported_module or imported_declaration DIE.
|
2014-08-31 05:41:15 +00:00
|
|
|
void constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
|
2015-04-29 16:38:44 +00:00
|
|
|
const DIImportedEntity *N);
|
2013-05-06 23:33:07 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Register a source line with debug info. Returns the unique
|
2012-11-27 22:43:45 +00:00
|
|
|
/// label that was emitted and which provides correspondence to the
|
|
|
|
/// source line list.
|
2011-05-11 19:22:19 +00:00
|
|
|
void recordSourceLine(unsigned Line, unsigned Col, const MDNode *Scope,
|
|
|
|
unsigned Flags);
|
2012-11-21 00:03:28 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Populate LexicalScope entries with variables' info.
|
2018-07-24 06:17:45 +00:00
|
|
|
void collectVariableInfo(DwarfCompileUnit &TheCU, const DISubprogram *SP,
|
|
|
|
DenseSet<InlinedVariable> &ProcessedVars);
|
2012-11-21 00:03:28 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Build the location list for all DBG_VALUEs in the
|
2014-08-01 22:11:58 +00:00
|
|
|
/// function that describe the same variable.
|
|
|
|
void buildLocationList(SmallVectorImpl<DebugLocEntry> &DebugLoc,
|
2014-08-05 23:14:16 +00:00
|
|
|
const DbgValueHistoryMap::InstrRanges &Ranges);
|
2014-08-01 22:11:58 +00:00
|
|
|
|
2016-11-30 23:48:50 +00:00
|
|
|
/// Collect variable information from the side table maintained by MF.
|
2017-05-12 01:13:45 +00:00
|
|
|
void collectVariableInfoFromMFTable(DwarfCompileUnit &TheCU,
|
|
|
|
DenseSet<InlinedVariable> &P);
|
2011-03-26 02:19:36 +00:00
|
|
|
|
2018-03-23 13:35:54 +00:00
|
|
|
/// Emit the reference to the section.
|
|
|
|
void emitSectionReference(const DwarfCompileUnit &CU);
|
|
|
|
|
2017-02-16 18:48:33 +00:00
|
|
|
protected:
|
|
|
|
/// Gather pre-function debug information.
|
|
|
|
void beginFunctionImpl(const MachineFunction *MF) override;
|
|
|
|
|
|
|
|
/// Gather and emit post-function debug information.
|
|
|
|
void endFunctionImpl(const MachineFunction *MF) override;
|
|
|
|
|
|
|
|
void skippedNonDebugFunction() override;
|
|
|
|
|
2010-04-05 05:32:45 +00:00
|
|
|
public:
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// Main entry points.
|
|
|
|
//
|
|
|
|
DwarfDebug(AsmPrinter *A, Module *M);
|
|
|
|
|
2014-04-30 20:34:31 +00:00
|
|
|
~DwarfDebug() override;
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit all Dwarf sections that should come prior to the
|
2010-04-05 05:32:45 +00:00
|
|
|
/// content.
|
2012-11-19 22:42:15 +00:00
|
|
|
void beginModule();
|
2010-04-05 05:32:45 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit all Dwarf sections that should come after the content.
|
2014-03-08 06:31:39 +00:00
|
|
|
void endModule() override;
|
2010-04-05 05:32:45 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Process beginning of an instruction.
|
2014-03-08 06:31:39 +00:00
|
|
|
void beginInstruction(const MachineInstr *MI) override;
|
2009-11-10 23:06:00 +00:00
|
|
|
|
2015-07-15 17:01:41 +00:00
|
|
|
/// Perform an MD5 checksum of \p Identifier and return the lower 64 bits.
|
|
|
|
static uint64_t makeTypeSignature(StringRef Identifier);
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Add a DIE to the set of types that we're going to pull into
|
2013-07-26 17:02:41 +00:00
|
|
|
/// type units.
|
2014-02-12 00:31:30 +00:00
|
|
|
void addDwarfTypeUnitType(DwarfCompileUnit &CU, StringRef Identifier,
|
2015-04-29 16:38:44 +00:00
|
|
|
DIE &Die, const DICompositeType *CTy);
|
2013-07-26 17:02:41 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Add a label so that arange data can be generated for it.
|
2013-10-03 08:54:43 +00:00
|
|
|
void addArangeLabel(SymbolCU SCU) { ArangeLabels.push_back(SCU); }
|
2013-09-19 23:21:01 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// For symbols that have a size designated (e.g. common symbols),
|
2013-09-23 17:56:20 +00:00
|
|
|
/// this tracks that size.
|
2014-03-08 06:31:39 +00:00
|
|
|
void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {
|
2013-12-09 23:32:48 +00:00
|
|
|
SymSize[Sym] = Size;
|
|
|
|
}
|
2013-09-23 17:56:20 +00:00
|
|
|
|
2016-04-18 22:41:41 +00:00
|
|
|
/// Returns whether we should emit all DW_AT_[MIPS_]linkage_name.
|
|
|
|
/// If not, we still might emit certain cases.
|
|
|
|
bool useAllLinkageNames() const { return UseAllLinkageNames; }
|
2015-08-11 21:36:45 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Returns whether to use DW_OP_GNU_push_tls_address, instead of the
|
2015-03-04 20:55:11 +00:00
|
|
|
/// standard DW_OP_form_tls_address opcode
|
|
|
|
bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
|
|
|
|
|
2016-05-17 21:07:16 +00:00
|
|
|
/// Returns whether to use the DWARF2 format for bitfields instyead of the
|
|
|
|
/// DWARF4 format.
|
|
|
|
bool useDWARF2Bitfields() const { return UseDWARF2Bitfields; }
|
|
|
|
|
2018-02-20 15:28:08 +00:00
|
|
|
/// Returns whether to use inline strings.
|
|
|
|
bool useInlineStrings() const { return UseInlineStrings; }
|
|
|
|
|
2018-06-29 14:23:28 +00:00
|
|
|
/// Returns whether GNU pub sections should be emitted.
|
2018-03-20 16:04:40 +00:00
|
|
|
bool usePubSections() const { return UsePubSections; }
|
|
|
|
|
2018-03-20 20:21:38 +00:00
|
|
|
/// Returns whether ranges section should be emitted.
|
|
|
|
bool useRangesSection() const { return UseRangesSection; }
|
|
|
|
|
2018-03-23 13:35:54 +00:00
|
|
|
/// Returns whether to use sections as labels rather than temp symbols.
|
|
|
|
bool useSectionsAsReferences() const {
|
|
|
|
return UseSectionsAsReferences;
|
|
|
|
}
|
|
|
|
|
2018-06-29 14:23:28 +00:00
|
|
|
/// Returns whether .debug_loc section should be emitted.
|
|
|
|
bool useLocSection() const { return UseLocSection; }
|
|
|
|
|
[DebugInfo] Generate .debug_names section when it makes sense
Summary:
This patch makes us generate the debug_names section in response to some
user-facing commands (previously it was only generated if explicitly
selected via the -accel-tables option).
My goal was to make this work for DWARF>=5 (as it's an official part of
that standard), and also, as an extension, for DWARF<5 if one is
explicitly tuning for lldb as a debugger (because it brings a large
performance improvement there).
This is slightly complicated by the fact that the debug_names tables are
incompatible with the DWARF v4 type units (they assume that the type
units are in the debug_info section), and unfortunately, right now we
generate DWARF v4-style type units even for -gdwarf-5. For this reason,
I disable all accelerator tables if the user requested type unit
generation. I do this even for apple tables, as they have the same
problem (in fact generating type units for apple targets makes us crash
even before we get around to emitting the accelerator tables).
Reviewers: JDevlieghere, aprantl, dblaikie, echristo, probinson
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D49420
llvm-svn: 337544
2018-07-20 12:59:05 +00:00
|
|
|
/// Returns whether to generate DWARF v4 type units.
|
|
|
|
bool generateTypeUnits() const { return GenerateTypeUnits; }
|
|
|
|
|
2012-11-21 00:03:31 +00:00
|
|
|
// Experimental DWARF5 features.
|
|
|
|
|
2018-04-04 14:42:14 +00:00
|
|
|
/// Returns what kind (if any) of accelerator tables to emit.
|
2018-04-04 14:54:08 +00:00
|
|
|
AccelTableKind getAccelTableKind() const { return TheAccelTableKind; }
|
2012-11-21 00:03:31 +00:00
|
|
|
|
2016-05-24 21:19:28 +00:00
|
|
|
bool useAppleExtensionAttributes() const {
|
|
|
|
return HasAppleExtensionAttributes;
|
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Returns whether or not to change the current debug info for the
|
2012-12-10 19:51:21 +00:00
|
|
|
/// split dwarf proposal support.
|
2014-03-06 00:00:53 +00:00
|
|
|
bool useSplitDwarf() const { return HasSplitDwarf; }
|
2013-07-02 23:40:10 +00:00
|
|
|
|
2018-01-26 18:52:58 +00:00
|
|
|
/// Returns whether to generate a string offsets table with (possibly shared)
|
|
|
|
/// contributions from each CU and type unit. This implies the use of
|
|
|
|
/// DW_FORM_strx* indirect references with DWARF v5 and beyond. Note that
|
|
|
|
/// DW_FORM_GNU_str_index is also an indirect reference, but it is used with
|
|
|
|
/// a pre-DWARF v5 implementation of split DWARF sections, which uses a
|
|
|
|
/// monolithic string offsets table.
|
|
|
|
bool useSegmentedStringOffsetsTable() const {
|
|
|
|
return UseSegmentedStringOffsetsTable;
|
|
|
|
}
|
|
|
|
|
2017-05-12 01:13:45 +00:00
|
|
|
bool shareAcrossDWOCUs() const;
|
|
|
|
|
2013-07-02 23:40:10 +00:00
|
|
|
/// Returns the Dwarf Version.
|
2016-11-23 23:30:37 +00:00
|
|
|
uint16_t getDwarfVersion() const;
|
2013-09-05 18:48:31 +00:00
|
|
|
|
2014-03-20 19:16:16 +00:00
|
|
|
/// Returns the previous CU that was being updated
|
|
|
|
const DwarfCompileUnit *getPrevCU() const { return PrevCU; }
|
2014-09-09 23:13:01 +00:00
|
|
|
void setPrevCU(const DwarfCompileUnit *PrevCU) { this->PrevCU = PrevCU; }
|
2014-03-20 19:16:16 +00:00
|
|
|
|
2014-03-08 00:29:41 +00:00
|
|
|
/// Returns the entries for the .debug_loc section.
|
AsmPrinter: Create a unified .debug_loc stream
This commit removes `DebugLocList` and replaces it with
`DebugLocStream`.
- `DebugLocEntry` no longer contains its byte/comment streams.
- The `DebugLocEntry` list for a variable/inlined-at pair is allocated
on the stack, and released right after `DebugLocEntry::finalize()`
(possible because of the refactoring in r231023). Now, only one
list is in memory at a time now.
- There's a single unified stream for the `.debug_loc` section that
persists, stored in the new `DebugLocStream` data structure.
The last point is important: this collapses the nested `SmallVector<>`s
from `DebugLocList` into unified streams. We previously had something
like the following:
vec<tuple<Label, CU,
vec<tuple<BeginSym, EndSym,
vec<Value>,
vec<char>,
vec<string>>>>>
A `SmallVector` can avoid allocations, but is statically fairly large
for a vector: three pointers plus the size of the small storage, which
is the number of elements in small mode times the element size).
Nesting these is expensive, since an inner vector's size contributes to
the element size of an outer one. (Nesting any vector is expensive...)
In the old data structure, the outer vector's *element* size was 632B,
excluding allocation costs for when the middle and inner vectors
exceeded their small sizes. 312B of this was for the "three" pointers
in the vector-tree beneath it. If you assume 1M functions with an
average of 10 variable/inlined-at pairs each (in an LTO scenario),
that's almost 6GB (besides inner allocations), with almost 3GB for the
"three" pointers.
This came up in a heap profile a little while ago of a `clang -flto -g`
bootstrap, with `DwarfDebug::collectVariableInfo()` using something like
10-15% of the total memory.
With this commit, we have:
tuple<vec<tuple<Label, CU, Offset>>,
vec<tuple<BeginSym, EndSym, Offset, Offset>>,
vec<char>,
vec<string>>
The offsets are used to create `ArrayRef` slices of adjacent
`SmallVector`s. This reduces the number of vectors to four (unrelated
to the number of variable/inlined-at pairs), and caps the number of
allocations at the same number.
Besides saving memory and limiting allocations, this is NFC.
I don't know my way around this code very well yet, but I wonder if we
could go further: why stream to a side-table, instead of directly to the
output stream?
llvm-svn: 235229
2015-04-17 21:34:47 +00:00
|
|
|
const DebugLocStream &getDebugLocs() const { return DebugLocs; }
|
2014-03-08 00:29:41 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// Emit an entry for the debug loc section. This can be used to
|
2014-03-08 00:29:41 +00:00
|
|
|
/// handle an entry that's going to be emitted into the debug loc section.
|
2015-03-02 22:02:33 +00:00
|
|
|
void emitDebugLocEntry(ByteStreamer &Streamer,
|
AsmPrinter: Create a unified .debug_loc stream
This commit removes `DebugLocList` and replaces it with
`DebugLocStream`.
- `DebugLocEntry` no longer contains its byte/comment streams.
- The `DebugLocEntry` list for a variable/inlined-at pair is allocated
on the stack, and released right after `DebugLocEntry::finalize()`
(possible because of the refactoring in r231023). Now, only one
list is in memory at a time now.
- There's a single unified stream for the `.debug_loc` section that
persists, stored in the new `DebugLocStream` data structure.
The last point is important: this collapses the nested `SmallVector<>`s
from `DebugLocList` into unified streams. We previously had something
like the following:
vec<tuple<Label, CU,
vec<tuple<BeginSym, EndSym,
vec<Value>,
vec<char>,
vec<string>>>>>
A `SmallVector` can avoid allocations, but is statically fairly large
for a vector: three pointers plus the size of the small storage, which
is the number of elements in small mode times the element size).
Nesting these is expensive, since an inner vector's size contributes to
the element size of an outer one. (Nesting any vector is expensive...)
In the old data structure, the outer vector's *element* size was 632B,
excluding allocation costs for when the middle and inner vectors
exceeded their small sizes. 312B of this was for the "three" pointers
in the vector-tree beneath it. If you assume 1M functions with an
average of 10 variable/inlined-at pairs each (in an LTO scenario),
that's almost 6GB (besides inner allocations), with almost 3GB for the
"three" pointers.
This came up in a heap profile a little while ago of a `clang -flto -g`
bootstrap, with `DwarfDebug::collectVariableInfo()` using something like
10-15% of the total memory.
With this commit, we have:
tuple<vec<tuple<Label, CU, Offset>>,
vec<tuple<BeginSym, EndSym, Offset, Offset>>,
vec<char>,
vec<string>>
The offsets are used to create `ArrayRef` slices of adjacent
`SmallVector`s. This reduces the number of vectors to four (unrelated
to the number of variable/inlined-at pairs), and caps the number of
allocations at the same number.
Besides saving memory and limiting allocations, this is NFC.
I don't know my way around this code very well yet, but I wonder if we
could go further: why stream to a side-table, instead of directly to the
output stream?
llvm-svn: 235229
2015-04-17 21:34:47 +00:00
|
|
|
const DebugLocStream::Entry &Entry);
|
2014-03-08 00:29:41 +00:00
|
|
|
|
2014-04-01 16:17:41 +00:00
|
|
|
/// Emit the location for a debug loc entry, including the size header.
|
AsmPrinter: Create a unified .debug_loc stream
This commit removes `DebugLocList` and replaces it with
`DebugLocStream`.
- `DebugLocEntry` no longer contains its byte/comment streams.
- The `DebugLocEntry` list for a variable/inlined-at pair is allocated
on the stack, and released right after `DebugLocEntry::finalize()`
(possible because of the refactoring in r231023). Now, only one
list is in memory at a time now.
- There's a single unified stream for the `.debug_loc` section that
persists, stored in the new `DebugLocStream` data structure.
The last point is important: this collapses the nested `SmallVector<>`s
from `DebugLocList` into unified streams. We previously had something
like the following:
vec<tuple<Label, CU,
vec<tuple<BeginSym, EndSym,
vec<Value>,
vec<char>,
vec<string>>>>>
A `SmallVector` can avoid allocations, but is statically fairly large
for a vector: three pointers plus the size of the small storage, which
is the number of elements in small mode times the element size).
Nesting these is expensive, since an inner vector's size contributes to
the element size of an outer one. (Nesting any vector is expensive...)
In the old data structure, the outer vector's *element* size was 632B,
excluding allocation costs for when the middle and inner vectors
exceeded their small sizes. 312B of this was for the "three" pointers
in the vector-tree beneath it. If you assume 1M functions with an
average of 10 variable/inlined-at pairs each (in an LTO scenario),
that's almost 6GB (besides inner allocations), with almost 3GB for the
"three" pointers.
This came up in a heap profile a little while ago of a `clang -flto -g`
bootstrap, with `DwarfDebug::collectVariableInfo()` using something like
10-15% of the total memory.
With this commit, we have:
tuple<vec<tuple<Label, CU, Offset>>,
vec<tuple<BeginSym, EndSym, Offset, Offset>>,
vec<char>,
vec<string>>
The offsets are used to create `ArrayRef` slices of adjacent
`SmallVector`s. This reduces the number of vectors to four (unrelated
to the number of variable/inlined-at pairs), and caps the number of
allocations at the same number.
Besides saving memory and limiting allocations, this is NFC.
I don't know my way around this code very well yet, but I wonder if we
could go further: why stream to a side-table, instead of directly to the
output stream?
llvm-svn: 235229
2015-04-17 21:34:47 +00:00
|
|
|
void emitDebugLocEntryLocation(const DebugLocStream::Entry &Entry);
|
2014-04-01 16:17:41 +00:00
|
|
|
|
2013-10-05 00:32:34 +00:00
|
|
|
/// Find the MDNode for the given reference.
|
2015-04-29 16:38:44 +00:00
|
|
|
template <typename T> T *resolve(TypedDINodeRef<T> Ref) const {
|
2016-04-23 21:08:00 +00:00
|
|
|
return Ref.resolve();
|
2014-03-18 02:34:58 +00:00
|
|
|
}
|
|
|
|
|
2015-04-29 16:38:44 +00:00
|
|
|
void addSubprogramNames(const DISubprogram *SP, DIE &Die);
|
2014-04-23 23:37:35 +00:00
|
|
|
|
2014-04-23 21:20:10 +00:00
|
|
|
AddressPool &getAddressPool() { return AddrPool; }
|
2014-04-23 23:37:35 +00:00
|
|
|
|
2014-04-25 18:52:29 +00:00
|
|
|
void addAccelName(StringRef Name, const DIE &Die);
|
2014-04-24 00:53:32 +00:00
|
|
|
|
2014-04-25 18:52:29 +00:00
|
|
|
void addAccelObjC(StringRef Name, const DIE &Die);
|
2014-04-24 01:02:42 +00:00
|
|
|
|
2014-04-25 18:52:29 +00:00
|
|
|
void addAccelNamespace(StringRef Name, const DIE &Die);
|
2014-04-24 01:23:49 +00:00
|
|
|
|
2014-04-25 18:52:29 +00:00
|
|
|
void addAccelType(StringRef Name, const DIE &Die, char Flags);
|
2014-10-04 16:24:00 +00:00
|
|
|
|
|
|
|
const MachineFunction *getCurrentFunction() const { return CurFn; }
|
2014-10-08 22:20:02 +00:00
|
|
|
|
2015-07-13 18:25:29 +00:00
|
|
|
/// A helper function to check whether the DIE for a given Scope is
|
2014-10-08 22:20:02 +00:00
|
|
|
/// going to be null.
|
|
|
|
bool isLexicalScopeDIENull(LexicalScope *Scope);
|
2017-05-25 18:50:28 +00:00
|
|
|
|
2017-11-15 10:57:05 +00:00
|
|
|
/// Find the matching DwarfCompileUnit for the given CU DIE.
|
|
|
|
DwarfCompileUnit *lookupCU(const DIE *Die) { return CUDieMap.lookup(Die); }
|
2018-04-04 14:42:14 +00:00
|
|
|
const DwarfCompileUnit *lookupCU(const DIE *Die) const {
|
|
|
|
return CUDieMap.lookup(Die);
|
|
|
|
}
|
2017-11-15 10:57:05 +00:00
|
|
|
|
2017-09-12 21:50:41 +00:00
|
|
|
/// \defgroup DebuggerTuning Predicates to tune DWARF for a given debugger.
|
|
|
|
///
|
|
|
|
/// Returns whether we are "tuning" for a given debugger.
|
|
|
|
/// @{
|
|
|
|
bool tuneForGDB() const { return DebuggerTuning == DebuggerKind::GDB; }
|
|
|
|
bool tuneForLLDB() const { return DebuggerTuning == DebuggerKind::LLDB; }
|
|
|
|
bool tuneForSCE() const { return DebuggerTuning == DebuggerKind::SCE; }
|
|
|
|
/// @}
|
2009-11-10 23:06:00 +00:00
|
|
|
};
|
2009-05-15 09:23:25 +00:00
|
|
|
|
2017-08-17 21:26:39 +00:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFDEBUG_H
|