If the link clause is used on the declare target directive, the object
should be linked on target or target data directives, not during the
codegen. Patch adds support for this clause.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@328544 91177308-0d34-0410-b5e6-96231b3b80d8
If the generic codegen is enabled and private copy of the original
variable escapes the declaration context, this private copy should be
globalized just like it was the original variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327985 91177308-0d34-0410-b5e6-96231b3b80d8
Added initial codegen for device side of declarations inside `omp
declare target` construct + codegen for implicit `declare target`
functions, which are used in the target regions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327636 91177308-0d34-0410-b5e6-96231b3b80d8
This relands r326965.
There was a null dereference in typo correction that was triggered in
Sema/diagnose_if.c. We are not always in a function scope when doing
typo correction. The fix is to add a null check.
LLVM's optimizer made it hard to find this bug. I wrote it up in a
not-very-well-editted blog post here:
http://qinsb.blogspot.com/2018/03/ub-will-delete-your-null-checks.html
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@327334 91177308-0d34-0410-b5e6-96231b3b80d8
This reverts r326965. It seems to have caused repeating test failures in
clang/test/Sema/diagnose_if.c on some buildbots.
I cannot reproduce the problem, and it's not immediately obvious what
the problem is, so let's revert to green.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326974 91177308-0d34-0410-b5e6-96231b3b80d8
Summary:
Before this patch, Sema pre-allocated a FunctionScopeInfo and kept it in
the first, always present element of the FunctionScopes stack. This
meant that Sema::getCurFunction would return a pointer to this
pre-allocated object when parsing code outside a function body. This is
pretty much always a bug, so this patch moves the pre-allocated object
into a separate unique_ptr. This should make bugs like PR36536 a lot
more obvious.
As you can see from this patch, there were a number of places that
unconditionally assumed they were always called inside a function.
However, there are also many places that null checked the result of
getCurFunction(), so I think this is a reasonable direction.
Reviewers: rsmith
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D44039
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326965 91177308-0d34-0410-b5e6-96231b3b80d8
In CUDA mode all local variables are actually thread
local|threadprivate, not private, and, thus, they cannot be shared
between threads|lanes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326590 91177308-0d34-0410-b5e6-96231b3b80d8
So I wrote a clang-tidy check to lint out redundant `isa`, `cast`, and
`dyn_cast`s for fun. This is a portion of what it found for clang; I
plan to do similar cleanups in LLVM and other subprojects when I find
time.
Because of the volume of changes, I explicitly avoided making any change
that wasn't highly local and obviously correct to me (e.g. we still have
a number of foo(cast<Bar>(baz)) that I didn't touch, since overloading
is a thing and the cast<Bar> did actually change the type -- just up the
class hierarchy).
I also tried to leave the types we were cast<>ing to somewhere nearby,
in cases where it wasn't locally obvious what we were dealing with
before.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326416 91177308-0d34-0410-b5e6-96231b3b80d8
If several member expressions are mapped and they reference the same
address as a base, but access different members, this must be allowed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326212 91177308-0d34-0410-b5e6-96231b3b80d8
constructs.
The compiler may emit some extra warnings for functions, that are
implicit specialization of the templates, declared in the target region.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325391 91177308-0d34-0410-b5e6-96231b3b80d8
Compiler erroneously returned wrong data-sharing attributes for the
constant variables if they have explictly specified attributes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325373 91177308-0d34-0410-b5e6-96231b3b80d8
Removed more empty SourceLocations() from the OpenMP code and replaced
with the correct locations for better debug info emission.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@323232 91177308-0d34-0410-b5e6-96231b3b80d8
parallel for simd` directives.
Added codegen for `depend` clauses on `#pragma omp target teams
distribute parallel for simd` directives.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322587 91177308-0d34-0410-b5e6-96231b3b80d8
simd`.
Added host codegen + codegen for devices with default codegen for
`#pragma omp target teams distribute parallel for simd` directive.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322515 91177308-0d34-0410-b5e6-96231b3b80d8
Patch fixes incorrect capturing of the expressions in clauses with
expressions that must be captured for the combined constructs. Incorrect
capturing may lead to compiler crash during codegen phase.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321820 91177308-0d34-0410-b5e6-96231b3b80d8
If the clause is applied to the combined construct and has captured
expression, try to capture this expression by value rather than by
reference.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@321386 91177308-0d34-0410-b5e6-96231b3b80d8
Adding the new enumerator forced a bunch more changes into this patch than I
would have liked. The -Wtautological-compare warning was extended to properly
check the new comparison operator, clang-format needed updating because it uses
precedence levels as weights for determining where to break lines (and several
operators increased their precedence levels with this change), thread-safety
analysis needed changes to build its own IL properly for the new operator.
All "real" semantic checking for this operator has been deferred to a future
patch. For now, we use the relational comparison rules and arbitrarily give
the builtin form of the operator a return type of 'void'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320707 91177308-0d34-0410-b5e6-96231b3b80d8
OpenMP 5.0 added support for `reduction` clause in target-based
directives. Patch adds this support to clang.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320596 91177308-0d34-0410-b5e6-96231b3b80d8
This patch is to add diagnose when a function name is
specified on the link clause. According to the OpenMP
spec, only the list items that exclude the function
name are allowed on the link clause.
Differential Revision: https://reviews.llvm.org/D40968
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320521 91177308-0d34-0410-b5e6-96231b3b80d8
If the error is generated during analysis of implicitly or explicitly
mapped variables, it may cause compiler crash because of incorrect
analysis.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319774 91177308-0d34-0410-b5e6-96231b3b80d8
distribute directives.
OpenMP standard does not allow to mark the variables as firstprivate and lastprivate at the same time in distribute-based directives. Patch fixes this problem.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319560 91177308-0d34-0410-b5e6-96231b3b80d8
Clang asserts on undeclared variables on the to or link clause in the declare
target directive. The patch is to properly diagnose the error.
// foo1 and foo2 are not declared
#pragma omp declare target to(foo1)
#pragma omp declare target link(foo2)
Differential Revision: https://reviews.llvm.org/D40588
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@319458 91177308-0d34-0410-b5e6-96231b3b80d8