This is an archive of the discontinued LLVM Phabricator instance.

[TLI checker] Update for post-commit review comments
ClosedPublic

Authored by probinson on Nov 23 2021, 2:55 PM.

Details

Summary

See D111358 for post-commit review comments; I've answered the questions and comments there.
This review has the minor code updates, and replaces the asm/object-file test with a yaml equivalent.

Diff Detail

Event Timeline

probinson requested review of this revision.Nov 23 2021, 2:55 PM
probinson created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 23 2021, 2:55 PM
jhenderson added inline comments.Nov 24 2021, 1:05 AM
llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml
10

I might be missing something obvious, but what's the point of this echo? Can't the object be passed directly on the command-line?

54–57

How important are these fields for the tool? Are they actually needed, or could you get away without them for the purpose of this test?

(I believe the Link: .dynstr is implicit, so you should be able to omit that regardless)

Same question for the other sections.

71–74

Are the Value and Type fields important to the tool?

Also, do you need this many symbols (it's fine if you do, just is a lot!)?

llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
107–108

Is this check strictly appropriate?

  1. There are efforts to add D and Rust demangling schemas to the set of supported functionality in the LLVM demangler, and this tool would not work with them.
  2. It seems like you should just attempt to call demangle and check to see if the output is different to the input string, to determine whether the name is actually demangled. Otherwise, you could end up with input symbol names that aren't valid (or aren't supported by the demangler) reading something like this "_Zsomeinvalidstring aka _Zsomeinvalidstring", which probably isn't what you want. If you really don't want to even attempt to demangle something (or you only want to support Itanium and Microsoft mangling schemes), you should probably make the is*Encoding functions in demangle.cpp into external functions that you can reference here.
170–171

If the tool can take more than one input (I haven't checked if it can), it might be wise to include the filename in this message.

probinson added inline comments.Nov 24 2021, 7:46 AM
llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml
10

The point is to test that response files work, a feature that is described in the help text.
I can take that out if you think it's unnecessary.

54–57

I got to this point by doing obj2yaml on one of the previous .so files and then deleting things that were clearly irrelevant and didn't make the test fail. I have no idea which fields/sections are necessary and there was a limit to how much fiddling I was willing to do. If you have guidance in this respect I'd be happy to reduce it further.

71–74

The tool checks Type and Binding. I have no idea whether the other fields matter; they came with the obj2yaml output. If you tell me I can delete Section and Value, I'm okay to do that.

I do need all of these symbols, because the object file has to define exactly the same set of symbols that TLI expects to find for this target.

llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
107–108

These are the mangling prefixes used in the list of functions known to TLI, and the mangled names are all for C++ operators. If there will be Rust or D-specific library functions added to TLI, then yes this function would need to be updated. It's not intended to work for arbitrary functions, just the ones that TLI knows about.

The idea was to avoid the relatively expensive demangling and string comparison for names that wouldn't need it; but as the printable name isn't used that much, I can recode this to do the trial demangle and string compare.

probinson updated this revision to Diff 389509.Nov 24 2021, 8:22 AM
probinson marked 4 inline comments as done.

Remove more unnecessary sections/fields from yaml file.
Report filename in a warning message.
Unconditionally demangle function name for future-proofing.

jhenderson added inline comments.Nov 25 2021, 12:26 AM
llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml
10

Ah, fair enough. Leave it in, but perhaps add a comment to say that that's what this is testing specifically (it looked to me like this was just trying to workaround something by using a response file).

54–57

I'm not familiar with what the tool looks at, so being able to point out which symbols are needed is a little tricky. We've tried to minimise unnecessary obj2yaml output, but it's not always possible to get it to the bare minimum required for a specific piece of code.

71–74

Removing the Section field makes the symbols undefined. That may or may not be an issue, but at a guess, you don't want your symbols to be undefined, and such symbols may not want to be considered "in the SDK" for the purposes of the tool, right?

llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
107–108

The idea was to avoid the relatively expensive demangling and string comparison for names that wouldn't need it; but as the printable name isn't used that much, I can recode this to do the trial demangle and string compare.

I guess the expensive bit is really checking whether the output is the same as the input, since the demangling will fail as fast as those checks would have done. Perhaps we need a new demangle signature that indicates whether demangling has occurred. Probably only worth it if there is a performance concern though.

170–171

Usual format is "warning: file name: message" (see what FileError does for a comparison).

probinson added inline comments.Nov 29 2021, 10:44 AM
llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml
71–74

It never occurred to me that Dynamic Symbols could be undefined, but no I suppose they shouldn't be considered as "in the SDK." I'll have to do something about that.

llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
107–108

This is the simplest of several demangling APIs. A few hundred string compares probably aren't a performance concern though, in this context.

probinson updated this revision to Diff 390460.Nov 29 2021, 1:57 PM

Tidy up error handling for more consistency.
Ignore unsupported symbols.

probinson marked 3 inline comments as done.Nov 29 2021, 2:00 PM
probinson added inline comments.
llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml
10

Added a comment here, and a few other places to better describe the testing.

54–57

I was actually asking about fields, not symbols, but I think it's as minimal as it can get at this point.

llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
170–171

Updated to put filename first, here and elsewhere.

jhenderson added inline comments.Nov 30 2021, 12:25 AM
llvm/test/tools/llvm-tli-checker/ps4-tli-check.yaml
54–57

Yes, looks pretty minimal now, since we need lots of symbols.

71–74

FYI, undefined dynamic symbols are imports.

llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
170–171

Is this warning message tested anywhere? I don't see it immediately, and I'd expect test failures if it were tested elsewhere due to the format change. Same goes for the other warnings/errors reported in this file.

238

I'd be tempted to use plain English here, rather than class names to describe this situation, as end users don't know about the classes, i.e. "not an archive or object file"

probinson updated this revision to Diff 390732.Nov 30 2021, 8:18 AM
probinson marked 3 inline comments as done.

Fix warning capitalization

probinson marked an inline comment as done.Nov 30 2021, 8:20 AM
probinson added inline comments.
llvm/tools/llvm-tli-checker/llvm-tli-checker.cpp
170–171

None of the malformed-input messages are tested.
Neither are multiple inputs, or using an archive as input.
I'd prefer to defer those to a separate patch if that's okay. You know where to find me, it'll happen. :)

jhenderson accepted this revision.Dec 1 2021, 1:50 AM

All looks good to me. I see there are a couple of @MaskRay's comments that you chose not to address (with reasons described in the original patch), but you might want to give him a chance to check before pushing this.

This revision is now accepted and ready to land.Dec 1 2021, 1:50 AM
This revision was landed with ongoing or failed builds.Dec 1 2021, 12:35 PM
This revision was automatically updated to reflect the committed changes.

LGTM. Thanks!