[PATCH] D109737: [LTO] Emit DebugLoc for dead function in optimization remarks

Xu Mingjie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 15 00:46:45 PDT 2021


Enna1 added inline comments.


================
Comment at: llvm/lib/LTO/LTO.cpp:860
       if (Function *F = dyn_cast<Function>(GV)) {
+        if (Error Err = F->materialize())
+          return Err;
----------------
tejohnson wrote:
> Were we eventually materializing these dead functions without this change? If not, this seems like a compile time degradation. Would it work to move the materialize call later, capture the OptimizationRemark in a variable, and guard the materialization by isEnabled() on the remark?
Thanks for your comment!
Yes, this will cause a compile time degradation, without this change these dead function will never be materialized.
To emit DebugLoc for dead function in optimization remarks, we must call `F->materialize` before `ORE(F, nullptr);` and `ore::NV("Function", F)`.
I'm looking for a variable which indicates whether we enable emit OptimizationRemark or not, we can use such variable to guard the materialization.
Here are some solutions came up to me:
1. Check if `Conf.RemarksFilename` is empty, only materializing these dead functions when `Conf.RemarksFilename` is not empty. 
2. In `LTO::linkRegularLTO` collect all dead functions, and in `lto::finalizeOptimizationRemarks` call materialize and OptimizationRemarkEmitter for all dead functions. This will introduce a variable to store all dead functions.
Thanks again!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109737/new/

https://reviews.llvm.org/D109737



More information about the llvm-commits mailing list