Skip to content

Commit e13d023

Browse files
committed
[LTO] Reset DiscardValueNames in optimize().
libLTO parses options late, so re-set them in optimize(). When LTOCodeGenerator's constructor executes, the options haven't been passed 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 wiht 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.
1 parent 326657f commit e13d023

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)