Hi, After some hacking and patching, I think I now have the emission of libcalls for C11 atomics working completely. Patch (please refresh):
http://80386.nl/pub/clang-atomic-hax.txt So it seems Clang only had support for the generic libcalls, which take a size, but not the optimized calls for the default sizes. As we only have optimized calls for the atomic_fetch_* operations, we do need to add support for optimized calls to make this actually useful. Explanation of the patch: - Instead of explicitly whitelisting certain sizes for the atomic_fetch_* calls, I thought it would be sane to just assume they are always there. In case our data types grow, we only need to update libcompiler-rt, not the actual compiler source. - For the other atomic ops, always use the optimized versions if size is {1,2,4,8}, but not 16. libcompiler-rt does not provide support for 16-byte types yet, so we'd better refrain from using that one for now. - As the operands to the fetch ops are always passed on throughout the code by reference -- not by value -- and I don't want to make the code more ugly, do a load of the value before passing it in as an argument (see AddDirectArgument()). - Change the E->isCmpXChg() check to !RetTy->isVoidType(). In other words: if a libcall has a non-void return type, let's assume that should be the return value of the libcall. - While there, extend the unit tests. In addition to testing __atomic_load(), also test __atomic_store(), to verify that AddDirectArgument() did its job. Also add the ARM backend, so we can test the case where all the atomics eventually do libcalls. Thoughts? Comments? Thanks, -- Ed Schouten <[email protected]> _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
