Skip to content

Commit 3b454e2

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3459)
2 parents daa1881 + c2698ac commit 3b454e2

File tree

260 files changed

+10095
-2832
lines changed

Some content is hidden

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

260 files changed

+10095
-2832
lines changed

.ci/compute_projects_test.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,34 @@ def test_ci(self):
284284
"check-cxx check-cxxabi check-unwind",
285285
)
286286

287+
def test_windows_ci(self):
288+
env_variables = compute_projects.get_env_variables(
289+
[".ci/compute_projects.py"], "Windows"
290+
)
291+
self.assertEqual(
292+
env_variables["projects_to_build"],
293+
"clang;clang-tools-extra;libclc;lld;llvm;mlir;polly",
294+
)
295+
self.assertEqual(
296+
env_variables["project_check_targets"],
297+
"check-clang check-clang-cir check-clang-tools check-lld check-llvm check-mlir check-polly",
298+
)
299+
self.assertEqual(
300+
env_variables["runtimes_to_build"],
301+
"libcxx;libcxxabi;libunwind",
302+
)
303+
self.assertEqual(
304+
env_variables["runtimes_check_targets"],
305+
"",
306+
)
307+
# TODO(boomanaiden154): We should not be emitting these on Windows.
308+
# It does not currently impact anything because we do not build the
309+
# runtimes on Windows though.
310+
self.assertEqual(
311+
env_variables["runtimes_check_targets_needs_reconfig"],
312+
"check-cxx check-cxxabi check-unwind",
313+
)
314+
287315
def test_lldb(self):
288316
env_variables = compute_projects.get_env_variables(
289317
["lldb/CMakeLists.txt"], "Linux"

clang/docs/ReleaseNotes.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,26 @@ C++ Specific Potentially Breaking Changes
4343
regressions if your build system supports two-phase compilation model but haven't support
4444
reduced BMI or it is a compiler bug or a bug in users code.
4545

46+
- Clang now correctly diagnoses during constant expression evaluation undefined behavior due to member
47+
pointer access to a member which is not a direct or indirect member of the most-derived object
48+
of the accessed object but is instead located directly in a sibling class to one of the classes
49+
along the inheritance hierarchy of the most-derived object as ill-formed.
50+
Other scenarios in which the member is not member of the most derived object were already
51+
diagnosed previously. (#GH150709)
52+
53+
.. code-block:: c++
54+
55+
struct A {};
56+
struct B : A {};
57+
struct C : A { constexpr int foo() const { return 1; } };
58+
constexpr A a;
59+
constexpr B b;
60+
constexpr C c;
61+
constexpr auto mp = static_cast<int(A::*)() const>(&C::foo);
62+
static_assert((a.*mp)() == 1); // continues to be rejected
63+
static_assert((b.*mp)() == 1); // newly rejected
64+
static_assert((c.*mp)() == 1); // accepted
65+
4666
ABI Changes in This Version
4767
---------------------------
4868

clang/include/clang/AST/OpenACCClause.h

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -878,23 +878,46 @@ class OpenACCPrivateClause final
878878

879879
class OpenACCFirstPrivateClause final
880880
: public OpenACCClauseWithVarList,
881-
private llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *> {
881+
private llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *,
882+
VarDecl *> {
882883
friend TrailingObjects;
883884

884885
OpenACCFirstPrivateClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
885-
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
886+
ArrayRef<Expr *> VarList,
887+
ArrayRef<VarDecl *> InitRecipes,
888+
SourceLocation EndLoc)
886889
: OpenACCClauseWithVarList(OpenACCClauseKind::FirstPrivate, BeginLoc,
887890
LParenLoc, EndLoc) {
888-
setExprs(getTrailingObjects(VarList.size()), VarList);
891+
assert(VarList.size() == InitRecipes.size());
892+
setExprs(getTrailingObjects<Expr *>(VarList.size()), VarList);
893+
llvm::uninitialized_copy(InitRecipes, getTrailingObjects<VarDecl *>());
889894
}
890895

891896
public:
892897
static bool classof(const OpenACCClause *C) {
893898
return C->getClauseKind() == OpenACCClauseKind::FirstPrivate;
894899
}
900+
901+
// Gets a list of 'made up' `VarDecl` objects that can be used by codegen to
902+
// ensure that we properly initialize each of these variables.
903+
ArrayRef<VarDecl *> getInitRecipes() {
904+
return ArrayRef<VarDecl *>{getTrailingObjects<VarDecl *>(),
905+
getExprs().size()};
906+
}
907+
908+
ArrayRef<VarDecl *> getInitRecipes() const {
909+
return ArrayRef<VarDecl *>{getTrailingObjects<VarDecl *>(),
910+
getExprs().size()};
911+
}
912+
895913
static OpenACCFirstPrivateClause *
896914
Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
897-
ArrayRef<Expr *> VarList, SourceLocation EndLoc);
915+
ArrayRef<Expr *> VarList, ArrayRef<VarDecl *> InitRecipes,
916+
SourceLocation EndLoc);
917+
918+
size_t numTrailingObjects(OverloadToken<Expr *>) const {
919+
return getExprs().size();
920+
}
898921
};
899922

900923
class OpenACCDevicePtrClause final

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ BUILTIN(__builtin_amdgcn_raw_buffer_load_b64, "V2UiQbiiIi", "n")
163163
BUILTIN(__builtin_amdgcn_raw_buffer_load_b96, "V3UiQbiiIi", "n")
164164
BUILTIN(__builtin_amdgcn_raw_buffer_load_b128, "V4UiQbiiIi", "n")
165165

166+
BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_add_i32, "iiQbiiIi", "t")
167+
168+
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_f32, "ffQbiiIi", "t", "atomic-fadd-rtn-insts")
169+
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_v2f16, "V2hV2hQbiiIi", "t", "atomic-buffer-global-pk-add-f16-insts")
170+
171+
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f32, "ffQbiiIi", "t", "atomic-fmin-fmax-global-f32")
172+
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f32, "ffQbiiIi", "t", "atomic-fmin-fmax-global-f32")
173+
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f64, "ddQbiiIi", "t", "atomic-fmin-fmax-global-f64")
174+
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f64, "ddQbiiIi", "t", "atomic-fmin-fmax-global-f64")
175+
166176
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_load_lds, "vQbv*3IUiiiIiIi", "t", "vmem-to-lds-load-insts")
167177
TARGET_BUILTIN(__builtin_amdgcn_struct_ptr_buffer_load_lds, "vQbv*3IUiiiiIiIi", "t", "vmem-to-lds-load-insts")
168178

@@ -800,6 +810,8 @@ TARGET_BUILTIN(__builtin_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4, "V8fIiV16iIiV
800810
TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x32_f16, "V8fIbV16hIbV16hIsV8fIbIb", "nc", "gfx1250-insts,wavefrontsize32")
801811
TARGET_BUILTIN(__builtin_amdgcn_wmma_f16_16x16x32_f16, "V8hIbV16hIbV16hIsV8hIbIb", "nc", "gfx1250-insts,wavefrontsize32")
802812
TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_32x16x128_f4, "V16fV16iV8iIsV16f", "nc", "gfx1250-insts,wavefrontsize32")
813+
TARGET_BUILTIN(__builtin_amdgcn_wmma_scale_f32_32x16x128_f4, "V16fV16iV8iIsV16fIiIiiIiIiiIbIb", "nc", "gfx1250-insts,wavefrontsize32")
814+
TARGET_BUILTIN(__builtin_amdgcn_wmma_scale16_f32_32x16x128_f4, "V16fV16iV8iIsV16fIiIiLiIiIiLiIbIb", "nc", "gfx1250-insts,wavefrontsize32")
803815
TARGET_BUILTIN(__builtin_amdgcn_swmmac_f32_16x16x64_bf16, "V8fIbV16yIbV32yV8fiIbIb", "nc", "gfx1250-insts,wavefrontsize32")
804816
TARGET_BUILTIN(__builtin_amdgcn_swmmac_bf16_16x16x64_bf16, "V8yIbV16yIbV32yV8yiIbIb", "nc", "gfx1250-insts,wavefrontsize32")
805817
TARGET_BUILTIN(__builtin_amdgcn_swmmac_bf16f32_16x16x64_bf16, "V8fIbV16yIbV32yV8fiIbIb", "nc", "gfx1250-insts,wavefrontsize32")

clang/include/clang/Sema/SemaOpenACC.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,9 @@ class SemaOpenACC : public SemaBase {
238238
ArrayRef<const OpenACCClause *> Clauses);
239239

240240
// Creates a VarDecl with a proper default init for the purposes of a
241-
// `private` clause, so it can be used to generate a recipe later.
242-
VarDecl *CreateInitRecipe(const Expr *VarExpr);
241+
// `private`/'firstprivate'/'reduction' clause, so it can be used to generate
242+
// a recipe later.
243+
VarDecl *CreateInitRecipe(OpenACCClauseKind CK, const Expr *VarExpr);
243244

244245
public:
245246
ComputeConstructInfo &getActiveComputeConstructInfo() {

clang/lib/AST/ExprConstant.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5035,6 +5035,9 @@ static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info,
50355035
// This is a member of some derived class. Truncate LV appropriately.
50365036
// The end of the derived-to-base path for the base object must match the
50375037
// derived-to-base path for the member pointer.
5038+
// C++23 [expr.mptr.oper]p4:
5039+
// If the result of E1 is an object [...] whose most derived object does
5040+
// not contain the member to which E2 refers, the behavior is undefined.
50385041
if (LV.Designator.MostDerivedPathLength + MemPtr.Path.size() >
50395042
LV.Designator.Entries.size()) {
50405043
Info.FFDiag(RHS);
@@ -5051,6 +5054,24 @@ static const ValueDecl *HandleMemberPointerAccess(EvalInfo &Info,
50515054
return nullptr;
50525055
}
50535056
}
5057+
// MemPtr.Path only contains the base classes of the class directly
5058+
// containing the member E2. It is still necessary to check that the class
5059+
// directly containing the member E2 lies on the derived-to-base path of E1
5060+
// to avoid incorrectly permitting member pointer access into a sibling
5061+
// class of the class containing the member E2. If this class would
5062+
// correspond to the most-derived class of E1, it either isn't contained in
5063+
// LV.Designator.Entries or the corresponding entry refers to an array
5064+
// element instead. Therefore get the most derived class directly in this
5065+
// case. Otherwise the previous entry should correpond to this class.
5066+
const CXXRecordDecl *LastLVDecl =
5067+
(PathLengthToMember > LV.Designator.MostDerivedPathLength)
5068+
? getAsBaseClass(LV.Designator.Entries[PathLengthToMember - 1])
5069+
: LV.Designator.MostDerivedType->getAsCXXRecordDecl();
5070+
const CXXRecordDecl *LastMPDecl = MemPtr.getContainingRecord();
5071+
if (LastLVDecl->getCanonicalDecl() != LastMPDecl->getCanonicalDecl()) {
5072+
Info.FFDiag(RHS);
5073+
return nullptr;
5074+
}
50545075

50555076
// Truncate the lvalue to the appropriate derived class.
50565077
if (!CastToDerivedClass(Info, RHS, LV, MemPtr.getContainingRecord(),

clang/lib/AST/OpenACCClause.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,11 +329,13 @@ OpenACCPrivateClause::Create(const ASTContext &C, SourceLocation BeginLoc,
329329

330330
OpenACCFirstPrivateClause *OpenACCFirstPrivateClause::Create(
331331
const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
332-
ArrayRef<Expr *> VarList, SourceLocation EndLoc) {
333-
void *Mem = C.Allocate(
334-
OpenACCFirstPrivateClause::totalSizeToAlloc<Expr *>(VarList.size()));
335-
return new (Mem)
336-
OpenACCFirstPrivateClause(BeginLoc, LParenLoc, VarList, EndLoc);
332+
ArrayRef<Expr *> VarList, ArrayRef<VarDecl *> InitRecipes,
333+
SourceLocation EndLoc) {
334+
void *Mem =
335+
C.Allocate(OpenACCFirstPrivateClause::totalSizeToAlloc<Expr *, VarDecl *>(
336+
VarList.size(), InitRecipes.size()));
337+
return new (Mem) OpenACCFirstPrivateClause(BeginLoc, LParenLoc, VarList,
338+
InitRecipes, EndLoc);
337339
}
338340

339341
OpenACCAttachClause *OpenACCAttachClause::Create(const ASTContext &C,

clang/lib/AST/StmtProfile.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2644,6 +2644,9 @@ void OpenACCClauseProfiler::VisitPrivateClause(
26442644
void OpenACCClauseProfiler::VisitFirstPrivateClause(
26452645
const OpenACCFirstPrivateClause &Clause) {
26462646
VisitClauseWithVarList(Clause);
2647+
2648+
for (auto *VD : Clause.getInitRecipes())
2649+
Profiler.VisitDecl(VD);
26472650
}
26482651

26492652
void OpenACCClauseProfiler::VisitAttachClause(

clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -923,6 +923,8 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
923923
case AMDGPU::BI__builtin_amdgcn_wmma_f32_32x16x128_f4:
924924
case AMDGPU::BI__builtin_amdgcn_wmma_scale_f32_16x16x128_f8f6f4:
925925
case AMDGPU::BI__builtin_amdgcn_wmma_scale16_f32_16x16x128_f8f6f4:
926+
case AMDGPU::BI__builtin_amdgcn_wmma_scale_f32_32x16x128_f4:
927+
case AMDGPU::BI__builtin_amdgcn_wmma_scale16_f32_32x16x128_f4:
926928
case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x64_f16:
927929
case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x64_bf16:
928930
case AMDGPU::BI__builtin_amdgcn_swmmac_f16_16x16x64_f16:
@@ -1201,6 +1203,14 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
12011203
ArgsForMatchingMatrixTypes = {3, 0, 1};
12021204
BuiltinWMMAOp = Intrinsic::amdgcn_wmma_f32_32x16x128_f4;
12031205
break;
1206+
case AMDGPU::BI__builtin_amdgcn_wmma_scale_f32_32x16x128_f4:
1207+
ArgsForMatchingMatrixTypes = {3, 0, 1};
1208+
BuiltinWMMAOp = Intrinsic::amdgcn_wmma_scale_f32_32x16x128_f4;
1209+
break;
1210+
case AMDGPU::BI__builtin_amdgcn_wmma_scale16_f32_32x16x128_f4:
1211+
ArgsForMatchingMatrixTypes = {3, 0, 1};
1212+
BuiltinWMMAOp = Intrinsic::amdgcn_wmma_scale16_f32_32x16x128_f4;
1213+
break;
12041214
case AMDGPU::BI__builtin_amdgcn_swmmac_f32_16x16x64_f16:
12051215
ArgsForMatchingMatrixTypes = {4, 1, 3, 5};
12061216
BuiltinWMMAOp = Intrinsic::amdgcn_swmmac_f32_16x16x64_f16;
@@ -1526,6 +1536,21 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
15261536
F, {EmitScalarExpr(E->getArg(0)), EmitScalarExpr(E->getArg(1)),
15271537
EmitScalarExpr(E->getArg(2)), EmitScalarExpr(E->getArg(3))});
15281538
}
1539+
case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_add_i32:
1540+
return emitBuiltinWithOneOverloadedType<5>(
1541+
*this, E, Intrinsic::amdgcn_raw_ptr_buffer_atomic_add);
1542+
case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_f32:
1543+
case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_v2f16:
1544+
return emitBuiltinWithOneOverloadedType<5>(
1545+
*this, E, Intrinsic::amdgcn_raw_ptr_buffer_atomic_fadd);
1546+
case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f32:
1547+
case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f64:
1548+
return emitBuiltinWithOneOverloadedType<5>(
1549+
*this, E, Intrinsic::amdgcn_raw_ptr_buffer_atomic_fmin);
1550+
case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f32:
1551+
case AMDGPU::BI__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f64:
1552+
return emitBuiltinWithOneOverloadedType<5>(
1553+
*this, E, Intrinsic::amdgcn_raw_ptr_buffer_atomic_fmax);
15291554
case AMDGPU::BI__builtin_amdgcn_s_prefetch_data:
15301555
return emitBuiltinWithOneOverloadedType<2>(
15311556
*this, E, Intrinsic::amdgcn_s_prefetch_data);

0 commit comments

Comments
 (0)