[PATCH] D152790: [ARM] Fix codegen of unaligned volatile load/store of i64

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 15 13:56:07 PDT 2023


efriedma added a comment.

Spent a bit of time digging in the armv7 reference manual.  Apparently on armv7, it should always be fine to use ldrd for word alignment.  On armv5, as you've noted, it's "UNPREDICTABLE".  For armv6, you can switch between armv5 semantics and armv7 semantics.  (sections `D12.3.1` and `D15.3.1`.)  On v6 targets, if allowsUnalignedMem() is true, we can safely assume we're using v7 semantics; if we're in strict alignment mode, I don't think we want to make any assumptions.  (We could theoretically make it a flag specified by the user, but that seems like overkill.)

Note that we currently assume the frontend will set the "+strict-align" target attribute if we're compiling for v4 or v5, so compiling for `-mtriple=armv5e-arm-none-eabi` without also adding `-mattr=+strict-align` will produce weird results: we assume unaligned accesses work, but they clearly won't.  This is probably a bug; the backend should do something more reasonable by default on v4/v5 targets.

Given that, I guess what we want is actually something like `Align(Subtarget->hasV7Ops() || Subtarget->allowsUnalignedMem() ? 4 : 8)`.  Maybe wrap that up in a helper and stick it in ARMSubtarget.h, so we can use it for ARMLoadStoreOptimizer in a followup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152790



More information about the llvm-commits mailing list