This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj/obj2yaml] - Make Value/Size fields of Symbol optional.
ClosedPublic

Authored by grimar on Dec 10 2020, 1:25 AM.

Details

Summary

When a field is optional we can use the =<none> syntax in macros.
This patch makes Value/Size fields of Symbol optional
and adds test cases for them.

Diff Detail

Event Timeline

grimar created this revision.Dec 10 2020, 1:25 AM
grimar requested review of this revision.Dec 10 2020, 1:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 10 2020, 1:25 AM
grimar set the repository for this revision to rG LLVM Github Monorepo.Dec 10 2020, 1:25 AM
jhenderson added inline comments.Dec 11 2020, 6:04 AM
llvm/test/tools/obj2yaml/ELF/symbol.yaml
2
17

That's needed or you won't be able to add more documents in the future to the test file, I've discovered. Same below.

llvm/test/tools/yaml2obj/ELF/symbol-value-size.yaml
1 ↗(On Diff #310794)

I'm slightly concerned that this test name and purpose is a bit restrictive. Why doesn't it apply to other symbol fields, like type, other or section index? (I'm not saying those tests need adding in this change, but it feels like there's no special reason why value and size are in one test and the others aren't in the same one).

3 ↗(On Diff #310794)

Perhaps worth a comment saying something like "show the default size and value is 0".

16–17 ↗(On Diff #310794)
30 ↗(On Diff #310794)
36 ↗(On Diff #310794)
grimar updated this revision to Diff 311530.Dec 14 2020, 2:11 AM
grimar marked 7 inline comments as done.
  • Addressed review comments.
llvm/test/tools/obj2yaml/ELF/symbol.yaml
17

You actually can add documents, you just need to be sure that 2nd and other document has --- !ELF.
For the first one it is not really important. I did it though.

llvm/test/tools/yaml2obj/ELF/symbol-value-size.yaml
1 ↗(On Diff #310794)

I did it for consistency. Currently we have the following list of tests for symbols:

symbol-stother.yaml
symbol-type.yaml
symbol-binding.yaml
symbol-index.yaml
symbol-index-invalid.yaml
symbol-name.yaml
symbol-visibility.yaml

Perhaps, we should merge them into a single test in a follow-up.

3 ↗(On Diff #310794)

The symbol to "show the default size and value is 0" is aaa, I have the comment for it below.
This particular call and check lines are not not testing anything valuable (used to bypass
the header and the null symbol).

grimar added inline comments.Dec 14 2020, 2:16 AM
llvm/test/tools/yaml2obj/ELF/symbol-value-size.yaml
1 ↗(On Diff #310794)

Note that value and size are the only llvm::yaml::Hex64 values of a symbol.
And the logic of handling them is very similar. It is probably reasonable to test them in a single test/subtest.

jhenderson added inline comments.Dec 15 2020, 12:57 AM
llvm/test/tools/yaml2obj/ELF/symbol-value-size.yaml
10 ↗(On Diff #311530)

Perhaps ---

1 ↗(On Diff #310794)

I think it would make sense to either have all fields tested in a single file, or all in separate files. I don't think the hex nature of these ones is sufficient reason for these two to be diffferent. If doing them all in a single file, you could do everything using decimal, and then show that hex can be used too in an additional single case at the end, I guess.

3 ↗(On Diff #310794)

Perhaps we don't need the header check at all actually? As it is, it looks like it's verifying something important, but the null entry and symbol count should be covered elsewhere, I reckon.

grimar updated this revision to Diff 311847.Dec 15 2020, 2:24 AM
grimar marked 3 inline comments as done.
  • Addressed review comments.
llvm/test/tools/yaml2obj/ELF/symbol-value-size.yaml
1 ↗(On Diff #310794)

I've splitted this test.

3 ↗(On Diff #310794)

I've removed it.

jhenderson accepted this revision.Dec 16 2020, 12:44 AM

Looks good, with one possible set of suggestions.

llvm/test/tools/yaml2obj/ELF/symbol-size.yaml
16–17

Up to you, but here and below, you could probably reduce the amount of stuff needed by the test by using regex wildcards/numeric expressions to skip much of the check. For example, see the inline edit. The same technique could probably be used for each of the other cases too, in both tests.

llvm/test/tools/yaml2obj/ELF/symbol-value.yaml
16–17

Equivalent suggestion to above.

This revision is now accepted and ready to land.Dec 16 2020, 12:44 AM
grimar marked 2 inline comments as done.Dec 16 2020, 3:00 AM
grimar added inline comments.
llvm/test/tools/yaml2obj/ELF/symbol-size.yaml
16–17

Thanks for the suggestion! I've applied it.

This revision was automatically updated to reflect the committed changes.
grimar marked an inline comment as done.