[PATCH] D123642: [clang codegen] Assume arguments of __atomic_* are aligned.
    Eli Friedman via Phabricator via cfe-commits 
    cfe-commits at lists.llvm.org
       
    Fri Apr 15 09:28:22 PDT 2022
    
    
  
efriedma added a comment.
> Have we verified that this is the rule that GCC uses? Is it true even if e.g. the pointer expression is the address of a variable with a known alignment, or if the pointer has an explicitly-aligned type (e.g. with an aligned typedef)?
As far as I can tell, if the type's size is a power of two, and there's an inline atomic sequence available, gcc will use an inline sequence that assumes the address is naturally aligned.  Otherwise, it makes the libcall.  I've tried a variety of ways of writing the operation; alignment doesn't matter at all, no matter what the alignment actually is.
Oddly, `__atomic_is_lock_free`/`__atomic_always_lock_free` do care about the alignment, though.
Repository:
  rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123642/new/
https://reviews.llvm.org/D123642
    
    
More information about the cfe-commits
mailing list