[PATCH] D118355: Add -mmanual-endbr switch to allow manual selection of control-flow protection

Gabriel F. T. Gomes via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 27 05:48:32 PST 2022


gftg added a comment.

This patch as-is doesn't build. To build it needs another change that I know is wrong, so I'm posting it below to ask for your help:

      [RFC] How to add more bits to the Type class?
  
      After reading https://reviews.llvm.org/D50630, I learned that keeping
      the size of the 'Type' class to a minimum (currently 24 bytes, where 8
      bytes are due to the various Bit Field classes) is desired. However,
      while trying to add a new function attribute (see the precious patches
      in this series), the new bit caused FunctionTypeBitfields to become 4
      bytes larger (previously 8 bytes), which becomes the larger member of
      the Bit Field union. The whole Type class increased in size to 32 bytes
      up from 24 (an 8-byte increase).
  
      This patch does the easy workaround of letting the size of the Type
      class grow to 32 bytes. However, I would like to know how to avoid this
      while still being able to add the new function attribute. I know it's a
      lot to ask, but could somebody teach me how to do this "the proper way"?
  
      Cheers,
      Gabriel
  
  diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
  index 7a00c7d2be8c..4d359d08a522 100644
  --- a/clang/include/clang/AST/Type.h
  +++ b/clang/include/clang/AST/Type.h
  @@ -1824,7 +1824,7 @@ protected:
     Type(TypeClass tc, QualType canon, TypeDependence Dependence)
         : ExtQualsTypeCommonBase(this,
                                  canon.isNull() ? QualType(this_(), 0) : canon) {
  -    static_assert(sizeof(*this) <= 8 + sizeof(ExtQualsTypeCommonBase),
  +    static_assert(sizeof(*this) <= 16 + sizeof(ExtQualsTypeCommonBase),
                     "changing bitfields changed sizeof(Type)!");
       static_assert(alignof(decltype(*this)) % sizeof(void *) == 0,
                     "Insufficient alignment!");

I realize that sending extra diffs here is probably not how this community works, but please bear with me while I get used to it (I'm a newcomer).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118355



More information about the llvm-commits mailing list