This is an archive of the discontinued LLVM Phabricator instance.

[BOLT][NFC] Fix MCPlusBuilder::getAliases caching behavior
ClosedPublic

Authored by Amir on May 4 2022, 10:13 AM.

Details

Summary

Caching behavior of getAliases causes a failure in unit tests where two
MCPlusBuilder objects are created corresponding to AArch64 and X86:
the alias cache is created for AArch64 but then used for X86.

https://lab.llvm.org/staging/#/builders/211/builds/126

The issue only affects unit tests as we only construct one MCPlusBuilder
for ELF binary.

Resolve the issue by moving alias bitvectors to MCPlusBuilder object.

Diff Detail

Event Timeline

Amir created this revision.May 4 2022, 10:13 AM
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Amir requested review of this revision.May 4 2022, 10:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 4 2022, 10:13 AM
yota9 added a comment.EditedMay 4 2022, 10:22 AM

-

bolt/lib/Core/MCPlusBuilder.cpp
443–444

Thanks, strange that we didn't come across it before. But maybe it would be better to move these vectors to MCPlusBuilder object?

Amir retitled this revision from [BOLT][TEST] Fix MCPlusBuilder::getAliases with two targets to [BOLT][TEST] Fix MCPlusBuilder::getAliases caching behavior.May 4 2022, 10:41 AM
Amir edited the summary of this revision. (Show Details)
Amir added inline comments.May 4 2022, 10:43 AM
bolt/lib/Core/MCPlusBuilder.cpp
443–444

Yes, it’s really strange, but I've confirmed on a buildbot that it's really happening. Looks like we might randomly "get lucky" with aliases depending on register ids.

It's a good idea to move these vectors to MCPlusBuilder.

Amir updated this revision to Diff 427072.May 4 2022, 11:11 AM

Move AliasMap and SmallerAliasMap into MCPlusBuilder object;
split initAliases from getAliases.

Amir retitled this revision from [BOLT][TEST] Fix MCPlusBuilder::getAliases caching behavior to [BOLT][NFC] Fix MCPlusBuilder::getAliases caching behavior.May 4 2022, 11:12 AM
Amir edited the summary of this revision. (Show Details)
Amir marked an inline comment as done.
yota9 added inline comments.May 4 2022, 11:16 AM
bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
1153 ↗(On Diff #427072)

Maybe move it to the common MCPlusBuilder constructor?

Amir updated this revision to Diff 427077.May 4 2022, 11:24 AM

Move initAliases to MCPlusBuilder ctor

Amir marked an inline comment as done.May 4 2022, 11:24 AM
Amir added inline comments.
bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp
1153 ↗(On Diff #427072)

That works too. Wasn't sure about invoking a virtual method from a base constructor.

yota9 accepted this revision.May 4 2022, 11:25 AM

LGTM Thanks!

This revision is now accepted and ready to land.May 4 2022, 11:25 AM
This revision was automatically updated to reflect the committed changes.
Amir marked an inline comment as done.