This is an archive of the discontinued LLVM Phabricator instance.

Add bunch of _Interlocked builtins
ClosedPublic

Authored by agutowski on Sep 1 2016, 1:01 PM.

Diff Detail

Event Timeline

agutowski updated this revision to Diff 70054.Sep 1 2016, 1:01 PM
agutowski retitled this revision from to Add bunch of _Interlocked builtins.
agutowski updated this object.
agutowski added reviewers: rnk, compnerd, thakis.
agutowski added a subscriber: cfe-commits.
rnk added a reviewer: majnemer.Sep 7 2016, 9:49 AM
rnk edited edge metadata.Sep 7 2016, 9:56 AM

Looks good to me. David, do you remember any subtleties here? I seem to recall there were some bugs in our intrin.h implementations, or inconsistencies between us and MSVC.

test/CodeGen/ms-intrinsics.c
297

I think we should make these increments and decrements non-volatile. I'd like us to be able to optimize this kind of code to return 2:

int f() {
  int x = 0;
  _InterlockedIncrement(&x);
  _InterlockedIncrement(&x);
 return x; // always 2
}
agutowski updated this revision to Diff 70572.Sep 7 2016, 11:21 AM
agutowski edited edge metadata.

Mark _InterlockedIncrement and _InterlockedDecrement as non-volatile

agutowski marked an inline comment as done.Sep 7 2016, 11:23 AM
majnemer edited edge metadata.Sep 7 2016, 12:16 PM
In D24153#535992, @rnk wrote:

Looks good to me. David, do you remember any subtleties here? I seem to recall there were some bugs in our intrin.h implementations, or inconsistencies between us and MSVC.

I can't seem to recall anything major. Our _ReadBarrier and _WriteBarrier simply map to _ReadWriteBarrier. Our __faststorefence is just a normal fence instead of an interlocked operation.

rnk accepted this revision.Sep 13 2016, 11:37 AM
rnk edited edge metadata.

lgtm Sorry, I lost track of this.

This revision is now accepted and ready to land.Sep 13 2016, 11:37 AM
This revision was automatically updated to reflect the committed changes.