This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Copy the implementation of SubtargetFeature and use it for PredicateBitset.
ClosedPublic

Authored by craig.topper on Aug 22 2023, 7:38 PM.

Details

Summary

PredicateBitset currently uses std::bitset, but std::bitset doesn't
have a constexpr constructor or any constexpr methods until C++23.
Each target that supports GlobalIsel has as an array of PredicateBitset
objects that currently use a global constructor.

SubtargetFeature used by the MC layer for feature bits, has its own
implementation of std::bitset that has constexpr constructor and methods
that provides all the capabilities that PredicateBitset needs.

This patch copies the implementation from SubtargetFeature, makes
it a template class, and puts it in ADT. I'll migrate SubtargetFeature
in a separate patch. Adapting all existing users to it being a template
was distracting from the goal of this patch.

This reduces the binary size of llc built with gcc 8.5.0 on my local
build by ~15k.

Diff Detail

Event Timeline

craig.topper created this revision.Aug 22 2023, 7:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 7:38 PM
craig.topper requested review of this revision.Aug 22 2023, 7:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 7:38 PM
Herald added a subscriber: wdng. · View Herald Transcript
arsenm accepted this revision.Aug 23 2023, 2:54 PM
This revision is now accepted and ready to land.Aug 23 2023, 2:54 PM
This revision was landed with ongoing or failed builds.Aug 23 2023, 3:58 PM
This revision was automatically updated to reflect the committed changes.

LGTM.

This reduces the binary size of llc built with gcc 8.5.0 on my local build by ~15k.

Interesting. When building llc with near-thunk clang, the size goes down from 47637800 to 47637776 (small decrease). The small change is mainly in bool llvm::GIMatchTableExecutor::executeMatchTable

MaskRay added inline comments.Aug 23 2023, 5:33 PM
llvm/include/llvm/ADT/Bitset.h
59

The unneeded workaround was copied. I created https://reviews.llvm.org/D158687 as a cleanup.