This is an archive of the discontinued LLVM Phabricator instance.

[dsymutil] Generate Apple accelerator tables
ClosedPublic

Authored by JDevlieghere on Jan 24 2018, 1:16 PM.

Details

Summary

This patch adds support for generating accelerator tables in dsymutil.
This feature was already present in our internal repository but not yet
upstreamed because it requires changes to the Apple accelerator table
implementation.

Diff Detail

Repository
rL LLVM

Event Timeline

JDevlieghere created this revision.Jan 24 2018, 1:16 PM

Looks mostly good, the test coverage could probably be a little better.

tools/dsymutil/CMakeLists.txt
4 ↗(On Diff #131333)

What's the dependency that makes this necessary?

tools/dsymutil/DwarfLinker.cpp
918 ↗(On Diff #131333)

This comment should be on the declaration instead.

1311 ↗(On Diff #131333)

The + 1 is for a \NUL? And it's guaranteed to exist?

1569 ↗(On Diff #131333)

.

2038 ↗(On Diff #131333)

Is there a PR/radar about this?

JDevlieghere marked an inline comment as done.Jan 24 2018, 2:22 PM

Looks mostly good, the test coverage could probably be a little better.

Thanks for having a look, Adrian! I'm planning on extending the existing test with the other .apple_* sections. A bunch more tests will be added when upstreaming the -update functionality as well, but that's for another diff.

tools/dsymutil/CMakeLists.txt
4 ↗(On Diff #131333)

The call to dwarf::djbHash()

tools/dsymutil/DwarfLinker.cpp
1311 ↗(On Diff #131333)

I'll double check!

labath added inline comments.Jan 25 2018, 1:24 AM
tools/dsymutil/DwarfLinker.cpp
10–11 ↗(On Diff #131333)

This seems a bit dodgy. Shouldn't the header be moved to the include folder if you want to access it outside codegen ?

631 ↗(On Diff #131333)

There's no Offset in this function

JDevlieghere marked 6 inline comments as done.

Feedback @aprantl and @labath

aprantl added inline comments.Jan 25 2018, 2:43 PM
tools/dsymutil/DwarfLinker.cpp
104 ↗(On Diff #131420)

It seems odd to have this implementation live in DwarfLinker. I would have expected this to be part of AsmPrinter. Out of curiosity: Why is it not needed there? Is there something else that is only on opensource.apple.com and should really be on llvm.org?

465 ↗(On Diff #131420)

.

642 ↗(On Diff #131420)

These comments are not strictly necessary and basically just repeat the function name :-)

1597 ↗(On Diff #131420)

Does moving this field improve the layout somehow?

tools/dsymutil/dsymutil.h
43 ↗(On Diff #131420)

It looks like this option is entirely untested?

JDevlieghere marked 2 inline comments as done.Jan 25 2018, 2:57 PM

Thanks Adrian, I'll address your comments before committing this tomorrow morning.

tools/dsymutil/DwarfLinker.cpp
104 ↗(On Diff #131420)

I left it here as it was only used by the DwarfLinker, but happy to move it.

I'm not sure what you mean by your last two questions? The AppleAccelTableStaticOffsetData is the template argument for the new accelerator tables. Dsymutil generates different tables from the AsmPrinter; both have static offsets (the implementation in AsmPrinter queries the DIE for it's offset) and for types we emit two more atoms (QualifiedNameHash and whether it's a ObjCClassIsImplementation).

1597 ↗(On Diff #131420)

No, this seems unintentional. Actually it makes things worse :(

tools/dsymutil/dsymutil.h
43 ↗(On Diff #131420)

Because the value is always false actually it *is* tested, as this implies we always generate the pubnames and pubtypes section. I added it so I didn't have to remove the output, only to add it again once I implement the command line flag that will control this. When doing so I will also add a test that check the output for when the value is set to true.

JDevlieghere marked 2 inline comments as done.

@adrian: looks like I was mistaken and you didn't accept yet, so updating the patch to address your comments.

aprantl requested changes to this revision.Jan 26 2018, 9:06 AM

Almost there. Thanks for bearing with me!

include/llvm/CodeGen/AccelTable.h
453 ↗(On Diff #131518)

Doesn't need to happen in this commit, but I think we should move the implementation of the print functions into the cpp file.

tools/dsymutil/CMakeLists.txt
4 ↗(On Diff #131333)

That is silly :-) and dsymutil is already huge.

MD5 is in Support, so let's this function to Support too, and remove it from the dwarf namespace.

tools/dsymutil/DwarfLinker.cpp
1311 ↗(On Diff #131333)

Is there no EmitInt8() or EmitByte() ?

This revision now requires changes to proceed.Jan 26 2018, 9:06 AM
JDevlieghere marked 6 inline comments as done.Jan 26 2018, 10:03 AM
JDevlieghere added inline comments.
include/llvm/CodeGen/AccelTable.h
453 ↗(On Diff #131518)

Agree. I’ll do that in a follow-up commit.

tools/dsymutil/CMakeLists.txt
4 ↗(On Diff #131333)

Yesterday I noticed that there’s another use that needed this. Anyway, it will trigger a linker error and I’ll see if I can move that into support too.

tools/dsymutil/DwarfLinker.cpp
1311 ↗(On Diff #131333)

Makes more sense indeed. I mindlessly copied this from somewhere else...

copied it from somewhere else

Could you fix it there, too? :-)

JDevlieghere marked an inline comment as done.Jan 26 2018, 12:00 PM
JDevlieghere added inline comments.
tools/dsymutil/CMakeLists.txt
4 ↗(On Diff #131333)

D42594: Move DJB hash to support.

aprantl accepted this revision.Jan 26 2018, 1:36 PM

LGTM with the dependency on BinaryFormat removed.

This revision is now accepted and ready to land.Jan 26 2018, 1:36 PM
This revision was automatically updated to reflect the committed changes.