Skip to content

Commit f3ac55f

Browse files
authored
[LTO] Reset DiscardValueNames in optimize(). (#78705)
libLTO parses options late, so at the moment the option is ignored. To fix that, re-set it in optimize(), as at this point the options have been parsed. When LTOCodeGenerator's constructor executes, the options haven't been parsed by the linker to libLTO yet. Note that we keep the value name of `%add = add..` because when the module is imported, DiscardValueNames is still set to false (the default when building with assertions). I tried to improve this in libLTO, but I am not sure if there's a suitable callback when all options have been set. PR: #78705
1 parent 6fab3f2 commit f3ac55f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

llvm/lib/LTO/LTOCodeGenerator.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ bool LTOCodeGenerator::optimize() {
572572
if (!this->determineTarget())
573573
return false;
574574

575+
// libLTO parses options late, so re-set them here.
576+
Context.setDiscardValueNames(LTODiscardValueNames);
577+
575578
auto DiagFileOrErr = lto::setupLLVMOptimizationRemarks(
576579
Context, RemarksFilename, RemarksPasses, RemarksFormat,
577580
RemarksWithHotness, RemarksHotnessThreshold);

llvm/test/tools/lto/discard-value-names.ll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77

88
; The test requires asserts, as it depends on the default value for
99
; -lto-discard-value-names at the moment.
10-
; FIXME: -lto-discard-value-names is ignored at the moment.
1110

1211
; REQUIRES: asserts
1312

14-
; DISCARD: %cmp.i = icmp
13+
; DISCARD: %{{[0-9]+}} = icmp
1514
; DISCARD: %add = add i32
1615

1716
; KEEP: %cmp.i = icmp

0 commit comments

Comments
 (0)