This is an archive of the discontinued LLVM Phabricator instance.

Add 64-bit MS _Interlocked functions as builtins again
ClosedPublic

Authored by agutowski on Oct 13 2016, 1:27 PM.

Details

Summary

Previously global 64-bit versions of _Interlocked functions broke buildbots on i386, so now I'm adding them as builtins for x86-64 and ARM only (should they be also on AArch64? I had problems with testing it for AArch64, so I left it)

Event Timeline

agutowski updated this revision to Diff 74574.Oct 13 2016, 1:27 PM
agutowski retitled this revision from to Add 64-bit MS _Interlocked functions as builtins again.
agutowski updated this object.
agutowski added reviewers: rnk, hans, majnemer, mstorsjo.
agutowski added a subscriber: cfe-commits.
rnk added inline comments.Oct 13 2016, 1:41 PM
lib/CodeGen/CGBuiltin.cpp
2730

Can you make a helper similar to MakeBinaryAtomicValue for inc/dec and share this code with the 16 and 32-bit atomic increment implementations? You can do something like Builder.CreateBinOp(Inc ? Instruction::Add : Instruction::Sub, ...)

agutowski added inline comments.Oct 13 2016, 1:49 PM
lib/CodeGen/CGBuiltin.cpp
2730

I thought about putting all the _Interlocked intrinsics here. Or do we want all the others to remain target-independent?

rnk added inline comments.Oct 13 2016, 2:20 PM
lib/CodeGen/CGBuiltin.cpp
2730

Sure, having the target-independent builtins call EmitMSVCBuiltinExpr seems reasonable.

agutowski updated this revision to Diff 74586.Oct 13 2016, 2:43 PM

make target-independent Interlocked builtins use EmitMSVCBuiltinExpr

rnk accepted this revision.Oct 13 2016, 3:15 PM
rnk edited edge metadata.

lgtm

This revision is now accepted and ready to land.Oct 13 2016, 3:15 PM
agutowski closed this revision.Oct 13 2016, 3:44 PM
mstorsjo edited edge metadata.Oct 14 2016, 12:38 AM

(should they be also on AArch64? I had problems with testing it for AArch64, so I left it)

Technically, I think they should be on AArch64 as well. But clang/LLVM probably doesn't support AArch64/Windows yet (I guess?), so testing it probably is impossible. When/if support later gets added for that, it's easy to complete these.

AArch64/Windows in general isn't available yet; the Windows 10 SDK contains some arm64 tools, and the Windows 10 SDK and MSVC 2015 headers have got ifdefs using _M_ARM64, but other than that, there's no public version of Visual Studio even having a compiler for it. So until then, and when someone tries to get clang/LLVM to support it, it's probably ok to just ignore it.