This is an archive of the discontinued LLVM Phabricator instance.

[BOLT][NFC] Improve performance of MCPlusBuilder::initAliases
ClosedPublic

Authored by jobnoorman on Mar 10 2023, 2:57 AM.

Details

Summary

It was using a redundant iteration over super regs to build
SmallerAliasMap. Removing this results in exactly the same alias maps
and a noticeable performance gain on targets with a large number of
registers.

Just anecdotally: on my machine, processing a small AArch64 binary went
from 2.7s down to 80ms.

Diff Detail

Event Timeline

jobnoorman created this revision.Mar 10 2023, 2:57 AM
Herald added a project: Restricted Project. · View Herald Transcript
jobnoorman requested review of this revision.Mar 10 2023, 2:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 10 2023, 2:57 AM
Amir accepted this revision.Mar 10 2023, 3:04 PM

Thanks!

This revision is now accepted and ready to land.Mar 10 2023, 3:04 PM

Thanks for the review, @Amir! I'm not sure if one accept is enough to get this landed but if it is, please note that I don't have commit rights so I cannot do it myself.

Amir added a comment.Mar 13 2023, 11:40 AM

Yes, one accept is enough. Please provide a commit author and email and I'll push it for you.

Job Noorman <jnoorman@igalia.com>

Thanks!

This revision was automatically updated to reflect the committed changes.
rafauler added inline comments.Mar 13 2023, 6:00 PM
bolt/lib/Core/MCPlusBuilder.cpp
468

X86 has registers with subregs, which in turn has their own subregs. e.g. RAX -> EAX -> AX -> AH, AL

I'm curious whether the subreg iterator here is returning the transitive list of all sub regs of a register? e.g. would it return AL as a subreg of RAX? That's what the old code was computing.

jobnoorman added inline comments.Mar 14 2023, 2:28 AM
bolt/lib/Core/MCPlusBuilder.cpp
468

It does:

// prints EAX AX AL AH HAX
for (MCSubRegIterator SI(X86::RAX, RegInfo); SI.isValid(); ++SI) {
  dbgs() << RegInfo->getName(*SI) << " ";
}
rafauler added inline comments.Mar 14 2023, 12:13 PM
bolt/lib/Core/MCPlusBuilder.cpp
468

Awesome, thanks for checking!