Skip to content

Commit 761a3d7

Browse files
committed
Emit memory reports to debug link time memory usage
This prints memory allocated by linker core data structures with a count of how many and total bytes used. This will be followed up by improvements to report virtual memory / resident memory size. Resolves #606 Signed-off-by: Shankar Easwaran <seaswara@qti.qualcomm.com>
1 parent 8bc0c1d commit 761a3d7

258 files changed

Lines changed: 1840 additions & 179 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Plugins/HelloWorldPlugin/HelloWorldPlugin.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#include <iostream>
1212

1313
class DLL_A_EXPORT HelloWorldPlugin : public eld::plugin::LinkerPlugin {
14+
public:
15+
static std::string getTypeName() { return "DLL_A_EXPORT"; }
16+
1417
public:
1518
HelloWorldPlugin() : eld::plugin::LinkerPlugin("HelloWorldPlugin") {}
1619

include/eld/BranchIsland/BranchIsland.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class Relocation;
3333
*
3434
*/
3535
class BranchIsland {
36+
public:
37+
static std::string getTypeName() { return "BranchIsland"; }
38+
3639
public:
3740
typedef std::vector<Relocation *> RelocationListType;
3841
typedef RelocationListType::iterator reloc_iterator;

include/eld/BranchIsland/BranchIslandFactory.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class FragmentRef;
3131
*
3232
*/
3333
class BranchIslandFactory {
34+
public:
35+
static std::string getTypeName() { return "BranchIslandFactory"; }
36+
3437
public:
3538
BranchIslandFactory(bool UseAddends, LinkerConfig &Config);
3639

include/eld/BranchIsland/StubFactory.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class IRBuilder;
3131
*
3232
*/
3333
class StubFactory {
34+
public:
35+
static std::string getTypeName() { return "StubFactory"; }
36+
3437
public:
3538
typedef std::vector<Stub *> StubVector;
3639
StubFactory(Stub *TargetStub);

include/eld/Config/GeneralOptions.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class ZOption;
4343
* - attribute of input files
4444
*/
4545
class GeneralOptions {
46+
public:
47+
static std::string getTypeName() { return "GeneralOptions"; }
48+
4649
public:
4750
typedef llvm::StringMap<std::string> SymbolRenameMap;
4851

@@ -834,6 +837,16 @@ class GeneralOptions {
834837
void setTimingStatsFile(std::string StatsFile) {
835838
TimingStatsFile = StatsFile;
836839
}
840+
//--------------------Memory Report--------------------------------
841+
// --print-memory-report
842+
bool showMemoryReport() const { return PrintMemoryReport; }
843+
844+
void setPrintMemoryReport() { PrintMemoryReport = true; }
845+
846+
// --emit-memory-report <file>
847+
std::string getMemoryReportFile() const { return MemoryReportFile; }
848+
849+
void setMemoryReportFile(std::string F) { MemoryReportFile = F; }
837850
//--------------------Plugin Config--------------------------------
838851
void addPluginConfig(const std::string &Config) {
839852
PluginConfig.push_back(Config);
@@ -1233,6 +1246,7 @@ class GeneralOptions {
12331246
bool BExecuteOnly = false; // --execute-only
12341247
bool BPrintTimeStats = false; // --print-stats
12351248
bool BPrintAllUserPluginTimeStats = false;
1249+
bool PrintMemoryReport = false; // --print-memory-report
12361250
bool BDemangle = true; // --demangle-style
12371251
bool ValidateArchOpts = false; // check -mabi with backend
12381252
bool DisableGuardForWeakUndefs = false; // hexagon specific option to
@@ -1265,7 +1279,8 @@ class GeneralOptions {
12651279
std::string Filter;
12661280
std::string MapFile; // Mapfile
12671281
std::string TarFile; // --reproduce output tarfile name
1268-
std::string TimingStatsFile;
1282+
std::string TimingStatsFile; // --emit-timing-stats
1283+
std::string MemoryReportFile; // --emit-memory-report
12691284
std::string MappingFileName; // --Mapping-file
12701285
std::string MappingDumpFile; // --dump-mapping-file
12711286
std::string ResponseDumpFile; // --dump-response-file

include/eld/Config/LinkerConfig.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ class Module;
3434
class DiagnosticEngine;
3535
class SearchDirs;
3636
class LinkerConfig {
37+
public:
38+
static std::string getTypeName() { return "LinkerConfig"; }
39+
3740
public:
3841
enum CodeGenType { Unknown, Object, DynObj, Exec, External, Binary };
3942

@@ -75,6 +78,8 @@ class LinkerConfig {
7578
enum SymDefStyle { Default, Provide, UnknownSymDefStyle };
7679

7780
struct WarnOptions {
81+
public:
82+
static std::string getTypeName() { return "WarnOptions"; }
7883
std::optional<bool> EnableAllWarnings;
7984
std::optional<bool> EnableLinkerScriptWarnings;
8085
std::optional<bool> EnableZeroSizedSectionsWarnings;
@@ -88,6 +93,8 @@ class LinkerConfig {
8893
};
8994

9095
struct MappingFileInfo {
96+
public:
97+
static std::string getTypeName() { return "MappingFileInfo"; }
9198
std::unordered_map<std::string, std::string> StringMapKeyToValue;
9299

93100
void addStringMapEntry(llvm::StringRef Key, llvm::StringRef Value) {

include/eld/Config/TargetOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class LinkerScript;
2626
* backend.
2727
*/
2828
class TargetOptions {
29+
public:
30+
static std::string getTypeName() { return "TargetOptions"; }
31+
2932
public:
3033
enum Endian { Little, Big, Unknown };
3134

include/eld/Core/CommandLine.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
namespace eld {
1212

1313
struct CommandLine {
14+
public:
15+
static std::string getTypeName() { return "CommandLine"; }
16+
1417
public:
1518
typedef enum { Flag, Option, MultiValueOption } CmdType;
1619

@@ -23,6 +26,8 @@ struct CommandLine {
2326
};
2427

2528
struct Flags : public CommandLine {
29+
public:
30+
static std::string getTypeName() { return "Flags"; }
2631
Flags(const std::string &Opt, bool Flag)
2732
: CommandLine(CmdType::Flag), Option(Opt), Flag(Flag) {}
2833

@@ -39,6 +44,8 @@ struct Flags : public CommandLine {
3944
};
4045

4146
struct Options : public CommandLine {
47+
public:
48+
static std::string getTypeName() { return "Options"; }
4249
Options(const std::string &Opt, const std::string &Arg)
4350
: CommandLine(CmdType::Option), Option(Opt), Argument(Arg) {}
4451

@@ -55,6 +62,8 @@ struct Options : public CommandLine {
5562
};
5663

5764
struct MultiValueOption : public CommandLine {
65+
public:
66+
static std::string getTypeName() { return "MultiValueOption"; }
5867
MultiValueOption(const std::string &Opt, const std::vector<std::string> &Arg)
5968
: CommandLine(CmdType::MultiValueOption), Option(Opt), ArgumentList(Arg) {
6069
}

include/eld/Core/Linker.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class ObjectLinker;
4040
* \brief Linker is a modular linker.
4141
*/
4242
class Linker {
43+
public:
44+
static std::string getTypeName() { return "Linker"; }
45+
4346
public:
4447
enum UnresolvedPolicy {
4548
NotSet = 0x0,

include/eld/Core/LinkerScript.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ class MemoryCmd;
5555
class SymbolContainer;
5656

5757
class Phdrs {
58+
public:
59+
static std::string getTypeName() { return "Phdrs"; }
60+
5861
public:
5962
Phdrs(const PhdrSpec &PPhdrDesc) {
6063
ScriptSpec.Name = PPhdrDesc.Name;
@@ -77,6 +80,9 @@ class Phdrs {
7780
*
7881
*/
7982
class LinkerScript {
83+
public:
84+
static std::string getTypeName() { return "LinkerScript"; }
85+
8086
public:
8187
typedef std::vector<Assignment *> Assignments;
8288
typedef std::vector<ChangeOutputSectionPluginOp *> OverrideSectionMatchT;

0 commit comments

Comments
 (0)