This is an archive of the discontinued LLVM Phabricator instance.

[COFF, ARM64] Add _InterlockedAdd intrinsic
ClosedPublic

Authored by mgrang on Oct 2 2018, 4:27 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

mgrang created this revision.Oct 2 2018, 4:27 PM
efriedma added inline comments.
test/CodeGen/ms-intrinsics.c
379 ↗(On Diff #168050)

Missing "add" instruction. _InterlockedAdd is supposed to return the sum, not the original value in memory.

None of this seems to be ARM64 specific - if I read it correctly, this adds the _InterlockedAdd intrinsic for ARM and X64 as well. How come this hasn't been an issue for those targets up until now? Do those targets have any other code somewhere handling it, that might conflict after this patch?

How come this hasn't been an issue for those targets up until now?

MSVC doesn't define _InterlockedAdd for x64.

How come this hasn't been an issue for those targets up until now?

MSVC doesn't define _InterlockedAdd for x64.

Ok - but judging from the context here, this would make clang define it there - which probably isn't desired?

mgrang updated this revision to Diff 168517.Oct 5 2018, 1:19 PM

Limited the intrinsic only for AArch64 and fixed the implementation to return the sum instead of the old value of the Addend. Thanks @efriedma for the pointers.

mgrang updated this revision to Diff 168518.Oct 5 2018, 1:25 PM
efriedma accepted this revision.Oct 5 2018, 1:30 PM

LGTM

This revision is now accepted and ready to land.Oct 5 2018, 1:30 PM
This revision was automatically updated to reflect the committed changes.