Skip to content

Commit 2934438

Browse files
authored
Merge branch 'main' into users/rampitec/09-19-_amdgpu_ds_read2_ds_write2_gfx1250_tests._nfc
2 parents 0cd0ffa + d38979d commit 2934438

File tree

130 files changed

+5806
-1984
lines changed

Some content is hidden

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

130 files changed

+5806
-1984
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ Improvements to Clang's diagnostics
271271
Moved the warning for a missing (though implied) attribute on a redeclaration into this group.
272272
Added a new warning in this group for the case where the attribute is missing/implicit on
273273
an override of a virtual method.
274+
- Implemented diagnostics when retrieving the tuple size for types where its specialization of `std::tuple_size`
275+
produces an invalid size (either negative or greater than the implementation limit). (#GH159563)
274276
- Fixed fix-it hint for fold expressions. Clang now correctly places the suggested right
275277
parenthesis when diagnosing malformed fold expressions. (#GH151787)
276278
- Added fix-it hint for when scoped enumerations require explicit conversions for binary operations. (#GH24265)
@@ -356,8 +358,8 @@ Bug Fixes in This Version
356358
and vector of 4 ``float`` values. (#GH155405)
357359
- Fixed inconsistent shadow warnings for lambda capture of structured bindings.
358360
Previously, ``[val = val]`` (regular parameter) produced no warnings with ``-Wshadow``
359-
while ``[a = a]`` (where ``a`` is from ``auto [a, b] = std::make_pair(1, 2)``)
360-
incorrectly produced warnings. Both cases now consistently show no warnings with
361+
while ``[a = a]`` (where ``a`` is from ``auto [a, b] = std::make_pair(1, 2)``)
362+
incorrectly produced warnings. Both cases now consistently show no warnings with
361363
``-Wshadow`` and show uncaptured-local warnings with ``-Wshadow-all``. (#GH68605)
362364
- Fixed a failed assertion with a negative limit parameter value inside of
363365
``__has_embed``. (#GH157842)

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,9 @@ def err_decomp_decl_std_tuple_element_not_specialized : Error<
638638
def err_decomp_decl_std_tuple_size_not_constant : Error<
639639
"cannot decompose this type; 'std::tuple_size<%0>::value' "
640640
"is not a valid integral constant expression">;
641+
def err_decomp_decl_std_tuple_size_invalid
642+
: Error<"cannot decompose this type; 'std::tuple_size<%0>::value' "
643+
"is not a valid size: %1">;
641644
def note_in_binding_decl_init : Note<
642645
"in implicit initialization of binding declaration %0">;
643646
def err_arg_is_not_destructurable : Error<

clang/include/clang/CIR/Dialect/IR/CIRAttrConstraints.td

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,27 @@ def CIR_AnyIntOrFloatAttr : AnyAttrOf<[CIR_AnyIntAttr, CIR_AnyFPAttr],
3838
string cppType = "::mlir::TypedAttr";
3939
}
4040

41+
//===----------------------------------------------------------------------===//
42+
// GlobalViewAttr constraints
43+
//===----------------------------------------------------------------------===//
44+
45+
def CIR_AnyGlobalViewAttr : CIR_AttrConstraint<"::cir::GlobalViewAttr", "GlobalView attribute">;
46+
47+
def CIR_AnyIntOrGlobalViewAttr : AnyAttrOf<[CIR_AnyIntAttr, CIR_AnyGlobalViewAttr],
48+
"integer or global view attribute"> {
49+
string cppType = "::mlir::TypedAttr";
50+
}
51+
4152
//===----------------------------------------------------------------------===//
4253
// ArrayAttr constraints
4354
//===----------------------------------------------------------------------===//
4455

4556
def CIR_IntArrayAttr : TypedArrayAttrBase<CIR_AnyIntAttr,
4657
"integer array attribute">;
4758

59+
def CIR_IntOrGlobalViewArrayAttr : TypedArrayAttrBase<CIR_AnyIntOrGlobalViewAttr,
60+
"integer or global view array attribute">{
61+
string cppType = "::mlir::ArrayAttr";
62+
}
63+
4864
#endif // CLANG_CIR_DIALECT_IR_CIRATTRCONSTRAINTS_TD

clang/include/clang/CIR/Dialect/IR/CIRAttrs.td

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,4 +779,56 @@ def CIR_AddressPointAttr : CIR_Attr<"AddressPoint", "address_point"> {
779779
}];
780780
}
781781

782+
//===----------------------------------------------------------------------===//
783+
// TypeInfoAttr
784+
//===----------------------------------------------------------------------===//
785+
786+
def CIR_TypeInfoAttr : CIR_Attr<"TypeInfo", "typeinfo", [TypedAttrInterface]> {
787+
let summary = "Represents a typeinfo used for RTTI";
788+
let description = [{
789+
The typeinfo data for a given class is stored into an ArrayAttr. The
790+
layout is determined by the C++ ABI used (clang only implements
791+
itanium on CIRGen).
792+
793+
The verifier enforces that the output type is always a `!cir.record`,
794+
and that the ArrayAttr element types match the equivalent member type
795+
for the resulting record, i.e, a GlobalViewAttr for symbol reference or
796+
an IntAttr for flags.
797+
798+
Example:
799+
800+
```
801+
cir.global "private" external @_ZTVN10__cxxabiv120__si_class_type_infoE
802+
: !cir.ptr<i32>
803+
804+
!rec_anon_struct = !cir.record<struct {!cir.ptr<!u8i>, !cir.ptr<!u8i>,
805+
!cir.ptr<!u8i>}>
806+
807+
cir.global constant external @type_info = #cir.typeinfo<{
808+
#cir.global_view<@_ZTVN10__cxxabiv120__si_class_type_infoE, [2 : i32]>
809+
: !cir.ptr<!u8i>, #cir.global_view<@_ZTS1B> : !cir.ptr<!u8i>,
810+
#cir.global_view<@_ZTI1A> : !cir.ptr<!u8i>}> : !rec_anon_struct
811+
```
812+
}];
813+
814+
let parameters = (ins
815+
AttributeSelfTypeParameter<"">:$type,
816+
CIR_IntOrGlobalViewArrayAttr:$data
817+
);
818+
819+
let builders = [
820+
AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
821+
"mlir::ArrayAttr":$data), [{
822+
return $_get(type.getContext(), type, data);
823+
}]>
824+
];
825+
826+
// Checks record element types should match the array for every equivalent
827+
// element type.
828+
let genVerifyDecl = 1;
829+
let assemblyFormat = [{
830+
`<` custom<RecordMembers>($data) `>`
831+
}];
832+
}
833+
782834
#endif // CLANG_CIR_DIALECT_IR_CIRATTRS_TD

clang/lib/AST/ExprClassification.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,13 @@ static Cl::Kinds ClassifyMemberExpr(ASTContext &Ctx, const MemberExpr *E) {
601601
static Cl::Kinds ClassifyBinaryOp(ASTContext &Ctx, const BinaryOperator *E) {
602602
assert(Ctx.getLangOpts().CPlusPlus &&
603603
"This is only relevant for C++.");
604+
605+
// For binary operators which are unknown due to type dependence, the
606+
// convention is to classify them as a prvalue. This does not matter much, but
607+
// it needs to agree with how they are created.
608+
if (E->getType() == Ctx.DependentTy)
609+
return Cl::CL_PRValue;
610+
604611
// C++ [expr.ass]p1: All [...] return an lvalue referring to the left operand.
605612
// Except we override this for writes to ObjC properties.
606613
if (E->isAssignmentOp())

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,8 +1063,20 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
10631063

10641064
mlir::Value VisitBinLAnd(const clang::BinaryOperator *e) {
10651065
if (e->getType()->isVectorType()) {
1066-
assert(!cir::MissingFeatures::vectorType());
1067-
return {};
1066+
mlir::Location loc = cgf.getLoc(e->getExprLoc());
1067+
auto vecTy = mlir::cast<cir::VectorType>(cgf.convertType(e->getType()));
1068+
mlir::Value zeroValue = builder.getNullValue(vecTy.getElementType(), loc);
1069+
SmallVector<mlir::Value, 16> elements(vecTy.getSize(), zeroValue);
1070+
auto zeroVec = cir::VecCreateOp::create(builder, loc, vecTy, elements);
1071+
1072+
mlir::Value lhs = Visit(e->getLHS());
1073+
mlir::Value rhs = Visit(e->getRHS());
1074+
1075+
auto cmpOpKind = cir::CmpOpKind::ne;
1076+
lhs = cir::VecCmpOp::create(builder, loc, vecTy, cmpOpKind, lhs, zeroVec);
1077+
rhs = cir::VecCmpOp::create(builder, loc, vecTy, cmpOpKind, rhs, zeroVec);
1078+
mlir::Value vecOr = builder.createAnd(loc, lhs, rhs);
1079+
return builder.createIntCast(vecOr, vecTy);
10681080
}
10691081

10701082
assert(!cir::MissingFeatures::instrumentation());

clang/lib/CIR/Dialect/IR/CIRDialect.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
#include "llvm/ADT/SmallSet.h"
2727
#include "llvm/Support/LogicalResult.h"
2828

29-
#include <numeric>
30-
3129
using namespace mlir;
3230
using namespace cir;
3331

@@ -342,8 +340,8 @@ static LogicalResult checkConstantTypes(mlir::Operation *op, mlir::Type opType,
342340

343341
if (mlir::isa<cir::ConstArrayAttr, cir::ConstVectorAttr,
344342
cir::ConstComplexAttr, cir::ConstRecordAttr,
345-
cir::GlobalViewAttr, cir::PoisonAttr, cir::VTableAttr>(
346-
attrType))
343+
cir::GlobalViewAttr, cir::PoisonAttr, cir::TypeInfoAttr,
344+
cir::VTableAttr>(attrType))
347345
return success();
348346

349347
assert(isa<TypedAttr>(attrType) && "What else could we be looking at here?");
@@ -2741,6 +2739,20 @@ LogicalResult cir::AtomicCmpXchg::verify() {
27412739
return success();
27422740
}
27432741

2742+
//===----------------------------------------------------------------------===//
2743+
// TypeInfoAttr
2744+
//===----------------------------------------------------------------------===//
2745+
2746+
LogicalResult cir::TypeInfoAttr::verify(
2747+
::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError,
2748+
::mlir::Type type, ::mlir::ArrayAttr typeInfoData) {
2749+
2750+
if (cir::ConstRecordAttr::verify(emitError, type, typeInfoData).failed())
2751+
return failure();
2752+
2753+
return success();
2754+
}
2755+
27442756
//===----------------------------------------------------------------------===//
27452757
// TableGen'd op method definitions
27462758
//===----------------------------------------------------------------------===//

clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class CIRAttrToValue {
235235
mlir::Value visitCirAttr(cir::ConstRecordAttr attr);
236236
mlir::Value visitCirAttr(cir::ConstVectorAttr attr);
237237
mlir::Value visitCirAttr(cir::GlobalViewAttr attr);
238+
mlir::Value visitCirAttr(cir::TypeInfoAttr attr);
238239
mlir::Value visitCirAttr(cir::VTableAttr attr);
239240
mlir::Value visitCirAttr(cir::ZeroAttr attr);
240241

@@ -521,6 +522,21 @@ mlir::Value CIRAttrToValue::visitCirAttr(cir::GlobalViewAttr globalAttr) {
521522
llvm_unreachable("Expecting pointer or integer type for GlobalViewAttr");
522523
}
523524

525+
// TypeInfoAttr visitor.
526+
mlir::Value CIRAttrToValue::visitCirAttr(cir::TypeInfoAttr typeInfoAttr) {
527+
mlir::Type llvmTy = converter->convertType(typeInfoAttr.getType());
528+
mlir::Location loc = parentOp->getLoc();
529+
mlir::Value result = mlir::LLVM::UndefOp::create(rewriter, loc, llvmTy);
530+
531+
for (auto [idx, elt] : llvm::enumerate(typeInfoAttr.getData())) {
532+
mlir::Value init = visit(elt);
533+
result =
534+
mlir::LLVM::InsertValueOp::create(rewriter, loc, result, init, idx);
535+
}
536+
537+
return result;
538+
}
539+
524540
// VTableAttr visitor.
525541
mlir::Value CIRAttrToValue::visitCirAttr(cir::VTableAttr vtableArr) {
526542
mlir::Type llvmTy = converter->convertType(vtableArr.getType());

clang/lib/Driver/ToolChains/UEFI.cpp

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,29 +57,44 @@ void tools::uefi::Linker::ConstructJob(Compilation &C, const JobAction &JA,
5757
assert((Output.isFilename() || Output.isNothing()) && "invalid output");
5858
if (Output.isFilename())
5959
CmdArgs.push_back(
60-
Args.MakeArgString(std::string("-out:") + Output.getFilename()));
60+
Args.MakeArgString(std::string("/out:") + Output.getFilename()));
6161

62-
CmdArgs.push_back("-nologo");
63-
64-
// TODO: Other UEFI binary subsystems that are currently unsupported:
65-
// efi_boot_service_driver, efi_rom, efi_runtime_driver.
66-
CmdArgs.push_back("-subsystem:efi_application");
62+
CmdArgs.push_back("/nologo");
6763

6864
// Default entry function name according to the TianoCore reference
69-
// implementation is EfiMain.
70-
// TODO: Provide a flag to override the entry function name.
71-
CmdArgs.push_back("-entry:EfiMain");
65+
// implementation is EfiMain. -Wl,/subsystem:... or -Wl,/entry:... can
66+
// override these since they will be added later in AddLinkerInputs.
67+
CmdArgs.push_back("/subsystem:efi_application");
68+
CmdArgs.push_back("/entry:EfiMain");
7269

7370
// "Terminal Service Aware" flag is not needed for UEFI applications.
74-
CmdArgs.push_back("-tsaware:no");
71+
CmdArgs.push_back("/tsaware:no");
7572

7673
if (Args.hasArg(options::OPT_g_Group, options::OPT__SLASH_Z7))
77-
CmdArgs.push_back("-debug");
74+
CmdArgs.push_back("/debug");
7875

7976
Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
8077

8178
AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
8279

80+
// Sample these options first so they are claimed even under -nostdlib et al.
81+
bool NoLibc = Args.hasArg(options::OPT_nolibc);
82+
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
83+
options::OPT_r)) {
84+
addSanitizerRuntimes(TC, Args, CmdArgs);
85+
86+
addXRayRuntime(TC, Args, CmdArgs);
87+
88+
TC.addProfileRTLibs(Args, CmdArgs);
89+
90+
// TODO: When compiler-rt/lib/builtins is ready, enable this call:
91+
// AddRunTimeLibs(TC, TC.getDriver(), CmdArgs, Args);
92+
93+
if (!NoLibc) {
94+
// TODO: When there is a libc ready, add it here.
95+
}
96+
}
97+
8398
// This should ideally be handled by ToolChain::GetLinkerPath but we need
8499
// to special case some linker paths. In the case of lld, we need to
85100
// translate 'lld' into 'lld-link'.

0 commit comments

Comments
 (0)