Skip to content

Commit

Permalink
[GISel] Make RegBank constructor constexpr. NFC (#71109)
Browse files Browse the repository at this point in the history
RegBanks are constructed as global objects. Making the constructor
constexpr helps the compiler construct it without a global
constructor.
    
clang's optimizer seems to figure this out on its own, but at
least gcc 8 does not.
  • Loading branch information
topperc authored and zahiraam committed Nov 20, 2023
1 parent 79c52a8 commit 0a80b70
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions llvm/include/llvm/CodeGen/RegisterBank.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class RegisterBank {
friend RegisterBankInfo;

public:
RegisterBank(unsigned ID, const char *Name, const uint32_t *CoveredClasses,
unsigned NumRegClasses)
constexpr RegisterBank(unsigned ID, const char *Name,
const uint32_t *CoveredClasses, unsigned NumRegClasses)
: ID(ID), NumRegClasses(NumRegClasses), Name(Name),
CoveredClasses(CoveredClasses) {}

Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/TableGen/RegisterBankEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void RegisterBankEmitter::emitBaseClassImplementation(
for (const auto &Bank : Banks) {
std::string QualifiedBankID =
(TargetName + "::" + Bank.getEnumeratorName()).str();
OS << "const RegisterBank " << Bank.getInstanceVarName() << "(/* ID */ "
OS << "constexpr RegisterBank " << Bank.getInstanceVarName() << "(/* ID */ "
<< QualifiedBankID << ", /* Name */ \"" << Bank.getName() << "\", "
<< "/* CoveredRegClasses */ " << Bank.getCoverageArrayName()
<< ", /* NumRegClasses */ "
Expand Down

0 comments on commit 0a80b70

Please sign in to comment.