This is an archive of the discontinued LLVM Phabricator instance.

[llvm-size] print a blank line between archieve members when using sysv format
ClosedPublic

Authored by TH3CHARLie on Dec 28 2019, 12:39 AM.

Details

Summary

This patch is related to https://bugs.llvm.org/show_bug.cgi?id=42967 and it fixes llvm-size's sysv format output by adding a blank line between archieve members

Diff Detail

Event Timeline

TH3CHARLie created this revision.Dec 28 2019, 12:39 AM
Jim added a subscriber: Jim.Dec 30 2019, 12:23 AM

The testcases tools/llvm-size/archive.test, tools/llvm-size/multiple-inputs.test and tools/llvm-size/radix.test
fail due to this patch. Could you update this testcases? You can try to execute command "ninja check-all -j32".

llvm/tools/llvm-size/llvm-size.cpp
449–450

Put "<< "\n"" in the new line look better.

outs() << format... 
       << "\n";

update testcases

In D71957#1798590, @Jim wrote:

The testcases tools/llvm-size/archive.test, tools/llvm-size/multiple-inputs.test and tools/llvm-size/radix.test
fail due to this patch. Could you update this testcases? You can try to execute command "ninja check-all -j32".

Hi, thanks for the reivew and I have updated it with a new patch. However, I'm new to LLVM's review system, I wonder where can I check the status of the testcases, it will be grateful if you can point it out to me.

Jim added inline comments.Dec 30 2019, 1:54 AM
llvm/tools/llvm-size/llvm-size.cpp
449

It should be origin one before any of your changes.

revert to origin

Jim added a comment.Dec 30 2019, 2:27 AM

There shows "Context not available."
Please follow https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface to upload patch.

fix context

Jim added a comment.Dec 30 2019, 6:34 PM

LGTM.
But I have tried gnu size, and I found that has two blank lines between archive members.
Here only one blank line.
What's your opinion?

TH3CHARLie marked an inline comment as done.EditedDec 30 2019, 7:06 PM
In D71957#1799537, @Jim wrote:

LGTM.
But I have tried gnu size, and I found that has two blank lines between archive members.
Here only one blank line.
What's your opinion?

If strictly following to the issue's(recall from https://bugs.llvm.org/show_bug.cgi?id=42967) description, adding one blank line would be enough. But indeed this looks inconsistent with GNU's size in sysv format:

  1. GNU's size print two blank lines between archive members, this PR prints one
  2. At end of the file, GNU's size prints no newline(but since last archive member prints two blank lines), llvm-size prints an additional newline at end of file(see line 843-845).

Thus, I think it is better to adjust this PR so llvm-size's behavior is identical with GNU's

I update the patch, now llvm-size's behavior is more(if not 100%) similar to GNU's size:

  1. two newlines after archive member
  2. no newline when the archive is empty
Jim accepted this revision.Jan 1 2020, 7:11 PM

LGTM.

This revision is now accepted and ready to land.Jan 1 2020, 7:11 PM
MaskRay accepted this revision.Jan 1 2020, 7:17 PM
MaskRay added a subscriber: MaskRay.
MaskRay added inline comments.
llvm/tools/llvm-size/llvm-size.cpp
579

Delete else and add a new line as you added return above.

MaskRay added inline comments.Jan 1 2020, 7:19 PM
llvm/test/tools/llvm-size/archive.test
51

GNU size prints 2 blank lines.

TH3CHARLie updated this revision to Diff 235817.Jan 1 2020, 7:53 PM

delete else and add newline

TH3CHARLie marked 3 inline comments as done.Jan 1 2020, 7:54 PM
TH3CHARLie added inline comments.
llvm/test/tools/llvm-size/archive.test
51

I believe this is necessary, see radix.test's case 4-6

TH3CHARLie marked an inline comment as done.Jan 2 2020, 12:18 AM

@MaskRay Hi, could you please review the newest update and commit it if you feel OK about it since looks like I have no commit access

MaskRay added inline comments.Jan 2 2020, 12:37 AM
llvm/test/tools/llvm-size/archive.test
51

--format=sysv prints exactly two blank lines between two blocks. Your patch currently prints 3.

After you fix this, you may need to provide git commit --amend --author "what-is-your-name <what-is@your-email>"

TH3CHARLie marked an inline comment as done.Jan 2 2020, 12:50 AM
TH3CHARLie added inline comments.
llvm/test/tools/llvm-size/archive.test
51

As you can tell from the patch, there was a SYSV-3-EMPTY in the testcase before this patch. The original code prints no new lines between blocks and to match the newly added 2 newlines, 2 corresponding SYSV-3-EMPTY is needed here.

If we remove a SYSV-3-EMPTY here, error will be generated:

bash
/home/yxd/llvm-project/llvm/test/tools/llvm-size/archive.test:52:16: error: SYSV-3-NEXT: is not on the line after the previous match
# SYSV-3-NEXT: archive.test.tmp1 (ex [[ARCHIVE2]]):
               ^
<stdin>:10:1: note: 'next' match was here
archive.test.tmp1 (ex /home/yxd/llvm-project/build/test/tools/llvm-size/Output/archive.test.tmp2.a):
^
<stdin>:8:1: note: previous match ended here

^
<stdin>:9:1: note: non-matching line after previous match is here

Although I'm not sure about why there was a SYSV-3-EMPTY here before adding any newlines, it is required here to add the two SYSV-3-EMPTY to pass the test. BTW, I have also verified with custom testcases.

Jim added inline comments.Jan 2 2020, 2:48 AM
llvm/test/tools/llvm-size/archive.test
51

This is non-archives (single object file).

llvm/tools/llvm-size/llvm-size.cpp
826

Fix here. It prints 3 blank lines. 2 blank lines is from printObjectSectionSizes and 1 blank line from

// System V adds an extra newline at the end of each file.
  if (OutputFormat == sysv)
    outs() << "\n";
Jim requested changes to this revision.Jan 2 2020, 3:11 AM
This revision now requires changes to proceed.Jan 2 2020, 3:11 AM
TH3CHARLie updated this revision to Diff 235855.Jan 2 2020, 5:15 AM

The extra newline originally printed is now removed since GNU size print two newlines for single object files

TH3CHARLie marked 2 inline comments as done.Jan 2 2020, 5:16 AM
jhenderson accepted this revision.Jan 2 2020, 8:52 AM

LGTM. Please make sure @Jim is happy with this too.

llvm/tools/llvm-size/llvm-size.cpp
449–450

I think this is correct, but to be sure if you haven't already, run git-clang-format on the modified part to verify your formatting choices match the official style (see https://llvm.org/docs/GettingStarted.html#sending-patches).

Jim added inline comments.Jan 2 2020, 6:14 PM
llvm/tools/llvm-size/llvm-size.cpp
579

I think this change is not needed. If you delete line 842-844.

TH3CHARLie marked an inline comment as done.Jan 2 2020, 8:36 PM
TH3CHARLie updated this revision to Diff 235991.Jan 2 2020, 8:42 PM

restore if-else logic

TH3CHARLie marked 2 inline comments as done.Jan 2 2020, 8:43 PM
TH3CHARLie added inline comments.
llvm/tools/llvm-size/llvm-size.cpp
449–450

Thanks for the heads up and I've run the clang-format which put the "\n\n" into a newline

TH3CHARLie marked an inline comment as done.Jan 2 2020, 9:07 PM
Jim accepted this revision.Jan 2 2020, 9:11 PM
This revision is now accepted and ready to land.Jan 2 2020, 9:11 PM
TH3CHARLie added a comment.EditedJan 2 2020, 9:35 PM

@Jim Thanks for the review! I wonder is there anything else I have to do before committing the patch? I've used git commit --amend to add author and e-mail and what should I do next. And seems like I have no commit access according to https://llvm.org/docs/Phabricator.html#committing-a-change

Jim added a comment.Jan 2 2020, 9:43 PM

@TH3CHARLie
I can commit this for you.
git commit --amend --author="What-is-your-name <What-is-your-email-address>" ?
If you are interested in obtaining commit right. please refer to https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

In D71957#1802393, @Jim wrote:

@TH3CHARLie
I can commit this for you.
git commit --amend --author="What-is-your-name <What-is-your-email-address>" ?
If you are interested in obtaining commit right. please refer to https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

Please commit this for me
git commit --amend --author="TH3CHARLie <th3charlie@gmail.com>"
And I am interested in obtaining commit right for future revisions, thank you and I will definitely take a look

This revision was automatically updated to reflect the committed changes.