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

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 30 04:32:33 PDT 2024


Author: Florian Hahn
Date: 2024-04-30T12:32:29+01:00
New Revision: f3ac55fab8c30e71987120f76da70b5b6e9075f7

URL: https://github.com/llvm/llvm-project/commit/f3ac55fab8c30e71987120f76da70b5b6e9075f7
DIFF: https://github.com/llvm/llvm-project/commit/f3ac55fab8c30e71987120f76da70b5b6e9075f7.diff

LOG: [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: https://github.com/llvm/llvm-project/pull/78705

Added: 
    

Modified: 
    llvm/lib/LTO/LTOCodeGenerator.cpp
    llvm/test/tools/lto/discard-value-names.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp
index 19b6f7e7879238..0611099c4690db 100644
--- a/llvm/lib/LTO/LTOCodeGenerator.cpp
+++ b/llvm/lib/LTO/LTOCodeGenerator.cpp
@@ -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);

diff  --git a/llvm/test/tools/lto/discard-value-names.ll b/llvm/test/tools/lto/discard-value-names.ll
index 723b0701ae22ce..04d25eaf6067c5 100644
--- a/llvm/test/tools/lto/discard-value-names.ll
+++ b/llvm/test/tools/lto/discard-value-names.ll
@@ -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
 
-; DISCARD: %cmp.i = icmp
+; DISCARD: %{{[0-9]+}} = icmp
 ; DISCARD: %add = add i32
 
 ; KEEP: %cmp.i = icmp


        


More information about the llvm-commits mailing list