[PATCH] D76550: [Attributor] Improve the alignment of the loads

Guillaume Chatelet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 23 01:38:30 PDT 2020


gchatelet added a comment.

If you always deal with defined alignment there is no need to use `MaybeAlign`.
Use `Align` in `createReplacementValues` (it will get rid of the extra if check).

Now, `LoadInst::setAlignment` takes a `MaybeAlign` but `Align` implicitly casts to `MaybeAlign` so you can safely pass in an `Align` (I'll optimize this case by providing `setAlignment` overloads later).

Then if you get raw alignment values that can be `0` but you assume that `0` means `1` use `assumeAligned` <https://github.com/llvm/llvm-project/blob/ccf49b9ef012bab44b1f1322223e8b2e5ca89bad/llvm/include/llvm/Support/Alignment.h#L114>.
Unfortunately the naming in this context is awkward (but that's how the API is supposed to be used) `assumeAligned(AlignAA.getAssumedAlign())`.

It will become better over time when `AlignAA` deals with `Align`/`MaybeAlign` directly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76550





More information about the llvm-commits mailing list