Skip to content

Commit 9217a8f

Browse files
committed
[ELD] Add link statistics to MapDetail options
Register link-stats-details with the existing MapDetail mechanism so detailed link statistics can be enabled with: --MapDetail=link-stats-details Fix: #2303 Signed-off-by: Steven Ramirez Rosa <ramirezr@qti.qualcomm.com>
1 parent 1d49da7 commit 9217a8f

5 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎include/eld/LayoutMap/LayoutInfo.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ class LayoutInfo {
8383
ShowTiming = 0x20,
8484
ShowDebugStrings = 0x40,
8585
ShowRelativePath = 0x80,
86-
ShowInitialLayout = 0x100
86+
ShowInitialLayout = 0x100,
87+
ShowLinkStatsDetails = 0x200
8788
};
8889

8990
enum InputKindPrefix {
@@ -211,6 +212,10 @@ class LayoutInfo {
211212

212213
bool showInitialLayout() const { return LayoutDetail & ShowInitialLayout; }
213214

215+
bool showLinkStatsDetails() const {
216+
return LayoutDetail & ShowLinkStatsDetails;
217+
}
218+
214219
static eld::Expected<void> setLayoutDetail(llvm::StringRef Option,
215220
DiagnosticEngine *);
216221

‎lib/LayoutMap/LayoutInfo.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ LayoutInfo::setLayoutDetail(llvm::StringRef Option,
183183
.Case("show-timing", ShowTiming)
184184
.Case("show-debug-strings", ShowDebugStrings)
185185
.Case("show-initial-layout", ShowInitialLayout)
186+
.Case("link-stats-details", ShowLinkStatsDetails)
186187
.StartsWith(ShowRelativePathOptionStr, ShowRelativePath)
187188
.Default(0);
188189
LayoutDetail |= OptionLayoutDetail;

‎lib/LayoutMap/TextLayoutPrinter.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ void TextLayoutPrinter::printStats(LayoutInfo::Stats &L,
166166
outputStream() << "# "
167167
<< "LinkStats Begin"
168168
<< "\n";
169+
if (ThisLayoutInfo->showLinkStatsDetails())
170+
outputStream() << "# Detailed link stats enabled\n";
169171
printStat("ObjectFiles", L.NumElfObjectFiles);
170172
printStat("ExecutableFiles", L.NumElfExecutableFiles);
171173
printStat("LinkerScripts", L.NumLinkerScripts);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int main() { return 0; }
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#---LinkStatsDetails.test----------------------- Executable -----------------#
2+
#BEGIN_COMMENT
3+
# This tests that detailed link statistics can be enabled with MapDetail.
4+
#END_COMMENT
5+
#START_TEST
6+
RUN: %clang %clangopts -c %p/Inputs/1.c -o %t.1.o
7+
RUN: %link %linkopts %t.1.o -M --MapDetail=link-stats-details -o %t.1.out 2>&1 | %filecheck %s --check-prefix=ENABLED
8+
RUN: %link %linkopts %t.1.o -M -o %t.2.out 2>&1 | %filecheck %s --check-prefix=DISABLED
9+
#END_TEST
10+
11+
#ENABLED: # Detailed link stats enabled
12+
#DISABLED-NOT: # Detailed link stats enabled

0 commit comments

Comments
 (0)