Commit Graph

32 Commits

Author SHA1 Message Date
Hal Finkel d2208b59cf Add __sync_fetch_and_nand (again)
Prior to GCC 4.4, __sync_fetch_and_nand was implemented as:

  { tmp = *ptr; *ptr = ~tmp & value; return tmp; }

but this was changed in GCC 4.4 to be:

  { tmp = *ptr; *ptr = ~(tmp & value); return tmp; }

in response to this change, support for sync_fetch_and_nand (and
sync_nand_and_fetch) was removed in r99522 in order to avoid miscompiling code
depending on the old semantics. However, at this point:

  1. Many years have passed, and the amount of code relying on the old
     semantics is likely smaller.

  2. Through the work of many contributors, all LLVM backends have been updated
     such that "atomicrmw nand" provides the newer GCC 4.4+ semantics (this process
     was complete July of 2014 (added to the release notes in r212635).

  3. The lack of this intrinsic is now a needless impediment to porting codes
     from GCC to Clang (I've now seen several examples of this).

It is true, however, that we still set GNUC_MINOR to 2 (corresponding to GCC
4.2). To compensate for this, and to address the original concern regarding
code relying on the old semantics, I've added a warning that specifically
details the fact that the semantics have changed and that we provide the newer
semantics.

Fixes PR8842.

llvm-svn: 218905
2014-10-02 20:53:50 +00:00
Tim Northover b49b04bbe0 IR-change: cmpxchg operations now return { iN, i1 }.
This is a minimal fix for clang. I'll soon add support for generating
weak variants when requested, but that's not really necessary for the
LLVM change in isolation.

llvm-svn: 210907
2014-06-13 14:24:59 +00:00
Eli Friedman fefe0d07ea Don't try to create "store atomic" instructions of non-integer types; they aren't supported at the moment. PR12040.
llvm-svn: 152891
2012-03-16 01:48:04 +00:00
Eli Friedman 84d2812111 Re-commit r139643.
Make clang use Acquire loads and Release stores where necessary.

llvm-svn: 139650
2011-09-13 22:21:56 +00:00
Eli Friedman acca089617 Revert r139643 while I look into it; it's breaking selfhost.
llvm-svn: 139648
2011-09-13 22:08:16 +00:00
Eli Friedman f92b2e0714 Make clang use Acquire loads and Release stores where necessary.
llvm-svn: 139643
2011-09-13 21:31:32 +00:00
Eli Friedman e9f8113ec4 Switch clang over to using fence/atomicrmw/cmpxchg instead of the intrinsics (which will go away). LLVM CodeGen does almost exactly the same thing with these and the old intrinsics, so I'm reasonably confident this will not break anything.
There are still a few issues which need to be resolved with code generation for atomic load and store, so I'm not converting the places which need those for now.

I'm not entirely sure what to do about __builtin_llvm_memory_barrier: the fence instruction doesn't expose all the possibilities which can be expressed by __builtin_llvm_memory_barrier.  I would appreciate hearing from anyone who is using this intrinsic.

llvm-svn: 139216
2011-09-07 01:41:24 +00:00
Eli Friedman 729ed799c7 Update clang tests for r137527.
llvm-svn: 137535
2011-08-12 23:33:52 +00:00
Chris Lattner 9cb59fa834 add a __sync_swap builtin to fill out the rest of the __sync builtins.
Patch by Dave Zarzycki!

llvm-svn: 129189
2011-04-09 03:57:26 +00:00
John McCall 3a7f6926d1 Restore r117403 (fixing IR gen for bool atomics), this time being less
aggressive about the form we expect bools to be in.  I don't really have
time to fix all the sources right now.

llvm-svn: 117486
2010-10-27 20:58:56 +00:00
Rafael Espindola 9d798a07e4 Revert r117403 as it caused PR8480.
llvm-svn: 117456
2010-10-27 17:13:49 +00:00
John McCall 6bde954f47 Extract procedures to do scalar-to-memory and memory-to-scalar conversions
in IR gen, and use those to fix a correctness issue with bool atomic
intrinsics.  rdar://problem/8461234

llvm-svn: 117403
2010-10-26 22:09:15 +00:00
Chris Lattner b2f659b7a0 fix the rest of rdar://8461279 - clang miscompiles address-space qualified atomics
llvm-svn: 114503
2010-09-21 23:40:48 +00:00
Chris Lattner c9066d3072 same bug as before, this time with __sync_val_compare_and_swap.
llvm-svn: 114502
2010-09-21 23:35:30 +00:00
Chris Lattner 7cf46bfda0 fix __sync_bool_compare_and_swap to work with address-space qualified types.
llvm-svn: 114498
2010-09-21 23:24:52 +00:00
Chris Lattner 65dce5eeee filecheckize.
llvm-svn: 114497
2010-09-21 23:22:41 +00:00
Chandler Carruth 3973af797a Fix a goof in my previous patch -- not all of the builtins return a value, some
fixed return types.

llvm-svn: 108657
2010-07-18 20:54:12 +00:00
Chandler Carruth bc8cab16c5 Improve the representation of the atomic builtins in a few ways. First, we make
their call expressions synthetically have the "deduced" types based on their
first argument. We only insert conversions in the AST for arguments whose
values require conversion to match the value type expected. This keeps PR7600
closed by maintaining the return type, but avoids assertions due to unexpected
implicit casts making the type unsigned (test case added from Daniel).

The magic is moved into the codegen for the atomic builtin which inserts the
casts as needed at the IR level to raise the type to an integer suitable for
the LLVM intrinsic. This shouldn't cause any real change in functionality, but
now we can make the builtin be more truly polymorphic.

llvm-svn: 108638
2010-07-18 07:23:17 +00:00
Daniel Dunbar 3f540c0d7d Remove support for nand atomic builtins. They are inconsistently implemented in
gcc, and the common expectation seems to be that they are unused. If and when
someone cares we can add them back with well documented demantics.

llvm-svn: 99522
2010-03-25 17:13:09 +00:00
Daniel Dunbar 4ff562d557 IRgen: Wrap atomic intrinsics with memory barriers, to ensure we honor the semantics.
- This should be conservatively correct, we eventually should have target hooks for platforms that are less strict.

llvm-svn: 99050
2010-03-20 07:04:11 +00:00
Daniel Dunbar 8fbe78f6fc Update tests to use %clang_cc1 instead of 'clang-cc' or 'clang -cc1'.
- This is designed to make it obvious that %clang_cc1 is a "test variable"
   which is substituted. It is '%clang_cc1' instead of '%clang -cc1' because it
   can be useful to redefine what gets run as 'clang -cc1' (for example, to set
   a default target).

llvm-svn: 91446
2009-12-15 20:14:24 +00:00
Daniel Dunbar 8b57697954 Eliminate &&s in tests.
- 'for i in $(find . -type f); do sed -e 's#\(RUN:.*[^ ]\) *&& *$#\1#g' $i | FileUpdate $i; done', for the curious.

llvm-svn: 86430
2009-11-08 01:45:36 +00:00
Daniel Dunbar 16f422ec86 Fix a use-of-undefined, IRgen expects the RValue for "void" to be a scalar RValue.
llvm-svn: 72504
2009-05-27 23:45:33 +00:00
Chris Lattner afde259240 implement __sync_synchronize and __sync_lock_release,
rdar://6880573

llvm-svn: 71637
2009-05-13 04:46:13 +00:00
Chris Lattner da38fda583 force a target triple so that the right greppable output happens.
llvm-svn: 71361
2009-05-09 17:36:58 +00:00
Chris Lattner 5b9241b2a6 Fix the atomics sema code to convert operands to the argument types
of the underlying _N builtin, not the the type of the pointee of the
actual type.  This ensures that atomics involving pointers end up
using the correct integer type when they are resolved, avoiding
aborts in codegen.

llvm-svn: 71218
2009-05-08 15:36:58 +00:00
Chris Lattner dc04654697 reimplement __sync_* builtins to be variadic and to follow the same
semantic rules that gcc and icc use.  This implements the variadic
and concrete versions as builtins and has sema do the 
disambiguation.  There are probably a bunch of details to finish up
but this seems like a large monotonic step forward :)

llvm-svn: 71212
2009-05-08 06:58:22 +00:00
Daniel Dunbar 4fab57ddea Implement __sync_{add,sub,and,or,xor}_and_fetch and
__sync_bool_compare_and_swap.
 - <rdar://problem/6762223> [sema/irgen] support
   __sync_bool_compare_and_swap and __sync_add_and_fetch

llvm-svn: 68482
2009-04-07 00:55:51 +00:00
Daniel Dunbar a45cf5b6b0 Rename clang to clang-cc.
Tests and drivers updated, still need to shuffle dirs.

llvm-svn: 67602
2009-03-24 02:24:46 +00:00
Chris Lattner 64d8d074a8 fix this testcase after Mon Ping's intrinsic rename.
llvm-svn: 52754
2008-06-26 04:06:27 +00:00
Argyrios Kyrtzidis 351763e156 Multiple tests in a single test file must be linked with '&&'.
Otherwise, failing tests other than the last one will not be reported.

llvm-svn: 52231
2008-06-12 12:40:02 +00:00
Mon P Wang b84407d6ec Added support to generate some atomic operators (add, sub, and, or etc..)
llvm-svn: 50919
2008-05-09 22:40:52 +00:00