Skip to content

[LTO] Reset DiscardValueNames in optimize(). #78705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/lib/LTO/LTOCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,9 @@ bool LTOCodeGenerator::optimize() {
if (!this->determineTarget())
return false;

// libLTO parses options late, so re-set them here.
Context.setDiscardValueNames(LTODiscardValueNames);

auto DiagFileOrErr = lto::setupLLVMOptimizationRemarks(
Context, RemarksFilename, RemarksPasses, RemarksFormat,
RemarksWithHotness, RemarksHotnessThreshold);
Expand Down
3 changes: 1 addition & 2 deletions llvm/test/tools/lto/discard-value-names.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@

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

; REQUIRES: asserts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the REQUIRED to be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is needed as otherwise the default is to discard value names. Left as is for now


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

; KEEP: %cmp.i = icmp
Expand Down