Skip to content

Commit 627eebd

Browse files
author
git apple-llvm automerger
committed
Merge commit 'd6cfed44c5fd' from apple/stable/20200714 into swift/master-rebranch
2 parents cce273e + d6cfed4 commit 627eebd

File tree

155 files changed

+4676
-1163
lines changed

Some content is hidden

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

155 files changed

+4676
-1163
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 96 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,46 @@ Major New Features
4848

4949
- ...
5050

51+
Recovery AST
52+
^^^^^^^^^^^^
53+
54+
clang's AST now improves support for representing broken C++ code. This improves
55+
the quality of subsequent diagnostics after an error is encountered. It also
56+
exposes more information to tools like clang-tidy and clangd that consume
57+
clang’s AST, allowing them to be more accurate on broken code.
58+
59+
A RecoveryExpr is introduced in clang's AST, marking an expression containing
60+
semantic errors. This preserves the source range and subexpressions of the
61+
broken expression in the AST (rather than discarding the whole expression).
62+
63+
For the following invalid code:
64+
65+
.. code-block:: c++
66+
67+
int NoArg(); // Line 1
68+
int x = NoArg(42); // oops!
69+
70+
clang-10 produces the minimal placeholder:
71+
72+
.. code-block:: c++
73+
74+
// VarDecl <line:2:1, col:5> col:5 x 'int'
75+
76+
clang-11 produces a richer AST:
77+
78+
.. code-block:: c++
79+
80+
// VarDecl <line:2:1, col:16> col:5 x 'int' cinit
81+
// `-RecoveryExpr <col:9, col:16> '<dependent type>' contains-errors lvalue
82+
// `-UnresolvedLookupExpr <col:9> '<overloaded function>' lvalue (ADL) = 'NoArg'
83+
// `-IntegerLiteral <col:15> 'int' 42
84+
85+
Note that error-dependent types and values may now occur outside a template
86+
context. Tools may need to adjust assumptions about dependent code.
87+
88+
This feature is on by default for C++ code, and can be explicitly controlled
89+
with `-Xclang -f[no-]recovery-ast`.
90+
5191
Improvements to Clang's diagnostics
5292
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5393

@@ -58,6 +98,10 @@ Improvements to Clang's diagnostics
5898
-Wuninitialized. It warns on cases where uninitialized variables are passed
5999
as const reference arguments to a function.
60100

101+
- ``-Wimplicit-const-int-float-conversion`` (enabled by default) is a new
102+
option controlled by ``-Wimplicit-int-float-conversion``. It warns on
103+
implicit conversion from a floating constant to an integer type.
104+
61105
Non-comprehensive list of changes in this release
62106
-------------------------------------------------
63107

@@ -144,6 +188,21 @@ Non-comprehensive list of changes in this release
144188
provided through shared libraries, avoid using lazy binding. If you
145189
use lazy binding, the results could be corrupted.
146190

191+
- ``-O`` maps to ``-O1`` instead of ``-O2``.
192+
(`D79916 <https://reviews.llvm.org/D79916>`_)
193+
194+
- In a ``-flto={full,thin}`` link, ``-Os``, ``-Oz`` and ``-Og`` can be used
195+
now. ``-Os`` and ``-Oz`` map to the -O2 pipe line while ``-Og`` maps to the
196+
-O1 pipeline.
197+
(`D79919 <https://reviews.llvm.org/D79919>`_)
198+
199+
- ``--coverage`` (gcov) defaults to gcov [4.8,8) compatible format now.
200+
201+
- On x86, ``-fpic/-fPIC -fno-semantic-interposition`` assumes a global
202+
definition of default visibility non-interposable and allows interprocedural
203+
optimizations. In produced assembly ``-Lfunc$local`` local aliases are created
204+
for global symbols of default visibility.
205+
147206
New Compiler Flags
148207
------------------
149208

@@ -195,6 +254,14 @@ New Compiler Flags
195254
adding -fdata-sections -ffunction-sections to the command generating
196255
the shared object).
197256

257+
- ``-fsanitize-coverage-allowlist`` and ``-fsanitize-coverage-blocklist`` are added.
258+
259+
- -mtls-size={12,24,32,48} allows selecting the size of the TLS (thread-local
260+
storage) in the local exec TLS model of AArch64, which is the default TLS
261+
model for non-PIC objects. Each value represents 4KB, 16MB (default), 4GB,
262+
and 256TB (needs -mcmodel=large). This allows large/many thread local
263+
variables or a compact/fast code in an executable.
264+
198265
Deprecated Compiler Flags
199266
-------------------------
200267

@@ -315,10 +382,36 @@ C++1z Feature Support
315382
Objective-C Language Changes in Clang
316383
-------------------------------------
317384

318-
OpenCL C Language Changes in Clang
319-
----------------------------------
385+
OpenCL Kernel Language Changes in Clang
386+
---------------------------------------
320387

321-
...
388+
- Added extensions from `cl_khr_subgroup_extensions` to clang and the internal
389+
header.
390+
391+
- Added rocm device libs linking for AMDGPU.
392+
393+
- Added diagnostic for OpenCL 2.0 blocks used in function arguments.
394+
395+
- Fixed MS mangling for OpenCL 2.0 pipe type specifier.
396+
397+
- Improved command line options for fast relaxed math.
398+
399+
- Improved `atomic_fetch_min/max` functions in the internal header
400+
(`opencl-c.h`).
401+
402+
- Improved size of builtin function table for `TableGen`-based internal header
403+
(enabled by `-fdeclare-opencl-builtins`) and added new functionality for
404+
OpenCL 2.0 atomics, pipes, enqueue kernel, `cl_khr_subgroups`,
405+
`cl_arm_integer_dot_product`.
406+
407+
Changes related to C++ for OpenCL
408+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
409+
410+
- Added `addrspace_cast` operator.
411+
412+
- Improved address space deduction in templates.
413+
414+
- Improved diagnostics of address spaces in nested pointer conversions.
322415

323416
ABI Changes in Clang
324417
--------------------

clang/include/clang/AST/ASTContext.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
#include "llvm/Support/Allocator.h"
6161
#include "llvm/Support/Casting.h"
6262
#include "llvm/Support/Compiler.h"
63+
#include "llvm/Support/TypeSize.h"
6364
#include <cassert>
6465
#include <cstddef>
6566
#include <cstdint>
@@ -1300,6 +1301,21 @@ class ASTContext : public RefCountedBase<ASTContext> {
13001301
/// Returns a vla type where known sizes are replaced with [*].
13011302
QualType getVariableArrayDecayedType(QualType Ty) const;
13021303

1304+
// Convenience struct to return information about a builtin vector type.
1305+
struct BuiltinVectorTypeInfo {
1306+
QualType ElementType;
1307+
llvm::ElementCount EC;
1308+
unsigned NumVectors;
1309+
BuiltinVectorTypeInfo(QualType ElementType, llvm::ElementCount EC,
1310+
unsigned NumVectors)
1311+
: ElementType(ElementType), EC(EC), NumVectors(NumVectors) {}
1312+
};
1313+
1314+
/// Returns the element type, element count and number of vectors
1315+
/// (in case of tuple) for a builtin vector type.
1316+
BuiltinVectorTypeInfo
1317+
getBuiltinVectorTypeInfo(const BuiltinType *VecTy) const;
1318+
13031319
/// Return the unique reference to a scalable vector type of the specified
13041320
/// element type and scalable number of elements.
13051321
///

clang/lib/AST/ASTContext.cpp

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3645,6 +3645,119 @@ QualType ASTContext::getIncompleteArrayType(QualType elementType,
36453645
return QualType(newType, 0);
36463646
}
36473647

3648+
ASTContext::BuiltinVectorTypeInfo
3649+
ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const {
3650+
#define SVE_INT_ELTTY(BITS, ELTS, SIGNED, NUMVECTORS) \
3651+
{getIntTypeForBitwidth(BITS, SIGNED), llvm::ElementCount(ELTS, true), \
3652+
NUMVECTORS};
3653+
3654+
#define SVE_ELTTY(ELTTY, ELTS, NUMVECTORS) \
3655+
{ELTTY, llvm::ElementCount(ELTS, true), NUMVECTORS};
3656+
3657+
switch (Ty->getKind()) {
3658+
default:
3659+
llvm_unreachable("Unsupported builtin vector type");
3660+
case BuiltinType::SveInt8:
3661+
return SVE_INT_ELTTY(8, 16, true, 1);
3662+
case BuiltinType::SveUint8:
3663+
return SVE_INT_ELTTY(8, 16, false, 1);
3664+
case BuiltinType::SveInt8x2:
3665+
return SVE_INT_ELTTY(8, 16, true, 2);
3666+
case BuiltinType::SveUint8x2:
3667+
return SVE_INT_ELTTY(8, 16, false, 2);
3668+
case BuiltinType::SveInt8x3:
3669+
return SVE_INT_ELTTY(8, 16, true, 3);
3670+
case BuiltinType::SveUint8x3:
3671+
return SVE_INT_ELTTY(8, 16, false, 3);
3672+
case BuiltinType::SveInt8x4:
3673+
return SVE_INT_ELTTY(8, 16, true, 4);
3674+
case BuiltinType::SveUint8x4:
3675+
return SVE_INT_ELTTY(8, 16, false, 4);
3676+
case BuiltinType::SveInt16:
3677+
return SVE_INT_ELTTY(16, 8, true, 1);
3678+
case BuiltinType::SveUint16:
3679+
return SVE_INT_ELTTY(16, 8, false, 1);
3680+
case BuiltinType::SveInt16x2:
3681+
return SVE_INT_ELTTY(16, 8, true, 2);
3682+
case BuiltinType::SveUint16x2:
3683+
return SVE_INT_ELTTY(16, 8, false, 2);
3684+
case BuiltinType::SveInt16x3:
3685+
return SVE_INT_ELTTY(16, 8, true, 3);
3686+
case BuiltinType::SveUint16x3:
3687+
return SVE_INT_ELTTY(16, 8, false, 3);
3688+
case BuiltinType::SveInt16x4:
3689+
return SVE_INT_ELTTY(16, 8, true, 4);
3690+
case BuiltinType::SveUint16x4:
3691+
return SVE_INT_ELTTY(16, 8, false, 4);
3692+
case BuiltinType::SveInt32:
3693+
return SVE_INT_ELTTY(32, 4, true, 1);
3694+
case BuiltinType::SveUint32:
3695+
return SVE_INT_ELTTY(32, 4, false, 1);
3696+
case BuiltinType::SveInt32x2:
3697+
return SVE_INT_ELTTY(32, 4, true, 2);
3698+
case BuiltinType::SveUint32x2:
3699+
return SVE_INT_ELTTY(32, 4, false, 2);
3700+
case BuiltinType::SveInt32x3:
3701+
return SVE_INT_ELTTY(32, 4, true, 3);
3702+
case BuiltinType::SveUint32x3:
3703+
return SVE_INT_ELTTY(32, 4, false, 3);
3704+
case BuiltinType::SveInt32x4:
3705+
return SVE_INT_ELTTY(32, 4, true, 4);
3706+
case BuiltinType::SveUint32x4:
3707+
return SVE_INT_ELTTY(32, 4, false, 4);
3708+
case BuiltinType::SveInt64:
3709+
return SVE_INT_ELTTY(64, 2, true, 1);
3710+
case BuiltinType::SveUint64:
3711+
return SVE_INT_ELTTY(64, 2, false, 1);
3712+
case BuiltinType::SveInt64x2:
3713+
return SVE_INT_ELTTY(64, 2, true, 2);
3714+
case BuiltinType::SveUint64x2:
3715+
return SVE_INT_ELTTY(64, 2, false, 2);
3716+
case BuiltinType::SveInt64x3:
3717+
return SVE_INT_ELTTY(64, 2, true, 3);
3718+
case BuiltinType::SveUint64x3:
3719+
return SVE_INT_ELTTY(64, 2, false, 3);
3720+
case BuiltinType::SveInt64x4:
3721+
return SVE_INT_ELTTY(64, 2, true, 4);
3722+
case BuiltinType::SveUint64x4:
3723+
return SVE_INT_ELTTY(64, 2, false, 4);
3724+
case BuiltinType::SveBool:
3725+
return SVE_ELTTY(BoolTy, 16, 1);
3726+
case BuiltinType::SveFloat16:
3727+
return SVE_ELTTY(HalfTy, 8, 1);
3728+
case BuiltinType::SveFloat16x2:
3729+
return SVE_ELTTY(HalfTy, 8, 2);
3730+
case BuiltinType::SveFloat16x3:
3731+
return SVE_ELTTY(HalfTy, 8, 3);
3732+
case BuiltinType::SveFloat16x4:
3733+
return SVE_ELTTY(HalfTy, 8, 4);
3734+
case BuiltinType::SveFloat32:
3735+
return SVE_ELTTY(FloatTy, 4, 1);
3736+
case BuiltinType::SveFloat32x2:
3737+
return SVE_ELTTY(FloatTy, 4, 2);
3738+
case BuiltinType::SveFloat32x3:
3739+
return SVE_ELTTY(FloatTy, 4, 3);
3740+
case BuiltinType::SveFloat32x4:
3741+
return SVE_ELTTY(FloatTy, 4, 4);
3742+
case BuiltinType::SveFloat64:
3743+
return SVE_ELTTY(DoubleTy, 2, 1);
3744+
case BuiltinType::SveFloat64x2:
3745+
return SVE_ELTTY(DoubleTy, 2, 2);
3746+
case BuiltinType::SveFloat64x3:
3747+
return SVE_ELTTY(DoubleTy, 2, 3);
3748+
case BuiltinType::SveFloat64x4:
3749+
return SVE_ELTTY(DoubleTy, 2, 4);
3750+
case BuiltinType::SveBFloat16:
3751+
return SVE_ELTTY(BFloat16Ty, 8, 1);
3752+
case BuiltinType::SveBFloat16x2:
3753+
return SVE_ELTTY(BFloat16Ty, 8, 2);
3754+
case BuiltinType::SveBFloat16x3:
3755+
return SVE_ELTTY(BFloat16Ty, 8, 3);
3756+
case BuiltinType::SveBFloat16x4:
3757+
return SVE_ELTTY(BFloat16Ty, 8, 4);
3758+
}
3759+
}
3760+
36483761
/// getScalableVectorType - Return the unique reference to a scalable vector
36493762
/// type of the specified element type and size. VectorType must be a built-in
36503763
/// type.

clang/lib/AST/DeclBase.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,6 +1487,13 @@ static bool shouldBeHidden(NamedDecl *D) {
14871487
if (FD->isFunctionTemplateSpecialization())
14881488
return true;
14891489

1490+
// Hide destructors that are invalid. There should always be one destructor,
1491+
// but if it is an invalid decl, another one is created. We need to hide the
1492+
// invalid one from places that expect exactly one destructor, like the
1493+
// serialization code.
1494+
if (isa<CXXDestructorDecl>(D) && D->isInvalidDecl())
1495+
return true;
1496+
14901497
return false;
14911498
}
14921499

clang/lib/Basic/Targets.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,6 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
409409
return new SolarisTargetInfo<SparcV8TargetInfo>(Triple, Opts);
410410
case llvm::Triple::NetBSD:
411411
return new NetBSDTargetInfo<SparcV8TargetInfo>(Triple, Opts);
412-
case llvm::Triple::OpenBSD:
413-
return new OpenBSDTargetInfo<SparcV8TargetInfo>(Triple, Opts);
414412
case llvm::Triple::RTEMS:
415413
return new RTEMSTargetInfo<SparcV8TargetInfo>(Triple, Opts);
416414
default:
@@ -424,8 +422,6 @@ TargetInfo *AllocateTarget(const llvm::Triple &Triple,
424422
return new LinuxTargetInfo<SparcV8elTargetInfo>(Triple, Opts);
425423
case llvm::Triple::NetBSD:
426424
return new NetBSDTargetInfo<SparcV8elTargetInfo>(Triple, Opts);
427-
case llvm::Triple::OpenBSD:
428-
return new OpenBSDTargetInfo<SparcV8elTargetInfo>(Triple, Opts);
429425
case llvm::Triple::RTEMS:
430426
return new RTEMSTargetInfo<SparcV8elTargetInfo>(Triple, Opts);
431427
default:

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -719,23 +719,39 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
719719
case BuiltinType::Id: \
720720
return getOrCreateStructPtrType("opencl_" #ExtType, Id##Ty);
721721
#include "clang/Basic/OpenCLExtensionTypes.def"
722-
// TODO: real support for SVE types requires more infrastructure
723-
// to be added first. The types have a variable length and are
724-
// represented in debug info as types whose length depends on a
725-
// target-specific pseudo register.
726-
#define SVE_TYPE(Name, Id, SingletonId) \
727-
case BuiltinType::Id:
722+
723+
#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
728724
#include "clang/Basic/AArch64SVEACLETypes.def"
729-
{
730-
unsigned DiagID = CGM.getDiags().getCustomDiagID(
731-
DiagnosticsEngine::Error,
732-
"cannot yet generate debug info for SVE type '%0'");
733-
auto Name = BT->getName(CGM.getContext().getPrintingPolicy());
734-
CGM.getDiags().Report(DiagID) << Name;
735-
// Return something safe.
736-
return CreateType(cast<const BuiltinType>(CGM.getContext().IntTy));
737-
}
725+
{
726+
ASTContext::BuiltinVectorTypeInfo Info =
727+
CGM.getContext().getBuiltinVectorTypeInfo(BT);
728+
unsigned NumElemsPerVG = (Info.EC.Min * Info.NumVectors) / 2;
729+
730+
// Debuggers can't extract 1bit from a vector, so will display a
731+
// bitpattern for svbool_t instead.
732+
if (Info.ElementType == CGM.getContext().BoolTy) {
733+
NumElemsPerVG /= 8;
734+
Info.ElementType = CGM.getContext().UnsignedCharTy;
735+
}
738736

737+
auto *LowerBound =
738+
llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
739+
llvm::Type::getInt64Ty(CGM.getLLVMContext()), 0));
740+
SmallVector<int64_t, 9> Expr(
741+
{llvm::dwarf::DW_OP_constu, NumElemsPerVG, llvm::dwarf::DW_OP_bregx,
742+
/* AArch64::VG */ 46, 0, llvm::dwarf::DW_OP_mul,
743+
llvm::dwarf::DW_OP_constu, 1, llvm::dwarf::DW_OP_minus});
744+
auto *UpperBound = DBuilder.createExpression(Expr);
745+
746+
llvm::Metadata *Subscript = DBuilder.getOrCreateSubrange(
747+
/*count*/ nullptr, LowerBound, UpperBound, /*stride*/ nullptr);
748+
llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
749+
llvm::DIType *ElemTy =
750+
getOrCreateType(Info.ElementType, TheCU->getFile());
751+
auto Align = getTypeAlignIfRequired(BT, CGM.getContext());
752+
return DBuilder.createVectorType(/*Size*/ 0, Align, ElemTy,
753+
SubscriptArray);
754+
}
739755
case BuiltinType::UChar:
740756
case BuiltinType::Char_U:
741757
Encoding = llvm::dwarf::DW_ATE_unsigned_char;

0 commit comments

Comments
 (0)