[PATCH] D68141: [Alignment][NFC] Remove AllocaInst::setAlignment(unsigned)

Guillaume Chatelet via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 30 07:22:01 PDT 2019


gchatelet marked an inline comment as done.
gchatelet added inline comments.


================
Comment at: llvm/trunk/lib/Target/AArch64/AArch64StackTagging.cpp:65
 
-static constexpr unsigned kTagGranuleSize = 16;
+static const Align kTagGranuleSize = Align(16);
 
----------------
arichardson wrote:
> Can't the Align ctor be constexpr? Will this result in a `Log2` call at runtime?
The implementation of Log2 is quite complex and depends on the implementation of [[ https://github.com/llvm/llvm-project/blob/02ada9bd2b41d850876a483bede59715e7550c1e/llvm/include/llvm/Support/MathExtras.h#L127 | countLeadingZeros ]].
GCC, clang, ICC can compute the value at compile time but there may be some compiler that can't.
https://godbolt.org/z/ytwWHn

I could solve this issue by introducing a `LogAlign()` function returning an `Align`. This function could be `constexpr`. What do you think? Is it worth the additional complexity?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D68141





More information about the cfe-commits mailing list