[llvm-commits] [compiler-rt] r171948 - in /compiler-rt/trunk/lib/ubsan: lit_tests/Misc/deduplication.cpp ubsan_handlers.cc ubsan_handlers_cxx.cc ubsan_value.h

Meador Inge meadori at codesourcery.com
Tue Jan 8 21:33:48 PST 2013


On Jan 8, 2013, at 9:40 PM, Will Dietz wrote:

> 
> +#ifdef __ATOMIC_RELAXED
> +    // Use weaker ordering if available (relaxed/monotonic)
> +    u32 OldColumn = __atomic_exchange_n(&Column, ~u32(0), __ATOMIC_RELAXED);
> +#else
> +    // Otherwise, do a TAS which has acquire semantics, stronger than needed.
> +    u32 OldColumn = __sync_lock_test_and_set(&Column, ~u32(0));
> +#endif
> +    return SourceLocation(Filename, Line, OldColumn);

What toolchains and what versions of those toolchains are these atomic
builtins expected to be available?  The system clang on my OS X 10.7.5
does *not* have these builtins and I get a build break of the form
when trying to build now:

   $ clang --version
   Apple clang version 4.1 (tags/Apple/clang-421.11.65) (based on LLVM 3.1svn)
   Target: x86_64-apple-darwin11.4.2
   Thread model: posix

   …

   error: 
      use of undeclared identifier '__atomic_exchange_n'
    u32 OldColumn = __atomic_exchange_n(&Column, ~u32(0), __ATOMIC_RELAXED);

Looks like many of the atomic builtins were added to Clang last April [1].
I am not sure if they are OK to use in the LLVM code base or not.

[1] http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120409/056079.html

--
Meador Inge
CodeSourcery / Mentor Embedded
http://www.mentor.com/embedded-software





More information about the llvm-commits mailing list