Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
Change-Id: I755fb889a1268f04c96c51e3d701e4bba5460912
  • Loading branch information
Jenkins committed Sep 25, 2024
2 parents 6699a8f + de70b95 commit f49f430
Show file tree
Hide file tree
Showing 258 changed files with 5,897 additions and 13,770 deletions.
23 changes: 0 additions & 23 deletions clang/docs/LanguageExtensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5860,26 +5860,3 @@ specify the starting offset to begin embedding from. The resources is treated
as being empty if the specified offset is larger than the number of bytes in
the resource. The offset will be applied *before* any ``limit`` parameters are
applied.
Union and aggregate initialization in C
=======================================
In C23 (N2900), when an object is initialized from initializer ``= {}``, all
elements of arrays, all members of structs, and the first members of unions are
empty-initialized recursively. In addition, all padding bits are initialized to
zero.
Clang guarantees the following behaviors:
* ``1:`` Clang supports initializer ``= {}`` mentioned above in all C
standards.
* ``2:`` When unions are initialized from initializer ``= {}``, bytes outside
of the first members of unions are also initialized to zero.
* ``3:`` When unions, structures and arrays are initialized from initializer
``= { initializer-list }``, all members not explicitly initialized in
the initializer list are empty-initialized recursively. In addition, all
padding bits are initialized to zero.
Currently, the above extension only applies to C source code, not C++.
2 changes: 1 addition & 1 deletion clang/include/clang/AST/PropertiesBase.td
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class EnumPropertyType<string typeName = ""> : PropertyType<typeName> {}
/// Supports optional values by using the null representation.
class RefPropertyType<string className> : PropertyType<className # "*"> {
let PackOptional =
"value ? *value : nullptr";
"value.value_or(nullptr)";
let UnpackOptional =
"value ? std::optional<" # CXXName # ">(value) : std::nullopt";
}
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/FileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ class FileManager : public RefCountedBase<FileManager> {
bool RequiresNullTerminator = true,
std::optional<int64_t> MaybeLimit = std::nullopt) const {
return getBufferForFileImpl(Filename,
/*FileSize=*/(MaybeLimit ? *MaybeLimit : -1),
/*FileSize=*/MaybeLimit.value_or(-1),
isVolatile, RequiresNullTerminator);
}

Expand Down
44 changes: 34 additions & 10 deletions clang/include/clang/Basic/riscv_vector.td
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,11 @@ multiclass RVVNonTupleVCreateBuiltin<int dst_lmul, list<int> src_lmul_list> {
defvar src_s = FixedVString<src_lmul, num, "v">.S;
def vcreate # src_v # dst_v : RVVBuiltin<src_v # dst_v,
dst_v # src_s,
"csilxfd">;
"csilfd">;
let RequiredFeatures = ["Zvfhmin"] in
def vcreate_h # src_v # dst_v : RVVBuiltin<src_v # dst_v,
dst_v # src_s,
"x", dst_v>;
let RequiredFeatures = ["Zvfbfmin"] in
def vcreate_bf16 # src_v # dst_v : RVVBuiltin<src_v # dst_v,
dst_v # src_s,
Expand Down Expand Up @@ -2474,15 +2478,19 @@ let HasMasked = false, HasVL = false, IRName = "" in {
ManualCodegen = [{
return llvm::PoisonValue::get(ResultType);
}] in {
def vundefined : RVVBuiltin<"v", "v", "csilxfd">;
def vundefined : RVVBuiltin<"v", "v", "csilfd">;
let RequiredFeatures = ["Zvfhmin"] in
def vundefined_h : RVVBuiltin<"v", "v", "x">;
let RequiredFeatures = ["Zvfbfmin"] in
def vundefined_bf16 : RVVBuiltin<"v", "v", "y">;
def vundefined_u : RVVBuiltin<"Uv", "Uv", "csil">;

foreach nf = NFList in {
let NF = nf in {
defvar T = "(Tuple:" # nf # ")";
def : RVVBuiltin<T # "v", T # "v", "csilxfd">;
def : RVVBuiltin<T # "v", T # "v", "csilfd">;
let RequiredFeatures = ["Zvfhmin"] in
def : RVVBuiltin<T # "v", T # "v", "x">;
let RequiredFeatures = ["Zvfbfmin"] in
def : RVVBuiltin<T # "v", T # "v", "y">;
def : RVVBuiltin<T # "Uv", T # "Uv", "csil">;
Expand All @@ -2502,7 +2510,10 @@ let HasMasked = false, HasVL = false, IRName = "" in {
foreach dst_lmul = ["(SFixedLog2LMUL:-3)", "(SFixedLog2LMUL:-2)", "(SFixedLog2LMUL:-1)",
"(SFixedLog2LMUL:0)", "(SFixedLog2LMUL:1)", "(SFixedLog2LMUL:2)"] in {
def vlmul_trunc # dst_lmul : RVVBuiltin<"v" # dst_lmul # "v",
dst_lmul # "vv", "csilxfd", dst_lmul # "v">;
dst_lmul # "vv", "csilfd", dst_lmul # "v">;
let RequiredFeatures = ["Zvfhmin"] in
def vlmul_trunc_h # dst_lmul : RVVBuiltin<"v" # dst_lmul # "v",
dst_lmul # "vv", "x", dst_lmul # "v">;
let RequiredFeatures = ["Zvfbfmin"] in
def vlmul_trunc_bf16 # dst_lmul : RVVBuiltin<"v" # dst_lmul # "v",
dst_lmul # "vv", "y", dst_lmul # "v">;
Expand All @@ -2523,7 +2534,10 @@ let HasMasked = false, HasVL = false, IRName = "" in {
foreach dst_lmul = ["(LFixedLog2LMUL:-2)", "(LFixedLog2LMUL:-1)", "(LFixedLog2LMUL:-0)",
"(LFixedLog2LMUL:1)", "(LFixedLog2LMUL:2)", "(LFixedLog2LMUL:3)"] in {
def vlmul_ext # dst_lmul : RVVBuiltin<"v" # dst_lmul # "v",
dst_lmul # "vv", "csilxfd", dst_lmul # "v">;
dst_lmul # "vv", "csilfd", dst_lmul # "v">;
let RequiredFeatures = ["Zvfhmin"] in
def vlmul_ext_h # dst_lmul : RVVBuiltin<"v" # dst_lmul # "v",
dst_lmul # "vv", "x", dst_lmul # "v">;
let RequiredFeatures = ["Zvfbfmin"] in
def vlmul_ext_bf16 # dst_lmul : RVVBuiltin<"v" # dst_lmul # "v",
dst_lmul # "vv", "y", dst_lmul # "v">;
Expand Down Expand Up @@ -2555,14 +2569,18 @@ let HasMasked = false, HasVL = false, IRName = "" in {
}
}] in {
foreach dst_lmul = ["(SFixedLog2LMUL:0)", "(SFixedLog2LMUL:1)", "(SFixedLog2LMUL:2)"] in {
def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "vvKz", "csilxfd", dst_lmul # "v">;
def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "vvKz", "csilfd", dst_lmul # "v">;
let RequiredFeatures = ["Zvfhmin"] in
def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "vvKz", "x", dst_lmul # "v">;
let RequiredFeatures = ["Zvfbfmin"] in
def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "vvKz", "y", dst_lmul # "v">;
def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "UvUvKz", "csil", dst_lmul # "Uv">;
}
foreach nf = NFList in {
defvar T = "(Tuple:" # nf # ")";
def : RVVBuiltin<T # "vv", "v" # T # "vKz", "csilxfd", "v">;
def : RVVBuiltin<T # "vv", "v" # T # "vKz", "csilfd", "v">;
let RequiredFeatures = ["Zvfhmin"] in
def : RVVBuiltin<T # "vv", "v" # T # "vKz", "x", "v">;
let RequiredFeatures = ["Zvfbfmin"] in
def : RVVBuiltin<T # "vv", "v" # T # "vKz", "y", "v">;
def : RVVBuiltin<T # "UvUv", "Uv" # T # "UvKz", "csil", "Uv">;
Expand Down Expand Up @@ -2592,14 +2610,18 @@ let HasMasked = false, HasVL = false, IRName = "" in {
}
}] in {
foreach dst_lmul = ["(LFixedLog2LMUL:1)", "(LFixedLog2LMUL:2)", "(LFixedLog2LMUL:3)"] in {
def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "v" # dst_lmul # "vKzv", "csilxfd">;
def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "v" # dst_lmul # "vKzv", "csilfd">;
let RequiredFeatures = ["Zvfhmin"] in
def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "v" # dst_lmul # "vKzv", "x">;
let RequiredFeatures = ["Zvfbfmin"] in
def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "v" # dst_lmul # "vKzv", "y">;
def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "Uv" # dst_lmul #"UvKzUv", "csil">;
}
foreach nf = NFList in {
defvar T = "(Tuple:" # nf # ")";
def : RVVBuiltin<"v" # T # "v", T # "v" # T # "vKzv", "csilxfd">;
def : RVVBuiltin<"v" # T # "v", T # "v" # T # "vKzv", "csilfd">;
let RequiredFeatures = ["Zvfhmin"] in
def : RVVBuiltin<"v" # T # "v", T # "v" # T # "vKzv", "x">;
let RequiredFeatures = ["Zvfbfmin"] in
def : RVVBuiltin<"v" # T # "v", T # "v" # T # "vKzv", "y">;
def : RVVBuiltin<"Uv" # T # "Uv", T # "Uv" # T # "UvKzUv", "csil">;
Expand Down Expand Up @@ -2646,7 +2668,9 @@ let HasMasked = false, HasVL = false, IRName = "" in {
defvar T = "(Tuple:" # nf # ")";
defvar V = VString<nf, /*signed=*/true>.S;
defvar UV = VString<nf, /*signed=*/false>.S;
def : RVVBuiltin<T # "v", T # "v" # V, "csilxfd">;
def : RVVBuiltin<T # "v", T # "v" # V, "csilfd">;
let RequiredFeatures = ["Zvfhmin"] in
def : RVVBuiltin<T # "v", T # "v" # V, "x">;
let RequiredFeatures = ["Zvfbfmin"] in
def : RVVBuiltin<T # "v", T # "v" # V, "y">;
def : RVVBuiltin<T # "Uv", T # "Uv" # UV, "csil">;
Expand Down
6 changes: 6 additions & 0 deletions clang/include/clang/Serialization/ASTBitCodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,12 @@ enum ASTRecordTypes {

/// Record code for vtables to emit.
VTABLES_TO_EMIT = 70,

/// Record code for the FunctionDecl to lambdas mapping. These lambdas have to
/// be loaded right after the function they belong to. It is required to have
/// canonical declaration for the lambda class from the same module as
/// enclosing function.
FUNCTION_DECL_TO_LAMBDAS_MAP = 71,
};

/// Record types used within a source manager block.
Expand Down
12 changes: 12 additions & 0 deletions clang/include/clang/Serialization/ASTReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,18 @@ class ASTReader
/// namespace as if it is not delayed.
DelayedNamespaceOffsetMapTy DelayedNamespaceOffsetMap;

/// Mapping from FunctionDecl IDs to the corresponding lambda IDs.
///
/// These lambdas have to be loaded right after the function they belong to.
/// It is required to have canonical declaration for lambda class from the
/// same module as enclosing function. This is required to correctly resolve
/// captured variables in the lambda. Without this, due to lazy
/// deserialization, canonical declarations for the function and lambdas can
/// be selected from different modules and DeclRefExprs may refer to the AST
/// nodes that don't exist in the function.
llvm::DenseMap<GlobalDeclID, SmallVector<GlobalDeclID, 4>>
FunctionToLambdasMap;

struct PendingUpdateRecord {
Decl *D;
GlobalDeclID ID;
Expand Down
8 changes: 8 additions & 0 deletions clang/include/clang/Serialization/ASTWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,14 @@ class ASTWriter : public ASTDeserializationListener,
/// instead of comparing the result of `getDeclID()` or `GetDeclRef()`.
llvm::SmallPtrSet<const Decl *, 32> PredefinedDecls;

/// Mapping from FunctionDecl to the list of lambda IDs inside the function.
///
/// These lambdas have to be loaded right after the function they belong to.
/// In order to have canonical declaration for lambda class from the same
/// module as enclosing function during deserialization.
llvm::DenseMap<const Decl *, SmallVector<LocalDeclID, 4>>
FunctionToLambdasMap;

/// Offset of each declaration in the bitstream, indexed by
/// the declaration's ID.
std::vector<serialization::DeclOffset> DeclOffsets;
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/APINotes/APINotesYAMLCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,8 +757,8 @@ class YAMLConverter {
OutInfo.addTypeInfo(idx++, N);
audited = Nullability.size() > 0 || ReturnNullability;
if (audited)
OutInfo.addTypeInfo(0, ReturnNullability ? *ReturnNullability
: NullabilityKind::NonNull);
OutInfo.addTypeInfo(0,
ReturnNullability.value_or(NullabilityKind::NonNull));
if (!audited)
return;
OutInfo.NullabilityAudited = audited;
Expand Down
8 changes: 5 additions & 3 deletions clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,9 +725,7 @@ bool Compiler<Emitter>::VisitParenExpr(const ParenExpr *E) {
template <class Emitter>
bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {
// Need short-circuiting for these.
if (BO->getType()->isVectorType())
return this->VisitVectorBinOp(BO);
if (BO->isLogicalOp())
if (BO->isLogicalOp() && !BO->getType()->isVectorType())
return this->VisitLogicalBinOp(BO);

const Expr *LHS = BO->getLHS();
Expand All @@ -746,6 +744,8 @@ bool Compiler<Emitter>::VisitBinaryOperator(const BinaryOperator *BO) {

if (BO->getType()->isAnyComplexType())
return this->VisitComplexBinOp(BO);
if (BO->getType()->isVectorType())
return this->VisitVectorBinOp(BO);
if ((LHS->getType()->isAnyComplexType() ||
RHS->getType()->isAnyComplexType()) &&
BO->isComparisonOp())
Expand Down Expand Up @@ -1264,6 +1264,8 @@ bool Compiler<Emitter>::VisitComplexBinOp(const BinaryOperator *E) {

template <class Emitter>
bool Compiler<Emitter>::VisitVectorBinOp(const BinaryOperator *E) {
assert(!E->isCommaOp() &&
"Comma op should be handled in VisitBinaryOperator");
assert(E->getType()->isVectorType());
assert(E->getLHS()->getType()->isVectorType());
assert(E->getRHS()->getType()->isVectorType());
Expand Down
11 changes: 8 additions & 3 deletions clang/lib/AST/ByteCode/Descriptor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,17 @@ Descriptor::Descriptor(const DeclTy &D)
}

QualType Descriptor::getType() const {
if (const auto *E = asExpr())
return E->getType();
if (const auto *D = asValueDecl())
return D->getType();
if (const auto *T = dyn_cast<TypeDecl>(asDecl()))
if (const auto *T = dyn_cast_if_present<TypeDecl>(asDecl()))
return QualType(T->getTypeForDecl(), 0);

// The Source sometimes has a different type than the once
// we really save. Try to consult the Record first.
if (isRecord())
return QualType(ElemRecord->getDecl()->getTypeForDecl(), 0);
if (const auto *E = asExpr())
return E->getType();
llvm_unreachable("Invalid descriptor type");
}

Expand Down
4 changes: 0 additions & 4 deletions clang/lib/AST/ByteCode/Interp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1296,10 +1296,6 @@ bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, const Expr *E,
if (!InvalidNewDeleteExpr(S, OpPC, E))
return false;

// Assume proper types in std functions.
if (S.Current->isStdFunction())
return true;

const auto *NewExpr = cast<CXXNewExpr>(E);
QualType StorageType = Ptr.getType();

Expand Down
2 changes: 2 additions & 0 deletions clang/lib/AST/ByteCode/Interp.h
Original file line number Diff line number Diff line change
Expand Up @@ -2573,6 +2573,7 @@ inline bool ArrayElem(InterpState &S, CodePtr OpPC, uint32_t Index) {
if (!CheckLoad(S, OpPC, Ptr))
return false;

assert(Ptr.atIndex(Index).getFieldDesc()->getPrimType() == Name);
S.Stk.push<T>(Ptr.atIndex(Index).deref<T>());
return true;
}
Expand All @@ -2584,6 +2585,7 @@ inline bool ArrayElemPop(InterpState &S, CodePtr OpPC, uint32_t Index) {
if (!CheckLoad(S, OpPC, Ptr))
return false;

assert(Ptr.atIndex(Index).getFieldDesc()->getPrimType() == Name);
S.Stk.push<T>(Ptr.atIndex(Index).deref<T>());
return true;
}
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Basic/TargetID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "clang/Basic/TargetID.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/TargetParser.h"
Expand Down
Loading

0 comments on commit f49f430

Please sign in to comment.