[PATCH] D83136: [NFC] Adding the align attribute on Atomic{CmpXchg|RMW}Inst

James Y Knight via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 6 12:55:21 PDT 2020


jyknight accepted this revision.
jyknight added a comment.
This revision is now accepted and ready to land.

It's odd to have CreateAtomicCmpXchg and CreateAtomicRMW not have Align as an argument when the constructors do, but as long as the migration is finished in an upcoming commit, this seems fine as a step on the path.



================
Comment at: llvm/include/llvm/IR/IRBuilder.h:1746
+    return Insert(new AtomicCmpXchgInst(
+        Ptr, Cmp, New, Alignment, SuccessOrdering, FailureOrdering, SSID));
   }
----------------
jfb wrote:
> Are types always rounded to a power of two at this point?
> 
> i.e. what does this do: `struct { char c[3]; };` ?
> 
> Also, I think this is wrong for non-lock-free types. The alignment requirement is lower on those.
This is just encoding the pre-existing behavior -- you cannot currently create an cmpxchg instruction with alignment other than the size of the type.

Right now, you _also_ cannot create a cmpxchg instruction with other than integral or pointer types, which -- in any _current_ llvm backend, afaik -- have non-power-of-2 sizes.

Upcoming changes will plumb through a required alignment argument everywhere, and then we'll be rid of this weird hardcoded special alignment behavior here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83136





More information about the llvm-commits mailing list