Skip to content

Commit 772cb8a

Browse files
committed
Merge remote-tracking branch 'remote/sycl' into stream-class
2 parents 84dc696 + 7d5ee05 commit 772cb8a

File tree

1,505 files changed

+55659
-138881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,505 files changed

+55659
-138881
lines changed

SECURITY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Reporting LLVM Security Issues
2+
3+
To report security issues in LLVM, please follow the steps outlined on the
4+
[LLVM Security Group](https://llvm.org/docs/Security.html#how-to-report-a-security-issue)
5+
page.

clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
446446
case DiagnosticsEngine::Warning:
447447
CheckName = "clang-diagnostic-warning";
448448
break;
449+
case DiagnosticsEngine::Remark:
450+
CheckName = "clang-diagnostic-remark";
451+
break;
449452
default:
450453
CheckName = "clang-diagnostic-unknown";
451454
break;
@@ -460,7 +463,10 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
460463
Level = ClangTidyError::Error;
461464
LastErrorRelatesToUserCode = true;
462465
LastErrorPassesLineFilter = true;
466+
} else if (DiagLevel == DiagnosticsEngine::Remark) {
467+
Level = ClangTidyError::Remark;
463468
}
469+
464470
bool IsWarningAsError = DiagLevel == DiagnosticsEngine::Warning &&
465471
Context.treatAsError(CheckName);
466472
Errors.emplace_back(CheckName, Level, Context.getCurrentBuildDirectory(),

clang-tools-extra/clang-tidy/modernize/RawStringLiteralCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ bool containsEscapedCharacters(const MatchFinder::MatchResult &Result,
5656
*Result.SourceManager, Result.Context->getLangOpts());
5757
StringRef Text = Lexer::getSourceText(CharRange, *Result.SourceManager,
5858
Result.Context->getLangOpts());
59-
if (isRawStringLiteral(Text))
59+
if (Text.empty() || isRawStringLiteral(Text))
6060
return false;
6161

6262
return containsEscapes(Text, R"('\"?x01)");
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// A
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module A { header "A.h" }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: rm -rf %t
2+
// RUN: cp -r %S/Inputs/remarks %t
3+
// RUN: cp %s %t/t.cpp
4+
5+
// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-module-import' t.cpp -- \
6+
// RUN: -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/cache \
7+
// RUN: -fsyntax-only \
8+
// RUN: -I%S/Inputs/remarks \
9+
// RUN: -working-directory=%t \
10+
// RUN: -Rmodule-build -Rmodule-import t.cpp 2>&1 |\
11+
// RUN: FileCheck %s -implicit-check-not "remark:"
12+
13+
#include "A.h"
14+
// CHECK: remark: importing module 'A' from {{.*}} [clang-diagnostic-module-import]
15+

clang/docs/LanguageExtensions.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,6 +1741,34 @@ OpenCL Features
17411741
17421742
Clang supports internal OpenCL extensions documented below.
17431743
1744+
``__cl_clang_bitfields``
1745+
--------------------------------
1746+
1747+
With this extension it is possible to enable bitfields in structs
1748+
or unions using the OpenCL extension pragma mechanism detailed in
1749+
`the OpenCL Extension Specification, section 1.2
1750+
<https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_Ext.html#extensions-overview>`_.
1751+
1752+
Use of bitfields in OpenCL kernels can result in reduced portability as struct
1753+
layout is not guaranteed to be consistent when compiled by different compilers.
1754+
If structs with bitfields are used as kernel function parameters, it can result
1755+
in incorrect functionality when the layout is different between the host and
1756+
device code.
1757+
1758+
**Example of Use**:
1759+
1760+
.. code-block:: c++
1761+
1762+
#pragma OPENCL EXTENSION __cl_clang_bitfields : enable
1763+
struct with_bitfield {
1764+
unsigned int i : 5; // compiled - no diagnostic generated
1765+
};
1766+
1767+
#pragma OPENCL EXTENSION __cl_clang_bitfields : disable
1768+
struct without_bitfield {
1769+
unsigned int i : 5; // error - bitfields are not supported
1770+
};
1771+
17441772
``__cl_clang_function_pointers``
17451773
--------------------------------
17461774

clang/docs/OpenCLSupport.rst

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,25 @@ Missing features or with limited support
339339

340340
.. _opencl_300:
341341

342-
OpenCL 3.0 Implementation Status
343-
================================
342+
OpenCL C 3.0 Usage
343+
==================
344+
345+
OpenCL C 3.0 language standard makes most OpenCL C 2.0 features optional. Optional
346+
functionality in OpenCL C 3.0 is indicated with the presence of feature-test macros
347+
(list of feature-test macros is `here <https://www.khronos.org/registry/OpenCL/specs/3.0-unified/html/OpenCL_C.html#features>`_).
348+
Command-line flag :ref:`-cl-ext <opencl_cl_ext>` can be used to override features supported by a target.
349+
350+
For cases when there is an associated extension for a specific feature (fp64 and 3d image writes)
351+
user should specify both (extension and feature) in command-line flag:
352+
353+
.. code-block:: console
354+
355+
$ clang -cc1 -cl-std=CL3.0 -cl-ext=+cl_khr_fp64,+__opencl_c_fp64 ...
356+
$ clang -cc1 -cl-std=CL3.0 -cl-ext=-cl_khr_fp64,-__opencl_c_fp64 ...
357+
358+
359+
OpenCL C 3.0 Implementation Status
360+
----------------------------------
344361

345362
The following table provides an overview of features in OpenCL C 3.0 and their
346363
implementation status.
@@ -354,7 +371,7 @@ implementation status.
354371
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
355372
| Predefined macros | Feature macros | :good:`done` | https://reviews.llvm.org/D95776 |
356373
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
357-
| Feature optionality | Generic address space | :none:`unclaimed` | |
374+
| Feature optionality | Generic address space | :none:`worked on` | https://reviews.llvm.org/D95778 (partial frontend) |
358375
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
359376
| Feature optionality | Builtin function overloads with generic address space | :part:`worked on` | https://reviews.llvm.org/D92004 |
360377
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
@@ -372,6 +389,8 @@ implementation status.
372389
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
373390
| Feature optionality | Work group collective functions | :part:`worked on` | https://reviews.llvm.org/D92004 |
374391
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
392+
| Feature optionality | Image types | :part:`unclaimed` | |
393+
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
375394
| New functionality | RGBA vector components | :good:`done` | https://reviews.llvm.org/D99969 |
376395
+------------------------------+--------------------------------------------------------------+----------------------+---------------------------------------------------------------------------+
377396
| New functionality | Subgroup functions | :part:`worked on` | https://reviews.llvm.org/D92004 |

clang/include/clang/AST/DeclCXX.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,15 +1852,17 @@ class CXXDeductionGuideDecl : public FunctionDecl {
18521852
CXXDeductionGuideDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
18531853
ExplicitSpecifier ES,
18541854
const DeclarationNameInfo &NameInfo, QualType T,
1855-
TypeSourceInfo *TInfo, SourceLocation EndLocation)
1855+
TypeSourceInfo *TInfo, SourceLocation EndLocation,
1856+
CXXConstructorDecl *Ctor)
18561857
: FunctionDecl(CXXDeductionGuide, C, DC, StartLoc, NameInfo, T, TInfo,
18571858
SC_None, false, ConstexprSpecKind::Unspecified),
1858-
ExplicitSpec(ES) {
1859+
Ctor(Ctor), ExplicitSpec(ES) {
18591860
if (EndLocation.isValid())
18601861
setRangeEnd(EndLocation);
18611862
setIsCopyDeductionCandidate(false);
18621863
}
18631864

1865+
CXXConstructorDecl *Ctor;
18641866
ExplicitSpecifier ExplicitSpec;
18651867
void setExplicitSpecifier(ExplicitSpecifier ES) { ExplicitSpec = ES; }
18661868

@@ -1871,7 +1873,8 @@ class CXXDeductionGuideDecl : public FunctionDecl {
18711873
static CXXDeductionGuideDecl *
18721874
Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
18731875
ExplicitSpecifier ES, const DeclarationNameInfo &NameInfo, QualType T,
1874-
TypeSourceInfo *TInfo, SourceLocation EndLocation);
1876+
TypeSourceInfo *TInfo, SourceLocation EndLocation,
1877+
CXXConstructorDecl *Ctor = nullptr);
18751878

18761879
static CXXDeductionGuideDecl *CreateDeserialized(ASTContext &C, unsigned ID);
18771880

@@ -1886,6 +1889,12 @@ class CXXDeductionGuideDecl : public FunctionDecl {
18861889
return getDeclName().getCXXDeductionGuideTemplate();
18871890
}
18881891

1892+
/// Get the constructor from which this deduction guide was generated, if
1893+
/// this is an implicit deduction guide.
1894+
CXXConstructorDecl *getCorrespondingConstructor() const {
1895+
return Ctor;
1896+
}
1897+
18891898
void setIsCopyDeductionCandidate(bool isCDC = true) {
18901899
FunctionDeclBits.IsCopyDeductionCandidate = isCDC;
18911900
}
@@ -3818,7 +3827,7 @@ class StaticAssertDecl : public Decl {
38183827
/// DecompositionDecl of type 'int (&)[3]'.
38193828
class BindingDecl : public ValueDecl {
38203829
/// The declaration that this binding binds to part of.
3821-
LazyDeclPtr Decomp;
3830+
ValueDecl *Decomp;
38223831
/// The binding represented by this declaration. References to this
38233832
/// declaration are effectively equivalent to this expression (except
38243833
/// that it is only evaluated once at the point of declaration of the
@@ -3844,7 +3853,7 @@ class BindingDecl : public ValueDecl {
38443853

38453854
/// Get the decomposition declaration that this binding represents a
38463855
/// decomposition of.
3847-
ValueDecl *getDecomposedDecl() const;
3856+
ValueDecl *getDecomposedDecl() const { return Decomp; }
38483857

38493858
/// Get the variable (if any) that holds the value of evaluating the binding.
38503859
/// Only present for user-defined bindings for tuple-like types.

clang/include/clang/Basic/DiagnosticCommonKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,4 +364,7 @@ def warn_poison_system_directories : Warning <
364364
def warn_opencl_unsupported_core_feature : Warning<
365365
"%0 is a core feature in %select{OpenCL C|C++ for OpenCL}1 version %2 but not supported on this target">,
366366
InGroup<OpenCLCoreFeaturesDiagGroup>, DefaultIgnore;
367+
368+
def err_opencl_extension_and_feature_differs : Error<
369+
"options %0 and %1 are set to different values">;
367370
}

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ def warn_float_underflow : Warning<
118118
"magnitude of floating-point constant too small for type %0; minimum is %1">,
119119
InGroup<LiteralRange>;
120120
def warn_double_const_requires_fp64 : Warning<
121-
"double precision constant requires cl_khr_fp64, casting to single precision">;
121+
"double precision constant requires %select{cl_khr_fp64|cl_khr_fp64 and __opencl_c_fp64}0, "
122+
"casting to single precision">;
122123
def err_half_const_requires_fp16 : Error<
123124
"half precision constant requires cl_khr_fp16">;
124125

@@ -3676,13 +3677,13 @@ def warn_fun_requires_lock_precise :
36763677
def note_found_mutex_near_match : Note<"found near match '%0'">;
36773678

36783679
// Verbose thread safety warnings
3679-
def warn_thread_safety_verbose : Warning<"Thread safety verbose warning.">,
3680+
def warn_thread_safety_verbose : Warning<"thread safety verbose warning">,
36803681
InGroup<ThreadSafetyVerbose>, DefaultIgnore;
3681-
def note_thread_warning_in_fun : Note<"Thread warning in function %0">;
3682-
def note_guarded_by_declared_here : Note<"Guarded_by declared here.">;
3682+
def note_thread_warning_in_fun : Note<"thread warning in function %0">;
3683+
def note_guarded_by_declared_here : Note<"guarded_by declared here">;
36833684

36843685
// Dummy warning that will trigger "beta" warnings from the analysis if enabled.
3685-
def warn_thread_safety_beta : Warning<"Thread safety beta warning.">,
3686+
def warn_thread_safety_beta : Warning<"thread safety beta warning">,
36863687
InGroup<ThreadSafetyBeta>, DefaultIgnore;
36873688

36883689
// Consumed warnings
@@ -10071,6 +10072,8 @@ def err_opencl_requires_extension : Error<
1007110072
def ext_opencl_double_without_pragma : Extension<
1007210073
"Clang permits use of type 'double' regardless pragma if 'cl_khr_fp64' is"
1007310074
" supported">;
10075+
def err_opencl_double_requires_extension : Error<
10076+
"use of type 'double' requires %select{cl_khr_fp64|cl_khr_fp64 and __opencl_c_fp64}0 support">;
1007410077
def warn_opencl_generic_address_space_arg : Warning<
1007510078
"passing non-generic address space pointer to %0"
1007610079
" may cause dynamic conversion affecting performance">,

clang/include/clang/Basic/OpenCLExtensions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ OPENCL_EXTENSION(cl_clang_storage_class_specifiers, true, 100)
8888
OPENCL_EXTENSION(__cl_clang_function_pointers, true, 100)
8989
OPENCL_EXTENSION(__cl_clang_variadic_functions, true, 100)
9090
OPENCL_EXTENSION(__cl_clang_non_portable_kernel_param_types, true, 100)
91+
OPENCL_EXTENSION(__cl_clang_bitfields, true, 100)
9192

9293
// AMD OpenCL extensions
9394
OPENCL_EXTENSION(cl_amd_media_ops, true, 100)

clang/include/clang/Basic/TargetInfo.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,6 +1091,12 @@ class TargetInfo : public virtual TransferrableTargetInfo,
10911091
return std::string(1, *Constraint);
10921092
}
10931093

1094+
/// Replace some escaped characters with another string based on
1095+
/// target-specific rules
1096+
virtual llvm::Optional<std::string> handleAsmEscapedChar(char C) const {
1097+
return llvm::None;
1098+
}
1099+
10941100
/// Returns a string of target-specific clobbers, in LLVM format.
10951101
virtual const char *getClobbers() const = 0;
10961102

clang/include/clang/Basic/arm_mve.td

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ defm vmaxnmavq: Reduction<Scalar, "maxnmav", [Scalar, Vector]>;
575575
}
576576

577577
foreach half = [ "b", "t" ] in {
578-
defvar halfconst = !if(!eq(half, "b"), 0, 1);
578+
defvar halfconst = !ne(half, "b");
579579

580580
let params = [f32], pnt = PNT_None in {
581581
def vcvt#half#q_f16: Intrinsic<
@@ -1153,8 +1153,7 @@ defm vshlltq : vshll_imm<1>;
11531153

11541154
multiclass DyadicImmShift<Type outtype, Immediate imm, string intname = NAME,
11551155
dag extraargs = (?)> {
1156-
defvar intparams = !if(!eq(!cast<string>(outtype), !cast<string>(Vector)),
1157-
[Vector], [outtype, Vector]);
1156+
defvar intparams = !if(!eq(outtype, Vector), [Vector], [outtype, Vector]);
11581157

11591158
def q_n: Intrinsic<
11601159
outtype, (args outtype:$a, Vector:$b, imm:$sh),
@@ -1529,12 +1528,7 @@ let params = T.Usual in {
15291528
foreach desttype = T.All in {
15301529
// We want a vreinterpretq between every pair of supported vector types
15311530
// _except_ that there shouldn't be one from a type to itself.
1532-
//
1533-
// So this foldl expression implements what you'd write in Python as
1534-
// [srctype for srctype in T.All if srctype != desttype]
1535-
let params = !foldl([]<Type>, T.All, tlist, srctype, !listconcat(tlist,
1536-
!if(!eq(!cast<string>(desttype),!cast<string>(srctype)),[],[srctype])))
1537-
in {
1531+
let params = !filter(srctype, T.All, !ne(srctype, desttype)) in {
15381532
def "vreinterpretq_" # desttype: Intrinsic<
15391533
VecOf<desttype>, (args Vector:$x), (vreinterpret $x, VecOf<desttype>)>;
15401534
}
@@ -1576,8 +1570,9 @@ foreach desttype = !listconcat(T.Int16, T.Int32, T.Float) in {
15761570
defvar is_dest_float = !eq(desttype.kind, "f");
15771571
defvar is_dest_unsigned = !eq(desttype.kind, "u");
15781572
// First immediate operand of the LLVM intrinsic
1579-
defvar unsigned_flag = !if(is_dest_float, (unsignedflag Scalar),
1580-
!if(is_dest_unsigned, V.True, V.False));
1573+
defvar unsigned_flag = !cond(is_dest_float: (unsignedflag Scalar),
1574+
is_dest_unsigned: V.True,
1575+
true: V.False);
15811576
// For float->int conversions _n and _x_n intrinsics are not polymorphic
15821577
// because the signedness of the destination type cannot be inferred.
15831578
defvar pnt_nx = !if(is_dest_float, PNT_2Type, PNT_None);

clang/include/clang/CodeGen/CGFunctionInfo.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,17 @@ class ABIArgInfo {
9393
llvm::Type *PaddingType; // canHavePaddingType()
9494
llvm::Type *UnpaddedCoerceAndExpandType; // isCoerceAndExpand()
9595
};
96+
struct DirectAttrInfo {
97+
unsigned Offset;
98+
unsigned Align;
99+
};
100+
struct IndirectAttrInfo {
101+
unsigned Align;
102+
unsigned AddrSpace;
103+
};
96104
union {
97-
struct {
98-
unsigned Offset;
99-
unsigned Align;
100-
} DirectAttr; // isDirect() || isExtend()
101-
struct {
102-
unsigned Align;
103-
unsigned AddrSpace;
104-
} IndirectAttr; // isIndirect()
105+
DirectAttrInfo DirectAttr; // isDirect() || isExtend()
106+
IndirectAttrInfo IndirectAttr; // isIndirect()
105107
unsigned AllocaFieldIndex; // isInAlloca()
106108
};
107109
Kind TheKind;

clang/include/clang/CrossTU/CrossTranslationUnit.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class TranslationUnitDecl;
3838
namespace cross_tu {
3939

4040
enum class index_error_code {
41+
success = 0,
4142
unspecified = 1,
4243
missing_index_file,
4344
invalid_index_format,
@@ -253,6 +254,7 @@ class CrossTranslationUnitContext {
253254
/// In case of on-demand parsing, the invocations for parsing the source
254255
/// files is stored.
255256
llvm::Optional<InvocationListTy> InvocationList;
257+
index_error_code PreviousParsingResult = index_error_code::success;
256258
};
257259

258260
/// Maintain number of AST loads and check for reaching the load limit.

clang/include/clang/Driver/Driver.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class Driver {
8484
/// LTO mode selected via -f(no-)?lto(=.*)? options.
8585
LTOKind LTOMode;
8686

87+
/// LTO mode selected via -f(no-offload-)?lto(=.*)? options.
88+
LTOKind OffloadLTOMode;
89+
8790
public:
8891
enum OpenMPRuntimeKind {
8992
/// An unknown OpenMP runtime. We can't generate effective OpenMP code
@@ -571,10 +574,14 @@ class Driver {
571574
bool ShouldEmitStaticLibrary(const llvm::opt::ArgList &Args) const;
572575

573576
/// Returns true if we are performing any kind of LTO.
574-
bool isUsingLTO() const { return LTOMode != LTOK_None; }
577+
bool isUsingLTO(bool IsOffload = false) const {
578+
return getLTOMode(IsOffload) != LTOK_None;
579+
}
575580

576581
/// Get the specific kind of LTO being performed.
577-
LTOKind getLTOMode() const { return LTOMode; }
582+
LTOKind getLTOMode(bool IsOffload = false) const {
583+
return IsOffload ? OffloadLTOMode : LTOMode;
584+
}
578585

579586
private:
580587

0 commit comments

Comments
 (0)