[PATCH] D18200: Add __atomic_* lowering to AtomicExpandPass.
James Y Knight via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 15 15:38:14 PDT 2016
jyknight created this revision.
jyknight added subscribers: theraven, rnk, hfinkel, jfb, reames, joerg, llvm-commits.
Herald added subscribers: dsanders, jyknight.
AtomicExpandPass can now lower atomic load, atomic store, atomicrmw, and
cmpxchg instructions to __atomic_* library calls, when the target
doesn't support atomics of a given size.
This is the first step towards moving all atomic lowering from clang
into llvm. When all is done, the behavior of __sync_* builtins,
__atomic_* builtins, and C11 atomics will be unified.
Previously LLVM would pass everything through to the ISelLowering code,
where unsupported atomic instructions would turn into __sync_* library
functions. Because of that, Clang avoids emitting atomic instructions
when this will happen, and emits __atomic_* library functions itself in
It is advantageous to do the lowering to atomic libcalls before ISel
time, because it's important that all atomic instructions for a given
size either lower to __atomic_* libcalls, or don't. No mixing and
At the moment, this code is enabled only for SPARC, as a
demonstration. The next commit will expand support to all of the other
There's also a few minor other changes:
- getInsertFencesForAtomic() is replaced with
shouldInsertFencesForAtomic(), so that the decision can be made
per-instruction. (This will be used in the next patch)
- emitLeadingFence/emitTrailingFence are no longer called when
shouldInsertFencesForAtomic is false, so don't need to check that
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 64728 bytes
Desc: not available
More information about the llvm-commits