Skip to content

Commit 0e8798f

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:e86d6a43f03b into amd-gfx:caaa027161c5
Local branch amd-gfx caaa027 Merged main:1964118ace49 into amd-gfx:a0a17ac92a9a Remote branch main e86d6a4 Regenerate test checks for tests affected by D141060
2 parents caaa027 + e86d6a4 commit 0e8798f

File tree

49 files changed

+2347
-1376
lines changed

Some content is hidden

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

49 files changed

+2347
-1376
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,11 @@ Bug Fixes to C++ Support
435435
we now produce a diagnostic. Fixes:
436436
(`#65522 <https://github.com/llvm/llvm-project/issues/65522>`_)
437437

438+
- Fixed a bug where clang incorrectly considered implicitly generated deduction
439+
guides from a non-templated constructor and a templated constructor as ambiguous,
440+
rather than prefer the non-templated constructor as specified in
441+
[standard.group]p3.
442+
438443
Bug Fixes to AST Handling
439444
^^^^^^^^^^^^^^^^^^^^^^^^^
440445
- Fixed an import failure of recursive friend class template.

clang/lib/Sema/SemaOverload.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10440,6 +10440,21 @@ bool clang::isBetterOverloadCandidate(
1044010440
// -- F1 is the copy deduction candidate(16.3.1.8) and F2 is not
1044110441
if (Guide1->getDeductionCandidateKind() == DeductionCandidate::Copy)
1044210442
return true;
10443+
if (Guide2->getDeductionCandidateKind() == DeductionCandidate::Copy)
10444+
return false;
10445+
10446+
// --F1 is generated from a non-template constructor and F2 is generated
10447+
// from a constructor template
10448+
const auto *Constructor1 = Guide1->getCorrespondingConstructor();
10449+
const auto *Constructor2 = Guide2->getCorrespondingConstructor();
10450+
if (Constructor1 && Constructor2) {
10451+
bool isC1Templated = Constructor1->getTemplatedKind() !=
10452+
FunctionDecl::TemplatedKind::TK_NonTemplate;
10453+
bool isC2Templated = Constructor2->getTemplatedKind() !=
10454+
FunctionDecl::TemplatedKind::TK_NonTemplate;
10455+
if (isC1Templated != isC2Templated)
10456+
return isC2Templated;
10457+
}
1044310458
}
1044410459
}
1044510460

@@ -10483,7 +10498,7 @@ bool clang::isBetterOverloadCandidate(
1048310498
if (AS1 != AS2) {
1048410499
if (Qualifiers::isAddressSpaceSupersetOf(AS2, AS1))
1048510500
return true;
10486-
if (Qualifiers::isAddressSpaceSupersetOf(AS2, AS1))
10501+
if (Qualifiers::isAddressSpaceSupersetOf(AS1, AS2))
1048710502
return false;
1048810503
}
1048910504
}

clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ Decl *TemplateDeclInstantiator::VisitFunctionDecl(
21402140
Function = CXXDeductionGuideDecl::Create(
21412141
SemaRef.Context, DC, D->getInnerLocStart(),
21422142
InstantiatedExplicitSpecifier, NameInfo, T, TInfo,
2143-
D->getSourceRange().getEnd(), /*Ctor=*/nullptr,
2143+
D->getSourceRange().getEnd(), DGuide->getCorrespondingConstructor(),
21442144
DGuide->getDeductionCandidateKind());
21452145
Function->setAccess(D->getAccess());
21462146
} else {

clang/test/CXX/over/over.match/over.match.funcs/over.match.class.deduct/p2.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,38 @@ int main() {
8585

8686

8787
}
88+
89+
namespace deduceTemplatedConstructor {
90+
template <typename X, typename Y> struct IsSame {
91+
static constexpr bool value = false;
92+
};
93+
94+
template <typename Z> struct IsSame<Z, Z> {
95+
static constexpr bool value = true;
96+
};
97+
template <class T> struct A {
98+
using value_type = T;
99+
A(value_type);
100+
A(const A&);
101+
A(T, T, int);
102+
template<class U>
103+
A(int, T, U);
104+
};
105+
106+
A x(1, 2, 3); // no-error
107+
static_assert(IsSame<decltype(x),A<int>>::value);
108+
109+
template <class T>
110+
A(T) -> A<T>;
111+
112+
A a(42);
113+
static_assert(IsSame<decltype(a),A<int>>::value);
114+
A b = a;
115+
static_assert(IsSame<decltype(b),A<int>>::value);
116+
117+
template <class T>
118+
A(A<T>) -> A<A<T>>;
119+
120+
A b2 = a;
121+
static_assert(IsSame<decltype(b2),A<A<int>>>::value);
122+
}

libcxx/include/__algorithm/pstl_backend.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,25 @@ A PSTL parallel backend is a tag type to which the following functions are assoc
3535
template <class _ExecutionPolicy, class _RandomAccessIterator, class _Comp>
3636
void __pstl_stable_sort(_Backend, _RandomAccessIterator __first, _RandomAccessIterator __last, _Comp __comp);
3737
38+
template <class _ExecutionPolicy,
39+
class _ForwardIterator1,
40+
class _ForwardIterator2,
41+
class _ForwardOutIterator,
42+
class _Comp>
43+
_ForwardOutIterator __pstl_merge(_Backend,
44+
_ForwardIterator1 __first1,
45+
_ForwardIterator1 __last1,
46+
_ForwardIterator2 __first2,
47+
_ForwardIterator2 __last2,
48+
_ForwardOutIterator __result,
49+
_Comp __comp);
50+
3851
template <class _ExecutionPolicy, class _InIterator, class _OutIterator, class _UnaryOperation>
39-
_OutIterator __pstl_transform(_InIterator __first, _InIterator __last, _OutIterator __result, _UnaryOperation __op);
52+
_OutIterator __pstl_transform(_Backend, _InIterator __first, _InIterator __last, _OutIterator __result, _UnaryOperation __op);
4053
4154
template <class _ExecutionPolicy, class _InIterator1, class _InIterator2, class _OutIterator, class _BinaryOperation>
42-
_OutIterator __pstl_transform(_InIterator1 __first1,
55+
_OutIterator __pstl_transform(_Backend,
56+
_InIterator1 __first1,
4357
_InIterator1 __last1,
4458
_InIterator2 __first2,
4559
_OutIterator __result,

lldb/include/lldb/Utility/XcodeSDK.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class XcodeSDK {
6969

7070
XcodeSDK &operator=(const XcodeSDK &other);
7171
XcodeSDK(const XcodeSDK&) = default;
72-
bool operator==(const XcodeSDK &other);
72+
bool operator==(const XcodeSDK &other) const;
7373

7474
/// Return parsed SDK type and version number.
7575
Info Parse() const;

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ void DynamicLoaderDarwinKernel::KextImageInfo::SetProcessStopId(
606606
m_load_process_stop_id = stop_id;
607607
}
608608

609-
bool DynamicLoaderDarwinKernel::KextImageInfo::
610-
operator==(const KextImageInfo &rhs) {
609+
bool DynamicLoaderDarwinKernel::KextImageInfo::operator==(
610+
const KextImageInfo &rhs) const {
611611
if (m_uuid.IsValid() || rhs.GetUUID().IsValid()) {
612612
return m_uuid == rhs.GetUUID();
613613
}

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class DynamicLoaderDarwinKernel : public lldb_private::DynamicLoader {
176176

177177
void SetProcessStopId(uint32_t stop_id);
178178

179-
bool operator==(const KextImageInfo &rhs);
179+
bool operator==(const KextImageInfo &rhs) const;
180180

181181
uint32_t GetAddressByteSize(); // as determined by Mach-O header
182182

lldb/source/Utility/XcodeSDK.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ XcodeSDK::XcodeSDK(XcodeSDK::Info info) : m_name(GetName(info.type).str()) {
5656

5757
XcodeSDK &XcodeSDK::operator=(const XcodeSDK &other) = default;
5858

59-
bool XcodeSDK::operator==(const XcodeSDK &other) {
59+
bool XcodeSDK::operator==(const XcodeSDK &other) const {
6060
return m_name == other.m_name;
6161
}
6262

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 476770
19+
#define LLVM_MAIN_REVISION 476779
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11113,6 +11113,31 @@ void RISCVTargetLowering::ReplaceNodeResults(SDNode *N,
1111311113
}
1111411114
}
1111511115

11116+
/// Given an integer binary operator, return the generic ISD::VECREDUCE_OP
11117+
/// which corresponds to it.
11118+
static unsigned getVecReduceOpcode(unsigned Opc) {
11119+
switch (Opc) {
11120+
default:
11121+
llvm_unreachable("Unhandled binary to transfrom reduction");
11122+
case ISD::ADD:
11123+
return ISD::VECREDUCE_ADD;
11124+
case ISD::UMAX:
11125+
return ISD::VECREDUCE_UMAX;
11126+
case ISD::SMAX:
11127+
return ISD::VECREDUCE_SMAX;
11128+
case ISD::UMIN:
11129+
return ISD::VECREDUCE_UMIN;
11130+
case ISD::SMIN:
11131+
return ISD::VECREDUCE_SMIN;
11132+
case ISD::AND:
11133+
return ISD::VECREDUCE_AND;
11134+
case ISD::OR:
11135+
return ISD::VECREDUCE_OR;
11136+
case ISD::XOR:
11137+
return ISD::VECREDUCE_XOR;
11138+
}
11139+
}
11140+
1111611141
/// Perform two related transforms whose purpose is to incrementally recognize
1111711142
/// an explode_vector followed by scalar reduction as a vector reduction node.
1111811143
/// This exists to recover from a deficiency in SLP which can't handle
@@ -11129,10 +11154,22 @@ combineBinOpOfExtractToReduceTree(SDNode *N, SelectionDAG &DAG,
1112911154
if (DAG.NewNodesMustHaveLegalTypes)
1113011155
return SDValue();
1113111156

11157+
// Without V, this transform isn't useful. We could form the (illegal)
11158+
// operations and let them be scalarized again, but there's really no point.
11159+
if (!Subtarget.hasVInstructions())
11160+
return SDValue();
11161+
1113211162
const SDLoc DL(N);
1113311163
const EVT VT = N->getValueType(0);
11134-
[[maybe_unused]] const unsigned Opc = N->getOpcode();
11135-
assert(Opc == ISD::ADD && "extend this to other reduction types");
11164+
11165+
// TODO: Handle floating point here.
11166+
if (!VT.isInteger())
11167+
return SDValue();
11168+
11169+
const unsigned Opc = N->getOpcode();
11170+
const unsigned ReduceOpc = getVecReduceOpcode(Opc);
11171+
assert(Opc == ISD::getVecReduceBaseOpcode(ReduceOpc) &&
11172+
"Inconsistent mappings");
1113611173
const SDValue LHS = N->getOperand(0);
1113711174
const SDValue RHS = N->getOperand(1);
1113811175

@@ -11162,13 +11199,13 @@ combineBinOpOfExtractToReduceTree(SDNode *N, SelectionDAG &DAG,
1116211199
EVT ReduceVT = EVT::getVectorVT(*DAG.getContext(), VT, 2);
1116311200
SDValue Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, ReduceVT, SrcVec,
1116411201
DAG.getVectorIdxConstant(0, DL));
11165-
return DAG.getNode(ISD::VECREDUCE_ADD, DL, VT, Vec);
11202+
return DAG.getNode(ReduceOpc, DL, VT, Vec);
1116611203
}
1116711204

1116811205
// Match (binop (reduce (extract_subvector V, 0),
1116911206
// (extract_vector_elt V, sizeof(SubVec))))
1117011207
// into a reduction of one more element from the original vector V.
11171-
if (LHS.getOpcode() != ISD::VECREDUCE_ADD)
11208+
if (LHS.getOpcode() != ReduceOpc)
1117211209
return SDValue();
1117311210

1117411211
SDValue ReduceVec = LHS.getOperand(0);
@@ -11184,7 +11221,7 @@ combineBinOpOfExtractToReduceTree(SDNode *N, SelectionDAG &DAG,
1118411221
EVT ReduceVT = EVT::getVectorVT(*DAG.getContext(), VT, Idx + 1);
1118511222
SDValue Vec = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, ReduceVT, SrcVec,
1118611223
DAG.getVectorIdxConstant(0, DL));
11187-
return DAG.getNode(ISD::VECREDUCE_ADD, DL, VT, Vec);
11224+
return DAG.getNode(ReduceOpc, DL, VT, Vec);
1118811225
}
1118911226
}
1119011227

@@ -11692,6 +11729,8 @@ static SDValue performANDCombine(SDNode *N,
1169211729

1169311730
if (SDValue V = combineBinOpToReduce(N, DAG, Subtarget))
1169411731
return V;
11732+
if (SDValue V = combineBinOpOfExtractToReduceTree(N, DAG, Subtarget))
11733+
return V;
1169511734

1169611735
if (DCI.isAfterLegalizeDAG())
1169711736
if (SDValue V = combineDeMorganOfBoolean(N, DAG))
@@ -11744,6 +11783,8 @@ static SDValue performORCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
1174411783

1174511784
if (SDValue V = combineBinOpToReduce(N, DAG, Subtarget))
1174611785
return V;
11786+
if (SDValue V = combineBinOpOfExtractToReduceTree(N, DAG, Subtarget))
11787+
return V;
1174711788

1174811789
if (DCI.isAfterLegalizeDAG())
1174911790
if (SDValue V = combineDeMorganOfBoolean(N, DAG))
@@ -11795,6 +11836,9 @@ static SDValue performXORCombine(SDNode *N, SelectionDAG &DAG,
1179511836

1179611837
if (SDValue V = combineBinOpToReduce(N, DAG, Subtarget))
1179711838
return V;
11839+
if (SDValue V = combineBinOpOfExtractToReduceTree(N, DAG, Subtarget))
11840+
return V;
11841+
1179811842
// fold (xor (select cond, 0, y), x) ->
1179911843
// (select cond, x, (xor x, y))
1180011844
return combineSelectAndUseCommutative(N, DAG, /*AllOnes*/ false, Subtarget);
@@ -14000,8 +14044,13 @@ SDValue RISCVTargetLowering::PerformDAGCombine(SDNode *N,
1400014044
case ISD::SMAX:
1400114045
case ISD::SMIN:
1400214046
case ISD::FMAXNUM:
14003-
case ISD::FMINNUM:
14004-
return combineBinOpToReduce(N, DAG, Subtarget);
14047+
case ISD::FMINNUM: {
14048+
if (SDValue V = combineBinOpToReduce(N, DAG, Subtarget))
14049+
return V;
14050+
if (SDValue V = combineBinOpOfExtractToReduceTree(N, DAG, Subtarget))
14051+
return V;
14052+
return SDValue();
14053+
}
1400514054
case ISD::SETCC:
1400614055
return performSETCCCombine(N, DAG, Subtarget);
1400714056
case ISD::SIGN_EXTEND_INREG:

llvm/test/CodeGen/AArch64/arm64_32-gep-sink.ll

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3
12
; RUN: opt -codegenprepare -mtriple=arm64_32-apple-ios %s -S -o - | FileCheck %s
23

34
define void @test_simple_sink(ptr %base, i64 %offset) {
4-
; CHECK-LABEL: @test_simple_sink
5-
; CHECK: next:
6-
; CHECK: [[ADDR8:%.*]] = getelementptr i8, ptr %base, i64 %offset
7-
; CHECK: load volatile i1, ptr [[ADDR8]]
5+
; CHECK-LABEL: define void @test_simple_sink(
6+
; CHECK-SAME: ptr [[BASE:%.*]], i64 [[OFFSET:%.*]]) {
7+
; CHECK-NEXT: [[ADDR:%.*]] = getelementptr i1, ptr [[BASE]], i64 [[OFFSET]]
8+
; CHECK-NEXT: [[TST:%.*]] = load i1, ptr [[ADDR]], align 1
9+
; CHECK-NEXT: br i1 [[TST]], label [[NEXT:%.*]], label [[END:%.*]]
10+
; CHECK: next:
11+
; CHECK-NEXT: [[SUNKADDR:%.*]] = getelementptr i8, ptr [[BASE]], i64 [[OFFSET]]
12+
; CHECK-NEXT: [[TMP1:%.*]] = load volatile i1, ptr [[SUNKADDR]], align 1
13+
; CHECK-NEXT: ret void
14+
; CHECK: end:
15+
; CHECK-NEXT: ret void
16+
;
817
%addr = getelementptr i1, ptr %base, i64 %offset
918
%tst = load i1, ptr %addr
1019
br i1 %tst, label %next, label %end
@@ -18,10 +27,18 @@ end:
1827
}
1928

2029
define void @test_inbounds_sink(ptr %base, i64 %offset) {
21-
; CHECK-LABEL: @test_inbounds_sink
22-
; CHECK: next:
23-
; CHECK: [[ADDR8:%.*]] = getelementptr inbounds i8, ptr %base, i64 %offset
24-
; CHECK: load volatile i1, ptr [[ADDR8]]
30+
; CHECK-LABEL: define void @test_inbounds_sink(
31+
; CHECK-SAME: ptr [[BASE:%.*]], i64 [[OFFSET:%.*]]) {
32+
; CHECK-NEXT: [[ADDR:%.*]] = getelementptr inbounds i1, ptr [[BASE]], i64 [[OFFSET]]
33+
; CHECK-NEXT: [[TST:%.*]] = load i1, ptr [[ADDR]], align 1
34+
; CHECK-NEXT: br i1 [[TST]], label [[NEXT:%.*]], label [[END:%.*]]
35+
; CHECK: next:
36+
; CHECK-NEXT: [[SUNKADDR:%.*]] = getelementptr inbounds i8, ptr [[BASE]], i64 [[OFFSET]]
37+
; CHECK-NEXT: [[TMP1:%.*]] = load volatile i1, ptr [[SUNKADDR]], align 1
38+
; CHECK-NEXT: ret void
39+
; CHECK: end:
40+
; CHECK-NEXT: ret void
41+
;
2542
%addr = getelementptr inbounds i1, ptr %base, i64 %offset
2643
%tst = load i1, ptr %addr
2744
br i1 %tst, label %next, label %end
@@ -36,10 +53,20 @@ end:
3653

3754
; No address derived via an add can be guaranteed inbounds
3855
define void @test_add_sink(ptr %base, i64 %offset) {
39-
; CHECK-LABEL: @test_add_sink
40-
; CHECK: next:
41-
; CHECK: [[ADDR8:%.*]] = getelementptr i8, ptr %base, i64 %offset
42-
; CHECK: load volatile i1, ptr [[ADDR8]]
56+
; CHECK-LABEL: define void @test_add_sink(
57+
; CHECK-SAME: ptr [[BASE:%.*]], i64 [[OFFSET:%.*]]) {
58+
; CHECK-NEXT: [[BASE64:%.*]] = ptrtoint ptr [[BASE]] to i64
59+
; CHECK-NEXT: [[ADDR64:%.*]] = add nuw nsw i64 [[BASE64]], [[OFFSET]]
60+
; CHECK-NEXT: [[ADDR:%.*]] = inttoptr i64 [[ADDR64]] to ptr
61+
; CHECK-NEXT: [[TST:%.*]] = load i1, ptr [[ADDR]], align 1
62+
; CHECK-NEXT: br i1 [[TST]], label [[NEXT:%.*]], label [[END:%.*]]
63+
; CHECK: next:
64+
; CHECK-NEXT: [[SUNKADDR:%.*]] = getelementptr i8, ptr [[BASE]], i64 [[OFFSET]]
65+
; CHECK-NEXT: [[TMP1:%.*]] = load volatile i1, ptr [[SUNKADDR]], align 1
66+
; CHECK-NEXT: ret void
67+
; CHECK: end:
68+
; CHECK-NEXT: ret void
69+
;
4370
%base64 = ptrtoint ptr %base to i64
4471
%addr64 = add nsw nuw i64 %base64, %offset
4572
%addr = inttoptr i64 %addr64 to ptr

0 commit comments

Comments
 (0)