Skip to content

Commit 5087fac

Browse files
committed
merge main into amd-staging
Change-Id: Ic18a488c4aa379d2d71488dd2a34c763860a6f68
2 parents 8c1b013 + 6776d65 commit 5087fac

File tree

181 files changed

+7830
-2687
lines changed

Some content is hidden

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

181 files changed

+7830
-2687
lines changed

clang-tools-extra/clang-tidy/tool/run-clang-tidy.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import time
5050
import traceback
5151
from types import ModuleType
52-
from typing import Any, Awaitable, Callable, List, Optional, Tuple, TypeVar
52+
from typing import Any, Awaitable, Callable, List, Optional, TypeVar
5353

5454

5555
yaml: Optional[ModuleType] = None
@@ -621,4 +621,7 @@ async def main() -> None:
621621

622622

623623
if __name__ == "__main__":
624-
asyncio.run(main())
624+
try:
625+
asyncio.run(main())
626+
except KeyboardInterrupt:
627+
pass

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ The improvements are...
9595
Improvements to clang-tidy
9696
--------------------------
9797

98+
- Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
99+
happening on certain platforms when interrupting the script.
100+
98101
New checks
99102
^^^^^^^^^^
100103

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ C++ Language Changes
108108
- Allow single element access of GCC vector/ext_vector_type object to be
109109
constant expression. Supports the `V.xyzw` syntax and other tidbits
110110
as seen in OpenCL. Selecting multiple elements is left as a future work.
111-
- Implement `CWG1815 <https://wg21.link/CWG1815>`_. Support lifetime extension
112-
of temporary created by aggregate initialization using a default member
113-
initializer.
114111

115112
- Accept C++26 user-defined ``static_assert`` messages in C++11 as an extension.
116113

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4763,6 +4763,12 @@ def HLSLSaturate : LangBuiltin<"HLSL_LANG"> {
47634763
let Prototype = "void(...)";
47644764
}
47654765

4766+
def HLSLSelect : LangBuiltin<"HLSL_LANG"> {
4767+
let Spellings = ["__builtin_hlsl_select"];
4768+
let Attributes = [NoThrow, Const];
4769+
let Prototype = "void(...)";
4770+
}
4771+
47664772
// Builtins for XRay.
47674773
def XRayCustomEvent : Builtin {
47684774
let Spellings = ["__xray_customevent"];

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9209,6 +9209,9 @@ def err_typecheck_expect_scalar_operand : Error<
92099209
"operand of type %0 where arithmetic or pointer type is required">;
92109210
def err_typecheck_cond_incompatible_operands : Error<
92119211
"incompatible operand types%diff{ ($ and $)|}0,1">;
9212+
def err_typecheck_expect_scalar_or_vector : Error<
9213+
"invalid operand of type %0 where %1 or "
9214+
"a vector of such type is required">;
92129215
def err_typecheck_expect_flt_or_vector : Error<
92139216
"invalid operand of type %0 where floating, complex or "
92149217
"a vector of such types is required">;
@@ -10162,6 +10165,13 @@ def warn_dangling_pointer_assignment : Warning<
1016210165
"will be destroyed at the end of the full-expression">,
1016310166
InGroup<DanglingAssignment>;
1016410167

10168+
def warn_unsupported_lifetime_extension : Warning<
10169+
"lifetime extension of "
10170+
"%select{temporary|backing array of initializer list}0 created "
10171+
"by aggregate initialization using a default member initializer "
10172+
"is not yet supported; lifetime of %select{temporary|backing array}0 "
10173+
"will end at the end of the full-expression">, InGroup<Dangling>;
10174+
1016510175
// For non-floating point, expressions of the form x == x or x != x
1016610176
// should result in a warning, since these always evaluate to a constant.
1016710177
// Array comparisons have similar warnings

clang/include/clang/Basic/arm_neon.td

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2120,4 +2120,9 @@ let ArchGuard = "defined(__aarch64__)", TargetGuard = "lut" in {
21202120
def VLUTI4_BF_X2_Q : SInst<"vluti4_laneq_x2", ".2(<U)I", "Qb",
21212121
[ImmCheck<3, ImmCheck0_3>]>;
21222122
}
2123-
}
2123+
}
2124+
2125+
let ArchGuard = "defined(__aarch64__)", TargetGuard = "neon,faminmax" in {
2126+
def FAMIN : WInst<"vamin", "...", "fhQdQfQh">;
2127+
def FAMAX : WInst<"vamax", "...", "fhQdQfQh">;
2128+
}

clang/include/clang/Driver/Options.td

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,7 @@ def z : Separate<["-"], "z">, Flags<[LinkerInput]>,
10531053
def offload_link : Flag<["--"], "offload-link">, Group<Link_Group>,
10541054
HelpText<"Use the new offloading linker to perform the link job.">;
10551055
def Xlinker : Separate<["-"], "Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
1056+
Visibility<[ClangOption, CLOption, FlangOption, DXCOption]>,
10561057
HelpText<"Pass <arg> to the linker">, MetaVarName<"<arg>">,
10571058
Group<Link_Group>;
10581059
def Xoffload_linker : JoinedAndSeparate<["-"], "Xoffload-linker">,
@@ -6105,7 +6106,9 @@ def _no_line_commands : Flag<["--"], "no-line-commands">, Alias<P>;
61056106
def _no_standard_includes : Flag<["--"], "no-standard-includes">, Alias<nostdinc>;
61066107
def _no_standard_libraries : Flag<["--"], "no-standard-libraries">, Alias<nostdlib>;
61076108
def _no_undefined : Flag<["--"], "no-undefined">, Flags<[LinkerInput]>;
6108-
def _no_warnings : Flag<["--"], "no-warnings">, Alias<w>;
6109+
def _no_warnings : Flag<["--"], "no-warnings">,
6110+
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
6111+
Alias<w>;
61096112
def _optimize_EQ : Joined<["--"], "optimize=">, Alias<O>;
61106113
def _optimize : Flag<["--"], "optimize">, Alias<O>;
61116114
def _output_class_directory_EQ : Joined<["--"], "output-class-directory=">, Alias<foutput_class_dir_EQ>;

clang/include/clang/Sema/Overload.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,6 @@ class Sema;
225225
/// HLSL Scalar Widening with promotion
226226
ICR_HLSL_Scalar_Widening_Promotion,
227227

228-
/// HLSL Matching Dimension Reduction
229-
ICR_HLSL_Dimension_Reduction,
230-
231228
/// Conversion
232229
ICR_Conversion,
233230

@@ -250,6 +247,9 @@ class Sema;
250247
/// extension anyway.
251248
ICR_C_Conversion_Extension,
252249

250+
/// HLSL Matching Dimension Reduction
251+
ICR_HLSL_Dimension_Reduction,
252+
253253
/// HLSL Dimension reduction with promotion
254254
ICR_HLSL_Dimension_Reduction_Promotion,
255255

clang/include/clang/Sema/Sema.h

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6407,9 +6407,6 @@ class Sema final : public SemaBase {
64076407
/// example, in a for-range initializer).
64086408
bool InLifetimeExtendingContext = false;
64096409

6410-
/// Whether we should rebuild CXXDefaultArgExpr and CXXDefaultInitExpr.
6411-
bool RebuildDefaultArgOrDefaultInit = false;
6412-
64136410
// When evaluating immediate functions in the initializer of a default
64146411
// argument or default member initializer, this is the declaration whose
64156412
// default initializer is being evaluated and the location of the call
@@ -7813,11 +7810,9 @@ class Sema final : public SemaBase {
78137810
}
78147811

78157812
bool isInLifetimeExtendingContext() const {
7816-
return currentEvaluationContext().InLifetimeExtendingContext;
7817-
}
7818-
7819-
bool needRebuildDefaultArgOrInit() const {
7820-
return currentEvaluationContext().RebuildDefaultArgOrDefaultInit;
7813+
assert(!ExprEvalContexts.empty() &&
7814+
"Must be in an expression evaluation context");
7815+
return ExprEvalContexts.back().InLifetimeExtendingContext;
78217816
}
78227817

78237818
bool isCheckingDefaultArgumentOrInitializer() const {
@@ -7859,6 +7854,18 @@ class Sema final : public SemaBase {
78597854
return Res;
78607855
}
78617856

7857+
/// keepInLifetimeExtendingContext - Pull down InLifetimeExtendingContext
7858+
/// flag from previous context.
7859+
void keepInLifetimeExtendingContext() {
7860+
if (ExprEvalContexts.size() > 2 &&
7861+
parentEvaluationContext().InLifetimeExtendingContext) {
7862+
auto &LastRecord = ExprEvalContexts.back();
7863+
auto &PrevRecord = parentEvaluationContext();
7864+
LastRecord.InLifetimeExtendingContext =
7865+
PrevRecord.InLifetimeExtendingContext;
7866+
}
7867+
}
7868+
78627869
DefaultedComparisonKind getDefaultedComparisonKind(const FunctionDecl *FD) {
78637870
return getDefaultedFunctionKind(FD).asComparison();
78647871
}
@@ -10632,9 +10639,9 @@ class Sema final : public SemaBase {
1063210639
/// BuildOverloadedArrowExpr - Build a call to an overloaded @c operator->
1063310640
/// (if one exists), where @c Base is an expression of class type and
1063410641
/// @c Member is the name of the member we're trying to find.
10635-
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base,
10636-
SourceLocation OpLoc,
10637-
bool *NoArrowOperatorFound = nullptr);
10642+
ExprResult BuildOverloadedArrowExpr(Expr *Base, SourceLocation OpLoc,
10643+
bool *NoArrowOperatorFound,
10644+
bool &IsDependent);
1063810645

1063910646
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl,
1064010647
CXXConversionDecl *Method,

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6245,8 +6245,20 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
62456245
}
62466246

62476247
// EmitHLSLBuiltinExpr will check getLangOpts().HLSL
6248-
if (Value *V = EmitHLSLBuiltinExpr(BuiltinID, E))
6249-
return RValue::get(V);
6248+
if (Value *V = EmitHLSLBuiltinExpr(BuiltinID, E, ReturnValue)) {
6249+
switch (EvalKind) {
6250+
case TEK_Scalar:
6251+
if (V->getType()->isVoidTy())
6252+
return RValue::get(nullptr);
6253+
return RValue::get(V);
6254+
case TEK_Aggregate:
6255+
return RValue::getAggregate(ReturnValue.getAddress(),
6256+
ReturnValue.isVolatile());
6257+
case TEK_Complex:
6258+
llvm_unreachable("No current hlsl builtin returns complex");
6259+
}
6260+
llvm_unreachable("Bad evaluation kind in EmitBuiltinExpr");
6261+
}
62506262

62516263
if (getLangOpts().HIPStdPar && getLangOpts().CUDAIsDevice)
62526264
return EmitHipStdParUnsupportedBuiltin(this, FD);
@@ -13577,6 +13589,23 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
1357713589
Int = Intrinsic::aarch64_neon_vluti4q_laneq_x2;
1357813590
return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vluti4q_laneq_x2");
1357913591
}
13592+
13593+
case NEON::BI__builtin_neon_vamin_f16:
13594+
case NEON::BI__builtin_neon_vaminq_f16:
13595+
case NEON::BI__builtin_neon_vamin_f32:
13596+
case NEON::BI__builtin_neon_vaminq_f32:
13597+
case NEON::BI__builtin_neon_vaminq_f64: {
13598+
Int = Intrinsic::aarch64_neon_famin;
13599+
return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "famin");
13600+
}
13601+
case NEON::BI__builtin_neon_vamax_f16:
13602+
case NEON::BI__builtin_neon_vamaxq_f16:
13603+
case NEON::BI__builtin_neon_vamax_f32:
13604+
case NEON::BI__builtin_neon_vamaxq_f32:
13605+
case NEON::BI__builtin_neon_vamaxq_f64: {
13606+
Int = Intrinsic::aarch64_neon_famax;
13607+
return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "famax");
13608+
}
1358013609
}
1358113610
}
1358213611

@@ -18631,7 +18660,8 @@ Intrinsic::ID getDotProductIntrinsic(CGHLSLRuntime &RT, QualType QT) {
1863118660
}
1863218661

1863318662
Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
18634-
const CallExpr *E) {
18663+
const CallExpr *E,
18664+
ReturnValueSlot ReturnValue) {
1863518665
if (!getLangOpts().HLSL)
1863618666
return nullptr;
1863718667

@@ -18818,6 +18848,27 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
1881818848
CGM.getHLSLRuntime().getSaturateIntrinsic(), ArrayRef<Value *>{Op0},
1881918849
nullptr, "hlsl.saturate");
1882018850
}
18851+
case Builtin::BI__builtin_hlsl_select: {
18852+
Value *OpCond = EmitScalarExpr(E->getArg(0));
18853+
RValue RValTrue = EmitAnyExpr(E->getArg(1));
18854+
Value *OpTrue =
18855+
RValTrue.isScalar()
18856+
? RValTrue.getScalarVal()
18857+
: RValTrue.getAggregatePointer(E->getArg(1)->getType(), *this);
18858+
RValue RValFalse = EmitAnyExpr(E->getArg(2));
18859+
Value *OpFalse =
18860+
RValFalse.isScalar()
18861+
? RValFalse.getScalarVal()
18862+
: RValFalse.getAggregatePointer(E->getArg(2)->getType(), *this);
18863+
18864+
Value *SelectVal =
18865+
Builder.CreateSelect(OpCond, OpTrue, OpFalse, "hlsl.select");
18866+
if (!RValTrue.isScalar())
18867+
Builder.CreateStore(SelectVal, ReturnValue.getAddress(),
18868+
ReturnValue.isVolatile());
18869+
18870+
return SelectVal;
18871+
}
1882118872
case Builtin::BI__builtin_hlsl_wave_get_lane_index: {
1882218873
return EmitRuntimeCall(CGM.CreateRuntimeFunction(
1882318874
llvm::FunctionType::get(IntTy, {}, false), "__hlsl_wave_get_lane_index",

clang/lib/CodeGen/CodeGenFunction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4797,7 +4797,8 @@ class CodeGenFunction : public CodeGenTypeCache {
47974797
llvm::Value *EmitX86BuiltinExpr(unsigned BuiltinID, const CallExpr *E);
47984798
llvm::Value *EmitPPCBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
47994799
llvm::Value *EmitAMDGPUBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
4800-
llvm::Value *EmitHLSLBuiltinExpr(unsigned BuiltinID, const CallExpr *E);
4800+
llvm::Value *EmitHLSLBuiltinExpr(unsigned BuiltinID, const CallExpr *E,
4801+
ReturnValueSlot ReturnValue);
48014802
llvm::Value *EmitScalarOrConstFoldImmArg(unsigned ICEArguments, unsigned Idx,
48024803
const CallExpr *E);
48034804
llvm::Value *EmitSystemZBuiltinExpr(unsigned BuiltinID, const CallExpr *E);

clang/lib/CodeGen/Targets/AArch64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadic,
304304
return getNaturalAlignIndirect(Ty, false);
305305

306306
return (isPromotableIntegerTypeForABI(Ty) && isDarwinPCS()
307-
? ABIArgInfo::getExtend(Ty)
307+
? ABIArgInfo::getExtend(Ty, CGT.ConvertType(Ty))
308308
: ABIArgInfo::getDirect());
309309
}
310310

clang/lib/CodeGen/Targets/ARM.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,9 @@ ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty, bool isVariadic,
354354
if (EIT->getNumBits() > 64)
355355
return getNaturalAlignIndirect(Ty, /*ByVal=*/true);
356356

357-
return (isPromotableIntegerTypeForABI(Ty) ? ABIArgInfo::getExtend(Ty)
358-
: ABIArgInfo::getDirect());
357+
return (isPromotableIntegerTypeForABI(Ty)
358+
? ABIArgInfo::getExtend(Ty, CGT.ConvertType(Ty))
359+
: ABIArgInfo::getDirect());
359360
}
360361

361362
if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI())) {

clang/lib/CodeGen/Targets/RISCV.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class RISCVABIInfo : public DefaultABIInfo {
5151
RValue EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty,
5252
AggValueSlot Slot) const override;
5353

54-
ABIArgInfo extendType(QualType Ty) const;
54+
ABIArgInfo extendType(QualType Ty, llvm::Type *CoerceTy = nullptr) const;
5555

5656
bool detectFPCCEligibleStruct(QualType Ty, llvm::Type *&Field1Ty,
5757
CharUnits &Field1Off, llvm::Type *&Field2Ty,
@@ -439,12 +439,12 @@ ABIArgInfo RISCVABIInfo::classifyArgumentType(QualType Ty, bool IsFixed,
439439

440440
// All integral types are promoted to XLen width
441441
if (Size < XLen && Ty->isIntegralOrEnumerationType()) {
442-
return extendType(Ty);
442+
return extendType(Ty, CGT.ConvertType(Ty));
443443
}
444444

445445
if (const auto *EIT = Ty->getAs<BitIntType>()) {
446446
if (EIT->getNumBits() < XLen)
447-
return extendType(Ty);
447+
return extendType(Ty, CGT.ConvertType(Ty));
448448
if (EIT->getNumBits() > 128 ||
449449
(!getContext().getTargetInfo().hasInt128Type() &&
450450
EIT->getNumBits() > 64))
@@ -526,12 +526,12 @@ RValue RISCVABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
526526
/*AllowHigherAlign=*/true, Slot);
527527
}
528528

529-
ABIArgInfo RISCVABIInfo::extendType(QualType Ty) const {
529+
ABIArgInfo RISCVABIInfo::extendType(QualType Ty, llvm::Type *CoerceTy) const {
530530
int TySize = getContext().getTypeSize(Ty);
531531
// RV64 ABI requires unsigned 32 bit integers to be sign extended.
532532
if (XLen == 64 && Ty->isUnsignedIntegerOrEnumerationType() && TySize == 32)
533-
return ABIArgInfo::getSignExtend(Ty);
534-
return ABIArgInfo::getExtend(Ty);
533+
return ABIArgInfo::getSignExtend(Ty, CoerceTy);
534+
return ABIArgInfo::getExtend(Ty, CoerceTy);
535535
}
536536

537537
namespace {

clang/lib/CodeGen/Targets/X86.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,8 @@ ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, CCState &State,
881881

882882
if (isPromotableIntegerTypeForABI(Ty)) {
883883
if (InReg)
884-
return ABIArgInfo::getExtendInReg(Ty);
885-
return ABIArgInfo::getExtend(Ty);
884+
return ABIArgInfo::getExtendInReg(Ty, CGT.ConvertType(Ty));
885+
return ABIArgInfo::getExtend(Ty, CGT.ConvertType(Ty));
886886
}
887887

888888
if (const auto *EIT = Ty->getAs<BitIntType>()) {
@@ -2756,7 +2756,7 @@ X86_64ABIInfo::classifyArgumentType(QualType Ty, unsigned freeIntRegs,
27562756

27572757
if (Ty->isIntegralOrEnumerationType() &&
27582758
isPromotableIntegerTypeForABI(Ty))
2759-
return ABIArgInfo::getExtend(Ty);
2759+
return ABIArgInfo::getExtend(Ty, CGT.ConvertType(Ty));
27602760
}
27612761

27622762
break;

clang/lib/Driver/Driver.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,13 +3049,6 @@ class OffloadingActionBuilder final {
30493049
// Set the flag to true, so that the builder acts on the current input.
30503050
IsActive = true;
30513051

3052-
if (CompileHostOnly)
3053-
return ABRT_Success;
3054-
3055-
// Replicate inputs for each GPU architecture.
3056-
auto Ty = AssociatedOffloadKind == Action::OFK_HIP
3057-
? types::TY_HIP_DEVICE
3058-
: types::TY_CUDA_DEVICE;
30593052
std::string CUID = FixedCUID.str();
30603053
if (CUID.empty()) {
30613054
if (UseCUID == CUID_Random)
@@ -3079,6 +3072,12 @@ class OffloadingActionBuilder final {
30793072
}
30803073
IA->setId(CUID);
30813074

3075+
if (CompileHostOnly)
3076+
return ABRT_Success;
3077+
3078+
// Replicate inputs for each GPU architecture.
3079+
auto Ty = IA->getType() == types::TY_HIP ? types::TY_HIP_DEVICE
3080+
: types::TY_CUDA_DEVICE;
30823081
for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
30833082
CudaDeviceActions.push_back(
30843083
C.MakeAction<InputAction>(IA->getInputArg(), Ty, IA->getId()));

0 commit comments

Comments
 (0)