[llvm] b14d344 - [GISel] Make the PartialMapping and ValueMapping constructors constexpr.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Sun Nov 5 12:17:12 PST 2023


Author: Craig Topper
Date: 2023-11-05T12:17:05-08:00
New Revision: b14d3441a67939533df1b10cc456516c85a3386a

URL: https://github.com/llvm/llvm-project/commit/b14d3441a67939533df1b10cc456516c85a3386a
DIFF: https://github.com/llvm/llvm-project/commit/b14d3441a67939533df1b10cc456516c85a3386a.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/RegisterBankInfo.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/RegisterBankInfo.h b/llvm/include/llvm/CodeGen/RegisterBankInfo.h
index 763ef6f32edca32..1ee1f6b6c32ed63 100644
--- a/llvm/include/llvm/CodeGen/RegisterBankInfo.h
+++ b/llvm/include/llvm/CodeGen/RegisterBankInfo.h
@@ -63,8 +63,8 @@ class RegisterBankInfo {
     PartialMapping() = default;
 
     /// Provide a shortcut for quickly building PartialMapping.
-    PartialMapping(unsigned StartIdx, unsigned Length,
-                   const RegisterBank &RegBank)
+    constexpr PartialMapping(unsigned StartIdx, unsigned Length,
+                             const RegisterBank &RegBank)
         : StartIdx(StartIdx), Length(Length), RegBank(&RegBank) {}
 
     /// \return the index of in the original value of the most
@@ -157,7 +157,8 @@ class RegisterBankInfo {
     /// Initialize a ValueMapping with the given parameter.
     /// \p BreakDown needs to have a life time at least as long
     /// as this instance.
-    ValueMapping(const PartialMapping *BreakDown, unsigned NumBreakDowns)
+    constexpr ValueMapping(const PartialMapping *BreakDown,
+                           unsigned NumBreakDowns)
         : BreakDown(BreakDown), NumBreakDowns(NumBreakDowns) {}
 
     /// Iterators through the PartialMappings.


        


More information about the llvm-commits mailing list