[llvm-bugs] [Bug 41804] New: Symbol ordering file is silently ignored with cgprofile generated with CGProfilePass

via llvm-bugs llvm-bugs at lists.llvm.org
Wed May 8 14:30:24 PDT 2019


https://bugs.llvm.org/show_bug.cgi?id=41804

            Bug ID: 41804
           Summary: Symbol ordering file is silently ignored with
                    cgprofile generated with CGProfilePass
           Product: lld
           Version: unspecified
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: ELF
          Assignee: unassignedbugs at nondot.org
          Reporter: tcwang at google.com
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org

I have found some problems in LLD dealing with the two flags
(--call-graph-order-file, and --symbol-ordering-file) that manipulates symbol
ordering. It might cause some confusions of precedence, especially if using new
pass manager.

Problem that I found:
In LLD, when we use a symbol ordering file (passed with
--symbol-ordering-file), we expect LLD to lay out symbols in the same order as
specified in the file. Also, there is another sort of ordering file: C3
ordering
(https://research.fb.com/wp-content/uploads/2017/01/cgo2017-hfsort-final1.pdf?).
It is implemented as a separate file passed with --call-graph-ordering-file. If
it's provided, LLD will order symbols using the call graph and do C3 stuff.

[With legacy pass manager] Currently in LLD, if both flags are provided,
--call-graph-ordering-file=<file> always takes precedence than
--symbol-ordering-file=<file>
(https://github.com/llvm/llvm-project/blob/master/lld/ELF/Writer.cpp#L1129).
This itself might cause a problem and we should probably do the same assumption
as other flags: take whichever flags comes last.

[With new pass manager] After the introduction new CGProfilePass
(https://github.com/llvm/llvm-project/blob/2946cd701067404b99c39fb29dc9c74bd7193eb3/llvm/lib/Transforms/Instrumentation/CGProfile.cpp),
which is triggered by new pass manager by default, will construct a call graph
through either instrumentation profiles or sample profiles and save the
information into a special section in each object file. And then LLD will
construct a call graph from these sections in object files (unless
--no-call-graph-profile-sort is passed). With the call graph constructed in
LLD, LLD will do C3 ordering by default if profiles are provided. This will be
a problem if a user specify --symbol-ordering-file and it will be silently
ignored since call graph takes precedence. This will silently break many cases
where users start to try new pass manager with profiles (so cgprofile is
generated implicitly) but keep using symbol ordering file. (In this case, they
should remember to always pass --no-call-graph-profile-sort with
--symbol-ordering-file to avoid the problem)

Possible solution:
I plan to submit a patch later to fix this problem. Any suggestions are
welcome.

Our proposal is to take whichever flag is passed later, if both flags are
specified explicitly. If only --symbol-ordering-file is present, cgprofile must
be ignored because it means the user wants to use symbol ordering. If none of
the flags are specified, we should keep the current behavior: do c3 ordering by
default if profiles are provided and use new pass manager, or do nothing if
not.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190508/1efb9a11/attachment.html>


More information about the llvm-bugs mailing list