Skip to content

Commit

Permalink
Merge remote-tracking branch 'intel/sycl' into loop-opts
Browse files Browse the repository at this point in the history
  • Loading branch information
bader committed Sep 28, 2020
2 parents 700bac4 + 4c6cda3 commit 8d74e41
Show file tree
Hide file tree
Showing 1,190 changed files with 30,842 additions and 15,054 deletions.
1 change: 1 addition & 0 deletions .github/workflows/gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
if: github.repository == 'intel/llvm'
steps:
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ autoconf/autom4te.cache
# VS2017 and VSCode config files.
.vscode
.vs
# pythonenv for github Codespaces
pythonenv*
# clangd index. (".clangd" is a config file now, thus trailing slash)
.clangd/
.cache
Expand Down
6 changes: 3 additions & 3 deletions buildbot/dependency.conf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ ocl_cpu_rt_ver_win=2020.11.8.0.27
# https://github.com/intel/compute-runtime/releases/tag/20.35.17767
ocl_gpu_rt_ver=20.35.17767
# Same GPU driver supports Level Zero and OpenCL:
# https://downloadmirror.intel.com/29817/a08/igfx_win10_100.8673.zip
ocl_gpu_rt_ver_win=27.20.100.8673
# https://downloadmirror.intel.com/29879/a08/igfx_win10_100.8778.zip
ocl_gpu_rt_ver_win=27.20.100.8778
intel_sycl_ver=build
# https://github.com/oneapi-src/oneTBB/releases/download/v2021.1-beta08/oneapi-tbb-2021.1-beta08-lin.tgz
tbb_ver=2021.1.9.636
Expand All @@ -25,7 +25,7 @@ fpga_ver_win=20200811_000006
cpu_driver_lin=2020.11.8.0.27
cpu_driver_win=2020.11.8.0.27
gpu_driver_lin=20.35.17767
gpu_driver_win=27.20.100.8673
gpu_driver_win=27.20.100.8778
fpga_driver_lin=2020.11.8.0.27
fpga_driver_win=2020.11.8.0.27
# NVidia CUDA driver
Expand Down
5 changes: 4 additions & 1 deletion buildbot/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def do_dependency(args):
# fetch and build OpenCL ICD loader
icd_loader_dir = os.path.join(args.obj_dir, "OpenCL-ICD-Loader")
if not os.path.isdir(icd_loader_dir):
clone_cmd = ["git", "clone", "https://github.com/KhronosGroup/OpenCL-ICD-Loader", "OpenCL-ICD-Loader"]
clone_cmd = ["git", "clone",
"https://github.com/KhronosGroup/OpenCL-ICD-Loader",
"OpenCL-ICD-Loader", "-b", "v2020.06.16"]

subprocess.check_call(clone_cmd, cwd=args.obj_dir)
else:
fetch_cmd = ["git", "pull", "--ff", "--ff-only", "origin"]
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void UseAutoCheck::replaceIterators(const DeclStmt *D, ASTContext *Context) {

// Drill down to the as-written initializer.
const Expr *E = (*Construct->arg_begin())->IgnoreParenImpCasts();
if (E != E->IgnoreConversionOperator()) {
if (E != E->IgnoreConversionOperatorSingleStep()) {
// We hit a conversion operator. Early-out now as they imply an implicit
// conversion from a different type. Could also mean an explicit
// conversion from the same type but that's pretty rare.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ std::string compareExpressionToZero(const MatchFinder::MatchResult &Result,

std::string replacementExpression(const MatchFinder::MatchResult &Result,
bool Negated, const Expr *E) {
E = E->ignoreParenBaseCasts();
E = E->IgnoreParenBaseCasts();
if (const auto *EC = dyn_cast<ExprWithCleanups>(E))
E = EC->getSubExpr();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Known limitations

The ``else`` branch is not checked currently for negated condition variable:

.. code-block:: c
bool onFire = isBurning();
if (onFire) {
scream();
Expand Down
5 changes: 3 additions & 2 deletions clang/docs/Block-ABI-Apple.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ High Level
==========

The ABI of ``Blocks`` consist of their layout and the runtime functions required
by the compiler. A ``Block`` consists of a structure of the following form:
by the compiler. A ``Block`` of type ``R (^)(P...)`` consists of a structure of
the following form:

.. code-block:: c
struct Block_literal_1 {
void *isa; // initialized to &_NSConcreteStackBlock or &_NSConcreteGlobalBlock
int flags;
int reserved;
void (*invoke)(void *, ...);
R (*invoke)(struct Block_literal_1 *, P...);
struct Block_descriptor_1 {
unsigned long int reserved; // NULL
unsigned long int size; // sizeof(struct Block_literal_1)
Expand Down
17 changes: 17 additions & 0 deletions clang/docs/ClangFormatStyleOptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,24 @@ the configuration (without a prefix: ``Auto``).
int bbbbbbbbbbbbbbbbbbbbb) {
}

**AttributeMacros** (``std::vector<std::string>``)
A vector of strings that should be interpreted as attributes/qualifiers
instead of identifiers. This can be useful for language extensions or
static analyzer annotations:

.. code-block:: c++

x = (char *__capability)&y;
int function(void) __ununsed;
void only_writes_to_buffer(char *__output buffer);
In the .clang-format configuration file, this can be configured like:

.. code-block:: yaml
AttributeMacros: ['__capability', '__output', '__ununsed']
For example: __capability.

**BinPackArguments** (``bool``)
If ``false``, a function call's arguments will either be all on the
Expand Down
114 changes: 103 additions & 11 deletions clang/docs/ThreadSafetyAnalysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,21 @@ must be held on entry to the function, *and must still be held on exit*.
}


ACQUIRE(...), ACQUIRE_SHARED(...), RELEASE(...), RELEASE_SHARED(...)
--------------------------------------------------------------------
ACQUIRE(...), ACQUIRE_SHARED(...), RELEASE(...), RELEASE_SHARED(...), RELEASE_GENERIC(...)
------------------------------------------------------------------------------------------

*Previously*: ``EXCLUSIVE_LOCK_FUNCTION``, ``SHARED_LOCK_FUNCTION``,
``UNLOCK_FUNCTION``

``ACQUIRE`` is an attribute on functions or methods, which
declares that the function acquires a capability, but does not release it. The
caller must not hold the given capability on entry, and it will hold the
capability on exit. ``ACQUIRE_SHARED`` is similar.
``ACQUIRE`` and ``ACQUIRE_SHARED`` are attributes on functions or methods
declaring that the function acquires a capability, but does not release it.
The given capability must not be held on entry, and will be held on exit
(exclusively for ``ACQUIRE``, shared for ``ACQUIRE_SHARED``).

``RELEASE`` and ``RELEASE_SHARED`` declare that the function releases the given
capability. The caller must hold the capability on entry, and will no longer
hold it on exit. It does not matter whether the given capability is shared or
exclusive.
``RELEASE``, ``RELEASE_SHARED``, and ``RELEASE_GENERIC`` declare that the
function releases the given capability. The capability must be held on entry
(exclusively for ``RELEASE``, shared for ``RELEASE_SHARED``, exclusively or
shared for ``RELEASE_GENERIC``), and will no longer be held on exit.

.. code-block:: c++

Expand Down Expand Up @@ -402,6 +402,13 @@ the destructor. Such classes require special handling because the constructor
and destructor refer to the capability via different names; see the
``MutexLocker`` class in :ref:`mutexheader`, below.

Scoped capabilities are treated as capabilities that are implicitly acquired
on construction and released on destruction. They are associated with
the set of (regular) capabilities named in thread safety attributes on the
constructor. Acquire-type attributes on other member functions are treated as
applying to that set of associated capabilities, while ``RELEASE`` implies that
a function releases all associated capabilities in whatever mode they're held.


TRY_ACQUIRE(<bool>, ...), TRY_ACQUIRE_SHARED(<bool>, ...)
---------------------------------------------------------
Expand All @@ -414,6 +421,26 @@ The first argument must be ``true`` or ``false``, to specify which return value
indicates success, and the remaining arguments are interpreted in the same way
as ``ACQUIRE``. See :ref:`mutexheader`, below, for example uses.

Because the analysis doesn't support conditional locking, a capability is
treated as acquired after the first branch on the return value of a try-acquire
function.

.. code-block:: c++

Mutex mu;
int a GUARDED_BY(mu);

void foo() {
bool success = mu.TryLock();
a = 0; // Warning, mu is not locked.
if (success) {
a = 0; // Ok.
mu.Unlock();
} else {
a = 0; // Warning, mu is not locked.
}
}


ASSERT_CAPABILITY(...) and ASSERT_SHARED_CAPABILITY(...)
--------------------------------------------------------
Expand Down Expand Up @@ -800,6 +827,9 @@ implementation.
#define RELEASE_SHARED(...) \
THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(__VA_ARGS__))

#define RELEASE_GENERIC(...) \
THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(__VA_ARGS__))

#define TRY_ACQUIRE(...) \
THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(__VA_ARGS__))

Expand Down Expand Up @@ -844,6 +874,9 @@ implementation.
// Release/unlock a shared mutex.
void ReaderUnlock() RELEASE_SHARED();

// Generic unlock, can unlock exclusive and shared mutexes.
void GenericUnlock() RELEASE_GENERIC();

// Try to acquire the mutex. Returns true on success, and false on failure.
bool TryLock() TRY_ACQUIRE(true);

Expand All @@ -860,19 +893,78 @@ implementation.
const Mutex& operator!() const { return *this; }
};
// Tag types for selecting a constructor.
struct adopt_lock_t {} inline constexpr adopt_lock = {};
struct defer_lock_t {} inline constexpr defer_lock = {};
struct shared_lock_t {} inline constexpr shared_lock = {};

// MutexLocker is an RAII class that acquires a mutex in its constructor, and
// releases it in its destructor.
class SCOPED_CAPABILITY MutexLocker {
private:
Mutex* mut;
bool locked;

public:
MutexLocker(Mutex *mu) ACQUIRE(mu) : mut(mu) {
// Acquire mu, implicitly acquire *this and associate it with mu.
MutexLocker(Mutex *mu) ACQUIRE(mu) : mut(mu), locked(true) {
mu->Lock();
}
// Assume mu is held, implicitly acquire *this and associate it with mu.
MutexLocker(Mutex *mu, adopt_lock_t) REQUIRES(mu) : mut(mu), locked(true) {}
// Acquire mu in shared mode, implicitly acquire *this and associate it with mu.
MutexLocker(Mutex *mu, shared_lock_t) ACQUIRE_SHARED(mu) : mut(mu), locked(true) {
mu->ReaderLock();
}
// Assume mu is held in shared mode, implicitly acquire *this and associate it with mu.
MutexLocker(Mutex *mu, adopt_lock_t, shared_lock_t) REQUIRES_SHARED(mu)
: mut(mu), locked(true) {}
// Assume mu is not held, implicitly acquire *this and associate it with mu.
MutexLocker(Mutex *mu, defer_lock_t) EXCLUDES(mu) : mut(mu), locked(false) {}
// Release *this and all associated mutexes, if they are still held.
// There is no warning if the scope was already unlocked before.
~MutexLocker() RELEASE() {
if (locked)
mut->GenericUnlock();
}
// Acquire all associated mutexes exclusively.
void Lock() ACQUIRE() {
mut->Lock();
locked = true;
}

// Try to acquire all associated mutexes exclusively.
bool TryLock() TRY_ACQUIRE(true) {
return locked = mut->TryLock();
}

// Acquire all associated mutexes in shared mode.
void ReaderLock() ACQUIRE_SHARED() {
mut->ReaderLock();
locked = true;
}

// Try to acquire all associated mutexes in shared mode.
bool ReaderTryLock() TRY_ACQUIRE_SHARED(true) {
return locked = mut->ReaderTryLock();
}

// Release all associated mutexes. Warn on double unlock.
void Unlock() RELEASE() {
mut->Unlock();
locked = false;
}

// Release all associated mutexes. Warn on double unlock.
void ReaderUnlock() RELEASE() {
mut->ReaderUnlock();
locked = false;
}
};

Expand Down
2 changes: 1 addition & 1 deletion clang/docs/analyzer/checkers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ Check for integer to enumeration casts that could result in undefined values.
void foo() {
TestEnum t = static_cast(-1);
// warn: the value provided to the cast expression is not in
the valid range of values for the enum
// the valid range of values for the enum
.. _alpha-cplusplus-InvalidatedIterator:
Expand Down
2 changes: 1 addition & 1 deletion clang/examples/Attribute/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang)

if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN))
target_link_libraries(Attribute ${cmake_2_8_12_PRIVATE}
target_link_libraries(Attribute PRIVATE
clangAST
clangBasic
clangFrontend
Expand Down
20 changes: 20 additions & 0 deletions clang/include/clang-c/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -2940,6 +2940,26 @@ CINDEX_LINKAGE int clang_getCursorPlatformAvailability(
CINDEX_LINKAGE void
clang_disposeCXPlatformAvailability(CXPlatformAvailability *availability);

/**
* If cursor refers to a variable declaration and it has initializer returns
* cursor referring to the initializer otherwise return null cursor.
*/
CINDEX_LINKAGE CXCursor clang_Cursor_getVarDeclInitializer(CXCursor cursor);

/**
* If cursor refers to a variable declaration that has global storage returns 1.
* If cursor refers to a variable declaration that doesn't have global storage
* returns 0. Otherwise returns -1.
*/
CINDEX_LINKAGE int clang_Cursor_hasVarDeclGlobalStorage(CXCursor cursor);

/**
* If cursor refers to a variable declaration that has external storage
* returns 1. If cursor refers to a variable declaration that doesn't have
* external storage returns 0. Otherwise returns -1.
*/
CINDEX_LINKAGE int clang_Cursor_hasVarDeclExternalStorage(CXCursor cursor);

/**
* Describe the "language" of the entity referred to by a cursor.
*/
Expand Down
Loading

0 comments on commit 8d74e41

Please sign in to comment.