digitalmars.D.ldc - Inlining std.atomic.AtomicFence
- Dan Olson (9/9) Jan 14 2015 In LDC, how do we make std.atomic.atomicFence inline?
- David Nadlinger via digitalmars-d-ldc (18/19) Jan 16 2015 Hi Dan,
- Dan Olson (1/1) Jan 18 2015 Good, nice to know there is a plan to solve this.
- David Nadlinger via digitalmars-d-ldc (4/5) Jan 19 2015 Now we just need somebody to execute it. ;)
- Kagamin (4/9) Jan 20 2015 Wouldn't
- David Nadlinger via digitalmars-d-ldc (8/11) Jan 20 2015 An issue with this is that the signature of llvm_memory_fence does not
In LDC, how do we make std.atomic.atomicFence inline? void atomicFence() nothrow { llvm_memory_fence(); } I was working on fixing a race condition in the unittest for this module and the assembly for the unitest has a nice ARM dmb instructions (arm memory fence). But then I had similar testcode in another module and atomicFence did not inline, even with -Os -inline. Changing atomicFence to a template function does make it inline into a dmb instruction but that changes the core.atomic API I suppose. Is there a better solution? -- Dan
Jan 14 2015
Hi Dan, On Wed, Jan 14, 2015 at 6:08 PM, Dan Olson via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> wrote:In LDC, how do we make std.atomic.atomicFence inline?The short answer: Fix inlining and implement forceinline. Cross-module inlining is not functional at all since the big code emission strategy change. This is a big problem, as it also causes issues like std.array.front not being inlined for template instances that are already available from imported modules (e.g. from Phobos). After this is fixed, we should also implement a forceinline attribute/pragma/… to make sure "single instruction wrappers" such as this are actually inlined even in debug mode. Just applying the LLVM attribute alone obviously won't work for situations where the definition isn't emitted in the first place (such as in your test case). Jernej had a go at the latter in https://github.com/ldc-developers/ldc/issues/561. Might be worth a look. David
Jan 16 2015
Good, nice to know there is a plan to solve this.
Jan 18 2015
On Sun, Jan 18, 2015 at 5:36 PM, Dan Olson via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> wrote:Good, nice to know there is a plan to solve this.Now we just need somebody to execute it. ;) David
Jan 19 2015
On Wednesday, 14 January 2015 at 17:08:13 UTC, Dan Olson wrote:In LDC, how do we make std.atomic.atomicFence inline? void atomicFence() nothrow { llvm_memory_fence(); }Wouldn't alias atomicFence = llvm_memory_fence; do it?
Jan 20 2015
On Tue, Jan 20, 2015 at 9:33 AM, Kagamin via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> wrote:Wouldn't alias atomicFence = llvm_memory_fence; do it?An issue with this is that the signature of llvm_memory_fence does not match atomicFence() (it takes an extra, optional ordering parameter). In this specific case, this discrepancy might be acceptable, but there are also other intrinsics where we need to adapt the arguments and/or return values. David
Jan 20 2015