[PATCH] D39946: Relax unaligned access assertion when type is byte aligned

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 13:58:23 PST 2017


efriedma added a comment.

> However, that makes the additional assumption that targets can handle atomic loads with an alignment that is the same as the ABI alignment for that type.

This is not a safe assumption.  For example, 32-bit x86 supports atomic 64-bit loads with native alignment, but the ABI alignment of i64 is only 32 bits.  (It might be technically possible to synthesize an unaligned atomic load on x86, but it's not something we try to do.)



================
Comment at: include/llvm/IR/DataLayout.h:429
+  bool isAligned(Type *Ty) const {
+    return getABITypeAlignment(Ty) > 1;
+  }
----------------
This helper is more likely to be confusing than actually helpful.


================
Comment at: lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:4150
+      I.getAlignment() < VT.getSizeInBits() / 8)
     report_fatal_error("Cannot generate unaligned atomic load");
 
----------------
I would prefer to have a target hook here, so we don't end up miscompiling or generating some obscure instruction selection failure for a target that isn't expecting this.


https://reviews.llvm.org/D39946





More information about the llvm-commits mailing list