This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] Display multiple function names for stack size entries
ClosedPublic

Authored by gbreynoo on Jul 13 2021, 3:34 AM.

Details

Summary

The current implementation of displaying .stack_size information presumes that each entry represents a single function but this is not always the case. For example with the use of ICF multiple functions can be represented with the same code, meaning that the address found in a .stack_size entry corresponds to multiple function symbols.
This change allows multiple function names to be displayed when appropriate.

Diff Detail

Event Timeline

gbreynoo created this revision.Jul 13 2021, 3:34 AM
gbreynoo requested review of this revision.Jul 13 2021, 3:34 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2021, 3:34 AM

See https://bugs.llvm.org/show_bug.cgi?id=43245 which I believe was incorrectly marked as fixed, as the behaviour described in the bug ticket is still present.

I want to note here, in the case of --elf-output-style=GNU this change should not be disruptive for the usual use case in which only one function symbol corresponds to an entry. However the --elf-output-style=LLVM output requires these symbols to be displayed as a list, meaning in the usual use case a list of size one will be output for each .stack_size entry.

This change touches printBBAddrMaps due to implementation but should see no behaviour difference.

I realise a number of other tests require updating due to the change in output, I'll fix them up once an agreement has been made regarding this change.

jhenderson added inline comments.Jul 14 2021, 2:29 AM
llvm/test/tools/llvm-readobj/ELF/stack-sizes-multiple-symbols.test
1 ↗(On Diff #358219)

It probably makes more sense to add this test case to the existing stack-sizes.test test.

llvm/test/tools/llvm-readobj/ELF/stack-sizes.test
180

Multiple symbols with the same value is not specific to executables, so combining these test cases sounds like it risks confusion. It probably makes more sense to just take the multiple symbols case you've written in a separate file and add it to this file.

llvm/tools/llvm-readobj/ELFDumper.cpp
65

What's this for?

305–308

Make sure to clang-format new/modified code.

5814

Nit: fix all the clang-tidy warnings.

5825

Use ArrayRef for passing around vectors by reference. Same elsewhere.

5831

Use StringRef, not const std::string &.

gbreynoo updated this revision to Diff 360078.Jul 20 2021, 3:58 AM
gbreynoo marked 2 inline comments as done.
  • Fixed a test
  • Correct use of clang-tidy
  • Use ArrayRef where appropriate
gbreynoo marked 3 inline comments as done.Jul 20 2021, 3:59 AM

I also folded the new stack-size test into the existing one as requested.

llvm/tools/llvm-readobj/ELFDumper.cpp
65

This is for use of std::accumulate

jhenderson added inline comments.Jul 20 2021, 4:34 AM
llvm/test/tools/llvm-readobj/ELF/stack-sizes.test
893–895

Use ## for comments in test files.

llvm/tools/llvm-readobj/ELFDumper.cpp
5814

Ping: this hasn't been addressed.

5831

Ping: this hasn't been addressed (nor has the adjacent clang-tidy issue).

gbreynoo updated this revision to Diff 360110.Jul 20 2021, 6:48 AM
gbreynoo updated this revision to Diff 360145.Jul 20 2021, 8:15 AM
gbreynoo updated this revision to Diff 360150.Jul 20 2021, 8:25 AM
gbreynoo marked an inline comment as done.

Apologies for the noise, I missed a filecheck prefix.

gbreynoo updated this revision to Diff 360174.Jul 20 2021, 9:34 AM
gbreynoo marked 3 inline comments as done.Jul 20 2021, 9:37 AM
gbreynoo added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
5829

After some offline discussion around the inefficiency of the previous implementation, the use of join makes more sense here.

MaskRay accepted this revision.Jul 20 2021, 10:31 AM

I agree that functions is more suitable. That may happen with ICF.

This revision is now accepted and ready to land.Jul 20 2021, 10:31 AM
jhenderson accepted this revision.Jul 23 2021, 1:43 AM

LGTM, with one nit.

llvm/tools/llvm-readobj/ELFDumper.cpp
65

I believe you can now remove this include?

This revision was landed with ongoing or failed builds.Jul 26 2021, 6:57 AM
This revision was automatically updated to reflect the committed changes.
gbreynoo marked an inline comment as done.Jul 26 2021, 6:58 AM
gbreynoo added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
65

Good catch, I've removed it.