This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] [CodeGenTarget] Cache the target's instruction namespace
ClosedPublic

Authored by Paul-C-Anagnostopoulos on Dec 5 2020, 7:38 AM.

Details

Summary

This revision caches the target machine's instruction namespace in CodeGenTarget. The namespace is requested multiple times by backends and involves a linear scan of the vector of records inheriting from Instruction.

I've separated this revision from https://reviews.llvm.org/D92674 and will remove it from that revision.

Diff Detail

Event Timeline

Paul-C-Anagnostopoulos requested review of this revision.Dec 5 2020, 7:38 AM
Paul-C-Anagnostopoulos created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2020, 7:38 AM
lattner accepted this revision.Dec 5 2020, 8:03 AM
This revision is now accepted and ready to land.Dec 5 2020, 8:03 AM

Is there much data to suggest this is an observable performance issue? (if the number of times it's queried is small, or the number of elements it searches through is small, etc - perhaps it doesn't matter & the simpler code might be better?)

llvm/utils/TableGen/CodeGenTarget.h
63

The = StringRef() is redundant here and should be omitted.

I can't separate the performance increases of the two caching revisions, but I suspect the other one produces most of the improvement (https://reviews.llvm.org/D92674).

At least one backend requests the namespace 22 times, and the search is linear and must skip all the TargetOpcode instructions. There are about 200 of them, I think.

But if you think this is pointless, I'm happy to discard it. On the other hand, it's a total of 3 new lines of code.

I can't separate the performance increases of the two caching revisions, but I suspect the other one produces most of the improvement (https://reviews.llvm.org/D92674).

At least one backend requests the namespace 22 times, and the search is linear and must skip all the TargetOpcode instructions. There are about 200 of them, I think.

Yeah, I'd expect that's pretty cheap/not a major performance consideration.

But if you think this is pointless, I'm happy to discard it. On the other hand, it's a total of 3 new lines of code.

Up to you - no strong feelings. Your call.

Paul-C-Anagnostopoulos marked an inline comment as done.

Eliminated explicit InstNamespace initializer.