New issue
Advanced search Search tips

Issue 902723 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Nov 8
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 2
Type: Bug



Sign in to add a comment

Supersize ThinLTO with optimizations causing some symbols to not have path info

Project Member Reported by agrieve@google.com, Nov 7

Issue description

From this change:
https://chromium-review.googlesource.com/c/chromium/src/+/1149061

Symbol names have " (.llvm.032939022)" appended. Probably just need to strip when parsing map file.
 
Labels: -Pri-3 Pri-2
Owner: hua...@chromium.org
I think he meant to assign it to the other sam
As pointed out earlier, to repro this one just have to add

  thin_lto_enable_optimizations = true

to args.gn.

In libchrome.so.map we find symbols like 

  .ARM.exidx.text._ZN5media12_GLOBAL__N_114GetBeepContextEv.llvm.5513108144494008565

llvm-cxxfilt then demangles these to:

  media::(anonymous namespace)::GetBeepContext() (.llvm.5513108144494008565)

This appears in about ~3500 symbols. The name actually came from section names in the generated ELF .o files in thinlto-cache. Also, it looks like the suffix comes from

https://github.com/llvm-mirror/llvm/blob/master/include/llvm/IR/ModuleSummaryIndex.h

********
  /// Convenience method for creating a promoted global name
  /// for the given value name of a local, and its original module's ID.
  static std::string getGlobalNameForLocal(StringRef Name, ModuleHash ModHash) {
    SmallString<256> NewName(Name);
    NewName += ".llvm.";
    NewName += utostr((uint64_t(ModHash[0]) << 32) |
                      ModHash[1]); // Take the first 64 bits
    return NewName.str();
  }
========

So the numbers is some sort of hash.

Project Member

Comment 4 by bugdroid1@chromium.org, Nov 8

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3828fe01699687de32f501d1719f4c39c958cd3c

commit 3828fe01699687de32f501d1719f4c39c958cd3c
Author: Samuel Huang <huangs@chromium.org>
Date: Thu Nov 08 16:15:49 2018

[SuperSize] Ignore LLVM promoted global names suffix (.llvm.1234).

Under LLD ThinLTO, if thin_lto_enable_optimizations is enabled then
"promoted global names" can appear. For these, mangled symbol names get
the suffix '.llvm.1234' or '.1.llvm.1234', where '1' is a small number,
and '1234' is a hash. When demangled, the suffix becomes ' (.llvm.1324)'
or ' (.1.llvm.1324)' if successful; and is left alone otherwise.

These suffix interferes with name comparison, leading to secondary
problems like symbols losing path info.

This CL makes SuperSize detect and strip these suffixes, to reduce
spurious diffs from enabling ThinLTO optimization. The transformation
is applied when parsing .map and nm output. Details:
* Add demangle.StripLlvmPromotedGlobalNames(), which performs a
  quick-reject substring test for '.llvm.', followed by RegExp
  string substitution.
* Print the number of promoted global names found in .map file.
* Minor updates to comments and tests.

Bug:  902723 
Change-Id: I4ca4142c891c948894c10180b31ff65b759cccfe
Reviewed-on: https://chromium-review.googlesource.com/c/1324192
Commit-Queue: Samuel Huang <huangs@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Reviewed-by: Samuel Huang <huangs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606487}
[modify] https://crrev.com/3828fe01699687de32f501d1719f4c39c958cd3c/tools/binary_size/libsupersize/demangle.py
[modify] https://crrev.com/3828fe01699687de32f501d1719f4c39c958cd3c/tools/binary_size/libsupersize/linker_map_parser.py
[modify] https://crrev.com/3828fe01699687de32f501d1719f4c39c958cd3c/tools/binary_size/libsupersize/testdata/mock_toolchain/mock_nm.py

Status: Fixed (was: Assigned)

Sign in to add a comment