[PATCH] D82197: [NFCI] Cleanup range checks in Register/MCRegister

Hubert Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 19 10:52:54 PDT 2020


hubert.reinterpretcast added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/Register.h:36
   // DenseMapInfo<unsigned> uses -1u and -2u.
+  static_assert(sizeof(Reg) >= 4, "Reg isn't large enough to hold full range.");
 
----------------
Please use `numeric_limits`

  - to catch if the type of `Reg` changes to in a way that the size no longer accurately reflects the range, and
  - account for padding bits.


================
Comment at: llvm/include/llvm/MC/MCRegister.h:38
   // DenseMapInfo<unsigned> uses -1u and -2u.
+  static_assert(sizeof(Reg) >= 4, "Reg isn't large enough to hold full range.");
+  static constexpr unsigned NoRegister = 0u;
----------------
Same comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82197/new/

https://reviews.llvm.org/D82197





More information about the llvm-commits mailing list