Skip to content

Commit b14d344

Browse files
committed
[GISel] Make the PartialMapping and ValueMapping constructors constexpr.
Backends contain static tables of PartialMapping and ValueMapping. Without the constexpr, the initial code from the frontend contains a global constructor to construct each entry of the table. The clang optimizer is able to optimize the constructors away, but gcc 8 is not able to. Using constexpr allows the tables to be created directly in the frontend without requiring optimizations to be performed.
1 parent c7b3b71 commit b14d344

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/include/llvm/CodeGen/RegisterBankInfo.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ class RegisterBankInfo {
6363
PartialMapping() = default;
6464

6565
/// Provide a shortcut for quickly building PartialMapping.
66-
PartialMapping(unsigned StartIdx, unsigned Length,
67-
const RegisterBank &RegBank)
66+
constexpr PartialMapping(unsigned StartIdx, unsigned Length,
67+
const RegisterBank &RegBank)
6868
: StartIdx(StartIdx), Length(Length), RegBank(&RegBank) {}
6969

7070
/// \return the index of in the original value of the most
@@ -157,7 +157,8 @@ class RegisterBankInfo {
157157
/// Initialize a ValueMapping with the given parameter.
158158
/// \p BreakDown needs to have a life time at least as long
159159
/// as this instance.
160-
ValueMapping(const PartialMapping *BreakDown, unsigned NumBreakDowns)
160+
constexpr ValueMapping(const PartialMapping *BreakDown,
161+
unsigned NumBreakDowns)
161162
: BreakDown(BreakDown), NumBreakDowns(NumBreakDowns) {}
162163

163164
/// Iterators through the PartialMappings.

0 commit comments

Comments
 (0)