Skip to content

Commit 62a1ddd

Browse files
committed
Merge remote-tracking branch 'upstream/release/12.x' into HEAD
2 parents 49b9728 + 15d1ee3 commit 62a1ddd

32 files changed

+832
-92
lines changed

clang-tools-extra/docs/ReleaseNotes.rst

+10
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,16 @@ Changes in existing checks
358358

359359
Added `std::basic_string_view` to default list of ``string``-like types.
360360

361+
Deprecated checks
362+
^^^^^^^^^^^^^^^^^
363+
364+
- The :doc:`readability-deleted-default
365+
<clang-tidy/checks/readability-deleted-default>` check has been deprecated.
366+
367+
The clang warning `Wdefaulted-function-deleted
368+
<https://clang.llvm.org/docs/DiagnosticsReference.html#wdefaulted-function-deleted>`_
369+
will diagnose the same issues and is enabled by default.
370+
361371
Improvements to include-fixer
362372
-----------------------------
363373

clang-tools-extra/docs/clang-tidy/checks/readability-deleted-default.rst

+3-17
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,6 @@
33
readability-deleted-default
44
===========================
55

6-
Checks that constructors and assignment operators marked as ``= default`` are
7-
not actually deleted by the compiler.
8-
9-
.. code-block:: c++
10-
11-
class Example {
12-
public:
13-
// This constructor is deleted because I is missing a default value.
14-
Example() = default;
15-
// This is fine.
16-
Example(const Example& Other) = default;
17-
// This operator is deleted because I cannot be assigned (it is const).
18-
Example& operator=(const Example& Other) = default;
19-
20-
private:
21-
const int I;
22-
};
6+
This check has been deprecated prefer to make use of the `Wdefaulted-function-deleted
7+
<https://clang.llvm.org/docs/DiagnosticsReference.html#wdefaulted-function-deleted>`_
8+
flag.

clang/docs/ReleaseNotes.rst

+41-1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ New Compiler Flags
7373

7474
- ...
7575

76+
- AArch64 options ``-moutline-atomics``, ``-mno-outline-atomics`` to enable
77+
and disable calls to helper functions implementing atomic operations. These
78+
out-of-line helpers like '__aarch64_cas8_relax' will detect at runtime
79+
AArch64 Large System Extensions (LSE) availability and either use their
80+
atomic instructions, or falls back to LL/SC loop. These options do not apply
81+
if the compilation target supports LSE. Atomic instructions are used directly
82+
in that case. The option's behaviour mirrors GCC, the helpers are implemented
83+
both in compiler-rt and libgcc.
84+
7685
- -fpch-codegen and -fpch-debuginfo generate shared code and/or debuginfo
7786
for contents of a precompiled header in a separate object file. This object
7887
file needs to be linked in, but its contents do not need to be generated
@@ -368,7 +377,38 @@ libclang
368377
Static Analyzer
369378
---------------
370379

371-
- ...
380+
.. 3ff220de9009 [analyzer][StdLibraryFunctionsChecker] Add POSIX networking functions
381+
.. ...And a million other patches.
382+
- Improve the analyzer's understanding of several POSIX functions.
383+
384+
.. https://reviews.llvm.org/D86533#2238207
385+
- Greatly improved the analyzer’s constraint solver by better understanding
386+
when constraints are imposed on multiple symbolic values that are known to be
387+
equal or known to be non-equal. It will now also efficiently reject impossible
388+
if-branches between known comparison expressions. (Incorrectly stated as a
389+
11.0.0 feature in the previous release notes)
390+
391+
.. 820e8d8656ec [Analyzer][WebKit] UncountedLambdaCaptureChecker
392+
- New checker: :ref:`webkit.UncountedLambdaCapturesChecker<webkit-UncountedLambdaCapturesChecker>`
393+
is a WebKit coding convention checker that flags raw pointers to
394+
reference-counted objects captured by lambdas and suggests using intrusive
395+
reference-counting smart pointers instead.
396+
397+
.. 8a64689e264c [Analyzer][WebKit] UncountedLocalVarsChecker
398+
- New checker: :ref:`alpha.webkit.UncountedLocalVarsChecker<alpha-webkit-UncountedLocalVarsChecker>`
399+
is a WebKit coding convention checker that intends to make sure that any
400+
uncounted local variable is backed by a ref-counted object with lifetime that
401+
is strictly larger than the scope of the uncounted local variable.
402+
403+
.. i914f6c4ff8a4 [StaticAnalyzer] Support struct annotations in FuchsiaHandleChecker
404+
- ``fuchia.HandleChecker`` now recognizes handles in structs; All the handles
405+
referenced by the structure (direct value or ptr) would be treated as
406+
containing the release/use/acquire annotations directly.
407+
408+
.. 8deaec122ec6 [analyzer] Update Fuchsia checker to catch releasing unowned handles.
409+
- Fuchsia checkers can detect the release of an unowned handle.
410+
411+
- Numerous fixes and improvements to bug report generation.
372412

373413
.. _release-notes-ubsan:
374414

clang/docs/analyzer/checkers.rst

+2
Original file line numberDiff line numberDiff line change
@@ -2538,6 +2538,8 @@ We also define a set of safe transformations which if passed a safe value as an
25382538
- casts
25392539
- unary operators like ``&`` or ``*``
25402540
2541+
.. _alpha-webkit-UncountedLocalVarsChecker:
2542+
25412543
alpha.webkit.UncountedLocalVarsChecker
25422544
""""""""""""""""""""""""""""""""""""""
25432545
The goal of this rule is to make sure that any uncounted local variable is backed by a ref-counted object with lifetime that is strictly larger than the scope of the uncounted local variable. To be on the safe side we require the scope of an uncounted variable to be embedded in the scope of ref-counted object that backs it.

clang/lib/Frontend/InitPreprocessor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
565565
Builder.defineMacro("__cpp_aggregate_bases", "201603L");
566566
Builder.defineMacro("__cpp_structured_bindings", "201606L");
567567
Builder.defineMacro("__cpp_nontype_template_args",
568-
LangOpts.CPlusPlus20 ? "201911L" : "201411L");
568+
"201411L"); // (not latest)
569569
Builder.defineMacro("__cpp_fold_expressions", "201603L");
570570
Builder.defineMacro("__cpp_guaranteed_copy_elision", "201606L");
571571
Builder.defineMacro("__cpp_nontype_template_parameter_auto", "201606L");

clang/test/Lexer/cxx-features.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@
181181
#error "wrong value for __cpp_structured_bindings"
182182
#endif
183183

184-
#if check(nontype_template_args, 0, 0, 0, 201411, 201911, 201911)
184+
#if check(nontype_template_args, 0, 0, 0, 201411, 201411, 201411)
185+
// FIXME: 201911 in C++20
185186
#error "wrong value for __cpp_nontype_template_args"
186187
#endif
187188

compiler-rt/lib/builtins/CMakeLists.txt

+7-1
Original file line numberDiff line numberDiff line change
@@ -515,14 +515,20 @@ set(aarch64_SOURCES
515515
set(OA_HELPERS_DIR "${CMAKE_CURRENT_BINARY_DIR}/outline_atomic_helpers.dir")
516516
file(MAKE_DIRECTORY "${OA_HELPERS_DIR}")
517517

518+
if(CMAKE_HOST_UNIX)
519+
set(COMPILER_RT_LINK_OR_COPY create_symlink)
520+
else()
521+
set(COMPILER_RT_LINK_OR_COPY copy)
522+
endif()
523+
518524
foreach(pat cas swp ldadd ldclr ldeor ldset)
519525
foreach(size 1 2 4 8 16)
520526
foreach(model 1 2 3 4)
521527
if(pat STREQUAL "cas" OR NOT size STREQUAL "16")
522528
set(helper_asm "${OA_HELPERS_DIR}/outline_atomic_${pat}${size}_${model}.S")
523529
add_custom_command(
524530
OUTPUT ${helper_asm}
525-
COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S" "${helper_asm}"
531+
COMMAND ${CMAKE_COMMAND} -E ${COMPILER_RT_LINK_OR_COPY} "${CMAKE_CURRENT_SOURCE_DIR}/aarch64/lse.S" "${helper_asm}"
526532
)
527533
set_source_files_properties("${helper_asm}"
528534
PROPERTIES

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -6517,8 +6517,11 @@ static SDValue extractShiftForRotate(SelectionDAG &DAG, SDValue OppShift,
65176517
// reduces to a rotate in direction shift2 by Pos or (equivalently) a rotate
65186518
// in direction shift1 by Neg. The range [0, EltSize) means that we only need
65196519
// to consider shift amounts with defined behavior.
6520+
//
6521+
// The IsRotate flag should be set when the LHS of both shifts is the same.
6522+
// Otherwise if matching a general funnel shift, it should be clear.
65206523
static bool matchRotateSub(SDValue Pos, SDValue Neg, unsigned EltSize,
6521-
SelectionDAG &DAG) {
6524+
SelectionDAG &DAG, bool IsRotate) {
65226525
// If EltSize is a power of 2 then:
65236526
//
65246527
// (a) (Pos == 0 ? 0 : EltSize - Pos) == (EltSize - Pos) & (EltSize - 1)
@@ -6550,8 +6553,11 @@ static bool matchRotateSub(SDValue Pos, SDValue Neg, unsigned EltSize,
65506553
// always invokes undefined behavior for 32-bit X.
65516554
//
65526555
// Below, Mask == EltSize - 1 when using [A] and is all-ones otherwise.
6556+
//
6557+
// NOTE: We can only do this when matching an AND and not a general
6558+
// funnel shift.
65536559
unsigned MaskLoBits = 0;
6554-
if (Neg.getOpcode() == ISD::AND && isPowerOf2_64(EltSize)) {
6560+
if (IsRotate && Neg.getOpcode() == ISD::AND && isPowerOf2_64(EltSize)) {
65556561
if (ConstantSDNode *NegC = isConstOrConstSplat(Neg.getOperand(1))) {
65566562
KnownBits Known = DAG.computeKnownBits(Neg.getOperand(0));
65576563
unsigned Bits = Log2_64(EltSize);
@@ -6641,7 +6647,8 @@ SDValue DAGCombiner::MatchRotatePosNeg(SDValue Shifted, SDValue Pos,
66416647
// (srl x, (*ext y))) ->
66426648
// (rotr x, y) or (rotl x, (sub 32, y))
66436649
EVT VT = Shifted.getValueType();
6644-
if (matchRotateSub(InnerPos, InnerNeg, VT.getScalarSizeInBits(), DAG)) {
6650+
if (matchRotateSub(InnerPos, InnerNeg, VT.getScalarSizeInBits(), DAG,
6651+
/*IsRotate*/ true)) {
66456652
bool HasPos = TLI.isOperationLegalOrCustom(PosOpcode, VT);
66466653
return DAG.getNode(HasPos ? PosOpcode : NegOpcode, DL, VT, Shifted,
66476654
HasPos ? Pos : Neg);
@@ -6670,7 +6677,7 @@ SDValue DAGCombiner::MatchFunnelPosNeg(SDValue N0, SDValue N1, SDValue Pos,
66706677
// fold (or (shl x0, (*ext (sub 32, y))),
66716678
// (srl x1, (*ext y))) ->
66726679
// (fshr x0, x1, y) or (fshl x0, x1, (sub 32, y))
6673-
if (matchRotateSub(InnerPos, InnerNeg, EltBits, DAG)) {
6680+
if (matchRotateSub(InnerPos, InnerNeg, EltBits, DAG, /*IsRotate*/ N0 == N1)) {
66746681
bool HasPos = TLI.isOperationLegalOrCustom(PosOpcode, VT);
66756682
return DAG.getNode(HasPos ? PosOpcode : NegOpcode, DL, VT, N0, N1,
66766683
HasPos ? Pos : Neg);

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

+29
Original file line numberDiff line numberDiff line change
@@ -5935,6 +5935,11 @@ SDValue TargetLowering::getNegatedExpression(SDValue Op, SelectionDAG &DAG,
59355935

59365936
SDLoc DL(Op);
59375937

5938+
// Because getNegatedExpression can delete nodes we need a handle to keep
5939+
// temporary nodes alive in case the recursion manages to create an identical
5940+
// node.
5941+
std::list<HandleSDNode> Handles;
5942+
59385943
switch (Opcode) {
59395944
case ISD::ConstantFP: {
59405945
// Don't invert constant FP values after legalization unless the target says
@@ -6003,11 +6008,18 @@ SDValue TargetLowering::getNegatedExpression(SDValue Op, SelectionDAG &DAG,
60036008
NegatibleCost CostX = NegatibleCost::Expensive;
60046009
SDValue NegX =
60056010
getNegatedExpression(X, DAG, LegalOps, OptForSize, CostX, Depth);
6011+
// Prevent this node from being deleted by the next call.
6012+
if (NegX)
6013+
Handles.emplace_back(NegX);
6014+
60066015
// fold (fneg (fadd X, Y)) -> (fsub (fneg Y), X)
60076016
NegatibleCost CostY = NegatibleCost::Expensive;
60086017
SDValue NegY =
60096018
getNegatedExpression(Y, DAG, LegalOps, OptForSize, CostY, Depth);
60106019

6020+
// We're done with the handles.
6021+
Handles.clear();
6022+
60116023
// Negate the X if its cost is less or equal than Y.
60126024
if (NegX && (CostX <= CostY)) {
60136025
Cost = CostX;
@@ -6052,11 +6064,18 @@ SDValue TargetLowering::getNegatedExpression(SDValue Op, SelectionDAG &DAG,
60526064
NegatibleCost CostX = NegatibleCost::Expensive;
60536065
SDValue NegX =
60546066
getNegatedExpression(X, DAG, LegalOps, OptForSize, CostX, Depth);
6067+
// Prevent this node from being deleted by the next call.
6068+
if (NegX)
6069+
Handles.emplace_back(NegX);
6070+
60556071
// fold (fneg (fmul X, Y)) -> (fmul X, (fneg Y))
60566072
NegatibleCost CostY = NegatibleCost::Expensive;
60576073
SDValue NegY =
60586074
getNegatedExpression(Y, DAG, LegalOps, OptForSize, CostY, Depth);
60596075

6076+
// We're done with the handles.
6077+
Handles.clear();
6078+
60606079
// Negate the X if its cost is less or equal than Y.
60616080
if (NegX && (CostX <= CostY)) {
60626081
Cost = CostX;
@@ -6094,15 +6113,25 @@ SDValue TargetLowering::getNegatedExpression(SDValue Op, SelectionDAG &DAG,
60946113
if (!NegZ)
60956114
break;
60966115

6116+
// Prevent this node from being deleted by the next two calls.
6117+
Handles.emplace_back(NegZ);
6118+
60976119
// fold (fneg (fma X, Y, Z)) -> (fma (fneg X), Y, (fneg Z))
60986120
NegatibleCost CostX = NegatibleCost::Expensive;
60996121
SDValue NegX =
61006122
getNegatedExpression(X, DAG, LegalOps, OptForSize, CostX, Depth);
6123+
// Prevent this node from being deleted by the next call.
6124+
if (NegX)
6125+
Handles.emplace_back(NegX);
6126+
61016127
// fold (fneg (fma X, Y, Z)) -> (fma X, (fneg Y), (fneg Z))
61026128
NegatibleCost CostY = NegatibleCost::Expensive;
61036129
SDValue NegY =
61046130
getNegatedExpression(Y, DAG, LegalOps, OptForSize, CostY, Depth);
61056131

6132+
// We're done with the handles.
6133+
Handles.clear();
6134+
61066135
// Negate the X if its cost is less or equal than Y.
61076136
if (NegX && (CostX <= CostY)) {
61086137
Cost = std::min(CostX, CostZ);

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -1017,11 +1017,12 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
10171017
// Vector reductions
10181018
for (MVT VT : { MVT::v4f16, MVT::v2f32,
10191019
MVT::v8f16, MVT::v4f32, MVT::v2f64 }) {
1020-
setOperationAction(ISD::VECREDUCE_FMAX, VT, Custom);
1021-
setOperationAction(ISD::VECREDUCE_FMIN, VT, Custom);
1020+
if (VT.getVectorElementType() != MVT::f16 || Subtarget->hasFullFP16()) {
1021+
setOperationAction(ISD::VECREDUCE_FMAX, VT, Custom);
1022+
setOperationAction(ISD::VECREDUCE_FMIN, VT, Custom);
10221023

1023-
if (VT.getVectorElementType() != MVT::f16 || Subtarget->hasFullFP16())
10241024
setOperationAction(ISD::VECREDUCE_FADD, VT, Legal);
1025+
}
10251026
}
10261027
for (MVT VT : { MVT::v8i8, MVT::v4i16, MVT::v2i32,
10271028
MVT::v16i8, MVT::v8i16, MVT::v4i32 }) {

llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,14 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
345345
return false;
346346

347347
// Get the constant out of the ICmp, if there is one.
348+
// Only try this when exactly 1 operand is a constant (if both operands
349+
// are constant, the icmp should eventually simplify). Otherwise, we may
350+
// invert the transform that reduces set bits and infinite-loop.
351+
Value *X;
348352
const APInt *CmpC;
349353
ICmpInst::Predicate Pred;
350-
if (!match(I->getOperand(0), m_c_ICmp(Pred, m_APInt(CmpC), m_Value())) ||
351-
CmpC->getBitWidth() != SelC->getBitWidth())
354+
if (!match(I->getOperand(0), m_ICmp(Pred, m_Value(X), m_APInt(CmpC))) ||
355+
isa<Constant>(X) || CmpC->getBitWidth() != SelC->getBitWidth())
352356
return ShrinkDemandedConstant(I, OpNo, DemandedMask);
353357

354358
// If the constant is already the same as the ICmp, leave it as-is.

llvm/lib/Transforms/Utils/Local.cpp

+23-1
Original file line numberDiff line numberDiff line change
@@ -918,17 +918,39 @@ static void gatherIncomingValuesToPhi(PHINode *PN,
918918
/// \param IncomingValues A map from block to value.
919919
static void replaceUndefValuesInPhi(PHINode *PN,
920920
const IncomingValueMap &IncomingValues) {
921+
SmallVector<unsigned> TrueUndefOps;
921922
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
922923
Value *V = PN->getIncomingValue(i);
923924

924925
if (!isa<UndefValue>(V)) continue;
925926

926927
BasicBlock *BB = PN->getIncomingBlock(i);
927928
IncomingValueMap::const_iterator It = IncomingValues.find(BB);
928-
if (It == IncomingValues.end()) continue;
929929

930+
// Keep track of undef/poison incoming values. Those must match, so we fix
931+
// them up below if needed.
932+
// Note: this is conservatively correct, but we could try harder and group
933+
// the undef values per incoming basic block.
934+
if (It == IncomingValues.end()) {
935+
TrueUndefOps.push_back(i);
936+
continue;
937+
}
938+
939+
// There is a defined value for this incoming block, so map this undef
940+
// incoming value to the defined value.
930941
PN->setIncomingValue(i, It->second);
931942
}
943+
944+
// If there are both undef and poison values incoming, then convert those
945+
// values to undef. It is invalid to have different values for the same
946+
// incoming block.
947+
unsigned PoisonCount = count_if(TrueUndefOps, [&](unsigned i) {
948+
return isa<PoisonValue>(PN->getIncomingValue(i));
949+
});
950+
if (PoisonCount != 0 && PoisonCount != TrueUndefOps.size()) {
951+
for (unsigned i : TrueUndefOps)
952+
PN->setIncomingValue(i, UndefValue::get(PN->getType()));
953+
}
932954
}
933955

934956
/// Replace a value flowing from a block to a phi with

llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h

+4
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ class VPBuilder {
142142
return createInstruction(Instruction::BinaryOps::Or, {LHS, RHS});
143143
}
144144

145+
VPValue *createSelect(VPValue *Cond, VPValue *TrueVal, VPValue *FalseVal) {
146+
return createNaryOp(Instruction::Select, {Cond, TrueVal, FalseVal});
147+
}
148+
145149
//===--------------------------------------------------------------------===//
146150
// RAII helpers.
147151
//===--------------------------------------------------------------------===//

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -8195,8 +8195,15 @@ VPValue *VPRecipeBuilder::createEdgeMask(BasicBlock *Src, BasicBlock *Dst,
81958195
if (BI->getSuccessor(0) != Dst)
81968196
EdgeMask = Builder.createNot(EdgeMask);
81978197

8198-
if (SrcMask) // Otherwise block in-mask is all-one, no need to AND.
8199-
EdgeMask = Builder.createAnd(EdgeMask, SrcMask);
8198+
if (SrcMask) { // Otherwise block in-mask is all-one, no need to AND.
8199+
// The condition is 'SrcMask && EdgeMask', which is equivalent to
8200+
// 'select i1 SrcMask, i1 EdgeMask, i1 false'.
8201+
// The select version does not introduce new UB if SrcMask is false and
8202+
// EdgeMask is poison. Using 'and' here introduces undefined behavior.
8203+
VPValue *False = Plan->getOrAddVPValue(
8204+
ConstantInt::getFalse(BI->getCondition()->getType()));
8205+
EdgeMask = Builder.createSelect(SrcMask, EdgeMask, False);
8206+
}
82008207

82018208
return EdgeMaskCache[Edge] = EdgeMask;
82028209
}

0 commit comments

Comments
 (0)