Skip to content

Commit 9591f5a

Browse files
committed
[LLD] Do not combine cg_profile from obj and ordering file
cg_profile in object is from CGProfilePass and it is often inaccurate. While call-graph-ordering-file is provided by user. It is weird to aggregate them together especially when call-graph-ordering-file is accurate enough.
1 parent d66829a commit 9591f5a

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

lld/COFF/Driver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2812,10 +2812,10 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
28122812
// Handle /call-graph-ordering-file and /call-graph-profile-sort (default on).
28132813
if (config->callGraphProfileSort) {
28142814
llvm::TimeTraceScope timeScope("Call graph");
2815-
if (auto *arg = args.getLastArg(OPT_call_graph_ordering_file)) {
2815+
if (auto *arg = args.getLastArg(OPT_call_graph_ordering_file))
28162816
parseCallGraphFile(arg->getValue());
2817-
}
2818-
readCallGraphsFromObjectFiles(ctx);
2817+
else
2818+
readCallGraphsFromObjectFiles(ctx);
28192819
}
28202820

28212821
// Handle /print-symbol-order.

lld/ELF/Driver.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,11 +3215,12 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &args) {
32153215

32163216
// Read the callgraph now that we know what was gced or icfed
32173217
if (ctx.arg.callGraphProfileSort != CGProfileSortKind::None) {
3218-
if (auto *arg = args.getLastArg(OPT_call_graph_ordering_file))
3218+
if (auto *arg = args.getLastArg(OPT_call_graph_ordering_file)) {
32193219
if (std::optional<MemoryBufferRef> buffer =
32203220
readFile(ctx, arg->getValue()))
32213221
readCallGraph(ctx, *buffer);
3222-
readCallGraphsFromObjectFiles<ELFT>(ctx);
3222+
} else
3223+
readCallGraphsFromObjectFiles<ELFT>(ctx);
32233224
}
32243225

32253226
// Write the result to the file.

lld/test/COFF/cgprofile-obj.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Aa:
4646
# NO-CG: 140001002 T B
4747
# NO-CG: 140001003 T A
4848

49-
# CG-OBJ-OF: 140001000 T C
50-
# CG-OBJ-OF: 140001001 t D
51-
# CG-OBJ-OF: 140001002 T A
52-
# CG-OBJ-OF: 140001003 T B
49+
# CG-OBJ-OF: 140001000 t D
50+
# CG-OBJ-OF: 140001001 T A
51+
# CG-OBJ-OF: 140001004 T C
52+
# CG-OBJ-OF: 140001005 T B

lld/test/ELF/cgprofile-obj.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Aa:
4949
# NO-CG: 0000000000201122 T B
5050
# NO-CG: 0000000000201123 T A
5151

52-
# CG-OBJ-OF: 0000000000201121 t D
53-
# CG-OBJ-OF: 0000000000201120 T C
54-
# CG-OBJ-OF: 0000000000201123 T B
55-
# CG-OBJ-OF: 0000000000201122 T A
52+
# CG-OBJ-OF: 0000000000201120 t D
53+
# CG-OBJ-OF: 0000000000201124 T C
54+
# CG-OBJ-OF: 0000000000201125 T B
55+
# CG-OBJ-OF: 0000000000201121 T A

0 commit comments

Comments
 (0)