Skip to content

Commit 0ed06a7

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3520)
2 parents ea2a868 + c4bedcf commit 0ed06a7

34 files changed

+853
-909
lines changed

.git-blame-ignore-revs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,3 @@ a3a007ad5fa20abc90ead4e1030b481bf109b4cf
143143
b7e332d3f59f567b1999fbcc660d7837cba8e406
144144
6056f942abe83b05406df8b04e95ec37a3d160b5
145145
906295b8a31c8dac5aa845864c0bca9f02f86184
146-
147-
# [mlir][tensor][linalg] Move Pack/UnPack Ops to Linalg
148-
517800e37e8d3a4ee84214bef65e227612c2a98b

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,15 +1931,10 @@ bool Compiler<Emitter>::visitInitList(ArrayRef<const Expr *> Inits,
19311931
dyn_cast<EmbedExpr>(Init->IgnoreParenImpCasts())) {
19321932
PrimType TargetT = classifyPrim(Init->getType());
19331933

1934-
auto Eval = [&](const Expr *Init, unsigned ElemIndex) {
1935-
PrimType InitT = classifyPrim(Init->getType());
1936-
if (!this->visit(Init))
1934+
auto Eval = [&](const IntegerLiteral *IL, unsigned ElemIndex) {
1935+
if (!this->emitConst(IL->getValue(), Init))
19371936
return false;
1938-
if (InitT != TargetT) {
1939-
if (!this->emitCast(InitT, TargetT, E))
1940-
return false;
1941-
}
1942-
return this->emitInitElem(TargetT, ElemIndex, Init);
1937+
return this->emitInitElem(TargetT, ElemIndex, IL);
19431938
};
19441939
if (!EmbedS->doForEachDataElement(Eval, ElementIndex))
19451940
return false;
@@ -2061,21 +2056,36 @@ bool Compiler<Emitter>::visitArrayElemInit(unsigned ElemIndex, const Expr *Init,
20612056
template <class Emitter>
20622057
bool Compiler<Emitter>::visitCallArgs(ArrayRef<const Expr *> Args,
20632058
const FunctionDecl *FuncDecl,
2064-
bool Activate) {
2059+
bool Activate, bool IsOperatorCall) {
20652060
assert(VarScope->getKind() == ScopeKind::Call);
20662061
llvm::BitVector NonNullArgs;
20672062
if (FuncDecl && FuncDecl->hasAttr<NonNullAttr>())
20682063
NonNullArgs = collectNonNullArgs(FuncDecl, Args);
20692064

2065+
bool ExplicitMemberFn = false;
2066+
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(FuncDecl))
2067+
ExplicitMemberFn = MD->isExplicitObjectMemberFunction();
2068+
20702069
unsigned ArgIndex = 0;
20712070
for (const Expr *Arg : Args) {
20722071
if (canClassify(Arg)) {
20732072
if (!this->visit(Arg))
20742073
return false;
20752074
} else {
20762075

2077-
std::optional<unsigned> LocalIndex = allocateLocal(
2078-
Arg, Arg->getType(), /*ExtendingDecl=*/nullptr, ScopeKind::Call);
2076+
DeclTy Source = Arg;
2077+
if (FuncDecl) {
2078+
// Try to use the parameter declaration instead of the argument
2079+
// expression as a source.
2080+
unsigned DeclIndex = ArgIndex - IsOperatorCall + ExplicitMemberFn;
2081+
if (DeclIndex < FuncDecl->getNumParams())
2082+
Source = FuncDecl->getParamDecl(ArgIndex - IsOperatorCall +
2083+
ExplicitMemberFn);
2084+
}
2085+
2086+
std::optional<unsigned> LocalIndex =
2087+
allocateLocal(std::move(Source), Arg->getType(),
2088+
/*ExtendingDecl=*/nullptr, ScopeKind::Call);
20792089
if (!LocalIndex)
20802090
return false;
20812091

@@ -4488,14 +4498,6 @@ template <class Emitter>
44884498
unsigned Compiler<Emitter>::allocateLocalPrimitive(
44894499
DeclTy &&Src, PrimType Ty, bool IsConst, const ValueDecl *ExtendingDecl,
44904500
ScopeKind SC, bool IsConstexprUnknown) {
4491-
// Make sure we don't accidentally register the same decl twice.
4492-
if (const auto *VD =
4493-
dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>())) {
4494-
assert(!P.getGlobal(VD));
4495-
assert(!Locals.contains(VD));
4496-
(void)VD;
4497-
}
4498-
44994501
// FIXME: There are cases where Src.is<Expr*>() is wrong, e.g.
45004502
// (int){12} in C. Consider using Expr::isTemporaryObject() instead
45014503
// or isa<MaterializeTemporaryExpr>().
@@ -4517,19 +4519,11 @@ std::optional<unsigned>
45174519
Compiler<Emitter>::allocateLocal(DeclTy &&Src, QualType Ty,
45184520
const ValueDecl *ExtendingDecl, ScopeKind SC,
45194521
bool IsConstexprUnknown) {
4520-
// Make sure we don't accidentally register the same decl twice.
4521-
if ([[maybe_unused]] const auto *VD =
4522-
dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>())) {
4523-
assert(!P.getGlobal(VD));
4524-
assert(!Locals.contains(VD));
4525-
}
4526-
45274522
const ValueDecl *Key = nullptr;
45284523
const Expr *Init = nullptr;
45294524
bool IsTemporary = false;
45304525
if (auto *VD = dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>())) {
45314526
Key = VD;
4532-
Ty = VD->getType();
45334527

45344528
if (const auto *VarD = dyn_cast<VarDecl>(VD))
45354529
Init = VarD->getInit();
@@ -5166,7 +5160,8 @@ bool Compiler<Emitter>::VisitCallExpr(const CallExpr *E) {
51665160
return false;
51675161
}
51685162

5169-
if (!this->visitCallArgs(Args, FuncDecl, IsAssignmentOperatorCall))
5163+
if (!this->visitCallArgs(Args, FuncDecl, IsAssignmentOperatorCall,
5164+
isa<CXXOperatorCallExpr>(E)))
51705165
return false;
51715166

51725167
// Undo the argument reversal we did earlier.

clang/lib/AST/ByteCode/Compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ class Compiler : public ConstStmtVisitor<Compiler<Emitter>, bool>,
306306
bool visitArrayElemInit(unsigned ElemIndex, const Expr *Init,
307307
OptPrimType InitT);
308308
bool visitCallArgs(ArrayRef<const Expr *> Args, const FunctionDecl *FuncDecl,
309-
bool Activate);
309+
bool Activate, bool IsOperatorCall);
310310

311311
/// Creates a local primitive value.
312312
unsigned allocateLocalPrimitive(DeclTy &&Decl, PrimType Ty, bool IsConst,

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,12 +885,12 @@ bool CheckStore(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
885885
if (!Ptr.block()->isAccessible()) {
886886
if (!CheckLive(S, OpPC, Ptr, AK_Assign))
887887
return false;
888+
if (!CheckExtern(S, OpPC, Ptr))
889+
return false;
888890
return CheckDummy(S, OpPC, Ptr.block(), AK_Assign);
889891
}
890892
if (!CheckLifetime(S, OpPC, Ptr.getLifetime(), AK_Assign))
891893
return false;
892-
if (!CheckExtern(S, OpPC, Ptr))
893-
return false;
894894
if (!CheckRange(S, OpPC, Ptr, AK_Assign))
895895
return false;
896896
if (!CheckActive(S, OpPC, Ptr, AK_Assign))

clang/test/AST/ByteCode/cxx23.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,14 @@ namespace NonLiteralDtorInParam {
309309
~NonLiteral() {} // all23-note {{declared here}}
310310
};
311311
constexpr int F2(NonLiteral N) { // all20-error {{constexpr function's 1st parameter type 'NonLiteral' is not a literal type}} \
312-
// ref23-note {{non-constexpr function '~NonLiteral' cannot be used in a constant expression}}
312+
// all23-note {{non-constexpr function '~NonLiteral' cannot be used in a constant expression}}
313313
return 8;
314314
}
315315

316316

317317
void test() {
318318
NonLiteral L;
319-
constexpr auto D = F2(L); // all23-error {{must be initialized by a constant expression}} \
320-
// expected23-note {{non-constexpr function '~NonLiteral' cannot be used in a constant expression}}
319+
constexpr auto D = F2(L); // all23-error {{must be initialized by a constant expression}}
321320
}
322321
}
323322

clang/test/AST/ByteCode/lifetimes.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,13 @@ namespace CallScope {
9494
int n = 0;
9595
constexpr int f() const { return 0; }
9696
};
97-
constexpr Q *out_of_lifetime(Q q) { return &q; } // both-warning {{address of stack}}
97+
constexpr Q *out_of_lifetime(Q q) { return &q; } // both-warning {{address of stack}} \
98+
// expected-note 2{{declared here}}
9899
constexpr int k3 = out_of_lifetime({})->n; // both-error {{must be initialized by a constant expression}} \
99-
// expected-note {{read of temporary whose lifetime has ended}} \
100-
// expected-note {{temporary created here}} \
100+
// expected-note {{read of variable whose lifetime has ended}} \
101101
// ref-note {{read of object outside its lifetime}}
102102

103103
constexpr int k4 = out_of_lifetime({})->f(); // both-error {{must be initialized by a constant expression}} \
104-
// expected-note {{member call on temporary whose lifetime has ended}} \
105-
// expected-note {{temporary created here}} \
104+
// expected-note {{member call on variable whose lifetime has ended}} \
106105
// ref-note {{member call on object outside its lifetime}}
107106
}

clang/test/SemaCXX/cxx23-invalid-constexpr.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -fsyntax-only -verify=expected -std=c++23 %s
2+
// RUN: %clang_cc1 -fsyntax-only -verify=expected -std=c++23 %s -fexperimental-new-constant-interpreter
23

34
// This test covers modifications made by P2448R2.
45

llvm/docs/LangRef.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12572,10 +12572,11 @@ Example:
1257212572
""""""""
1257312573
This example assumes pointers in address space 1 are 64 bits in size with an
1257412574
address width of 32 bits (``p1:64:64:64:32`` :ref:`datalayout string<langref_datalayout>`)
12575+
1257512576
.. code-block:: llvm
1257612577

12577-
%X = ptrtoaddr ptr addrspace(1) %P to i32 ; extracts low 32 bits of pointer
12578-
%Y = ptrtoaddr <4 x ptr addrspace(1)> %P to <4 x i32>; yields vector of low 32 bits for each pointer
12578+
%X = ptrtoaddr ptr addrspace(1) %P to i32 ; extracts low 32 bits of pointer
12579+
%Y = ptrtoaddr <4 x ptr addrspace(1)> %P to <4 x i32> ; yields vector of low 32 bits for each pointer
1257912580

1258012581

1258112582
.. _i_inttoptr:

llvm/docs/ReleaseNotes.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ Changes to Vectorizers
7777

7878
* Added initial support for copyable elements in SLP, which models copyable
7979
elements as add <element>, 0, i.e. uses identity constants for missing lanes.
80-
* SLP vectorizer supports initial recognition of FMA/FMAD pattern
8180

8281
Changes to the AArch64 Backend
8382
------------------------------

llvm/include/llvm/IR/GenericFloatingPointPredicateUtils.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ template <typename ContextT> class GenericFloatingPointPredicateUtils {
135135
if (Mode.Input != DenormalMode::IEEE)
136136
return {Invalid, fcAllFlags, fcAllFlags};
137137

138+
auto ExactClass = [IsFabs, Src](FPClassTest Mask) {
139+
if (IsFabs)
140+
Mask = llvm::inverse_fabs(Mask);
141+
return exactClass(Src, Mask);
142+
};
143+
138144
switch (Pred) {
139145
case FCmpInst::FCMP_OEQ: // Match x == 0.0
140146
return exactClass(Src, fcZero);
@@ -151,26 +157,24 @@ template <typename ContextT> class GenericFloatingPointPredicateUtils {
151157
case FCmpInst::FCMP_UNO:
152158
return exactClass(Src, fcNan);
153159
case FCmpInst::FCMP_OGT: // x > 0
154-
return exactClass(Src, fcPosSubnormal | fcPosNormal | fcPosInf);
160+
return ExactClass(fcPosSubnormal | fcPosNormal | fcPosInf);
155161
case FCmpInst::FCMP_UGT: // isnan(x) || x > 0
156-
return exactClass(Src, fcPosSubnormal | fcPosNormal | fcPosInf | fcNan);
162+
return ExactClass(fcPosSubnormal | fcPosNormal | fcPosInf | fcNan);
157163
case FCmpInst::FCMP_OGE: // x >= 0
158-
return exactClass(Src, fcPositive | fcNegZero);
164+
return ExactClass(fcPositive | fcNegZero);
159165
case FCmpInst::FCMP_UGE: // isnan(x) || x >= 0
160-
return exactClass(Src, fcPositive | fcNegZero | fcNan);
166+
return ExactClass(fcPositive | fcNegZero | fcNan);
161167
case FCmpInst::FCMP_OLT: // x < 0
162-
return exactClass(Src, fcNegSubnormal | fcNegNormal | fcNegInf);
168+
return ExactClass(fcNegSubnormal | fcNegNormal | fcNegInf);
163169
case FCmpInst::FCMP_ULT: // isnan(x) || x < 0
164-
return exactClass(Src, fcNegSubnormal | fcNegNormal | fcNegInf | fcNan);
170+
return ExactClass(fcNegSubnormal | fcNegNormal | fcNegInf | fcNan);
165171
case FCmpInst::FCMP_OLE: // x <= 0
166-
return exactClass(Src, fcNegative | fcPosZero);
172+
return ExactClass(fcNegative | fcPosZero);
167173
case FCmpInst::FCMP_ULE: // isnan(x) || x <= 0
168-
return exactClass(Src, fcNegative | fcPosZero | fcNan);
174+
return ExactClass(fcNegative | fcPosZero | fcNan);
169175
default:
170176
llvm_unreachable("all compare types are handled");
171177
}
172-
173-
return {Invalid, fcAllFlags, fcAllFlags};
174178
}
175179

176180
const bool IsDenormalRHS = (OrigClass & fcSubnormal) == OrigClass;

0 commit comments

Comments
 (0)