Skip to content

Commit

Permalink
Merge pull request #17 from llvm/main
Browse files Browse the repository at this point in the history
[pull] main from llvm:main
  • Loading branch information
devkadirselcuk authored Jul 7, 2021
2 parents 5cbc5e9 + d0b282e commit 7b0c636
Show file tree
Hide file tree
Showing 255 changed files with 51,702 additions and 4,166 deletions.
3 changes: 3 additions & 0 deletions clang/include/clang/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,9 @@ class VarDecl : public DeclaratorDecl, public Redeclarable<VarDecl> {
NonParmVarDeclBits.EscapingByref = true;
}

/// Determines if this variable's alignment is dependent.
bool hasDependentAlignment() const;

/// Retrieve the variable declaration from which this variable could
/// be instantiated, if it is an instantiation (rather than a non-template).
VarDecl *getTemplateInstantiationPattern() const;
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/IdentifierTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>;
/// of a pointer to one of these classes.
enum { IdentifierInfoAlignment = 8 };

static constexpr int ObjCOrBuiltinIDBits = 15;
static constexpr int ObjCOrBuiltinIDBits = 16;

/// One of these records is kept for each identifier that
/// is lexed. This contains information about whether the token was \#define'd,
Expand Down
165 changes: 165 additions & 0 deletions clang/include/clang/Basic/riscv_vector.td
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ class RVVBuiltin<string suffix, string prototype, string type_range,
// Sub extension of vector spec. Currently only support Zvamo or Zvlsseg.
string RequiredExtension = "";

// Number of fields for Zvlsseg.
int NF = 1;
}

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -768,6 +770,163 @@ multiclass RVVIndexedStore<string op> {
}
}

defvar NFList = [2, 3, 4, 5, 6, 7, 8];

class PVString<int nf, bit signed> {
string S =
!cond(!eq(nf, 2): !if(signed, "PvPv", "PUvPUv"),
!eq(nf, 3): !if(signed, "PvPvPv", "PUvPUvPUv"),
!eq(nf, 4): !if(signed, "PvPvPvPv", "PUvPUvPUvPUv"),
!eq(nf, 5): !if(signed, "PvPvPvPvPv", "PUvPUvPUvPUvPUv"),
!eq(nf, 6): !if(signed, "PvPvPvPvPvPv", "PUvPUvPUvPUvPUvPUv"),
!eq(nf, 7): !if(signed, "PvPvPvPvPvPvPv", "PUvPUvPUvPUvPUvPUvPUv"),
!eq(nf, 8): !if(signed, "PvPvPvPvPvPvPvPv", "PUvPUvPUvPUvPUvPUvPUvPUv"));
}

multiclass RVVUnitStridedSegLoad<string op> {
foreach type = TypeList in {
defvar eew = !cond(!eq(type, "c") : "8",
!eq(type, "s") : "16",
!eq(type, "i") : "32",
!eq(type, "l") : "64",
!eq(type, "h") : "16",
!eq(type, "f") : "32",
!eq(type, "d") : "64");
foreach nf = NFList in {
let Name = op # nf # "e" # eew # "_v",
IRName = op # nf,
IRNameMask = op # nf # "_mask",
NF = nf,
HasNoMaskedOverloaded = false,
ManualCodegen = [{
{
// builtin: (val0 address, val1 address, ..., ptr, vl)
IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(),
Ops[NF + 1]->getType()};
// intrinsic: (ptr, vl)
llvm::Value *Operands[] = {Ops[NF], Ops[NF + 1]};
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
clang::CharUnits Align =
CGM.getNaturalTypeAlignment(getContext().getSizeType());
llvm::Value *V;
for (unsigned I = 0; I < NF; ++I) {
V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}),
Address(Ops[I], Align));
}
return V;
}
}],
ManualCodegenMask = [{
{
// builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, vl)
// intrinsic: (maskedoff0, ..., ptr, mask, vl)
IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(),
Ops[2 * NF + 2]->getType()};
SmallVector<llvm::Value*, 12> Operands;
for (unsigned I = 0; I < NF; ++I)
Operands.push_back(Ops[NF + I + 1]);
Operands.push_back(Ops[2 * NF + 1]);
Operands.push_back(Ops[NF]);
Operands.push_back(Ops[2 * NF + 2]);
assert(Operands.size() == NF + 3);
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
clang::CharUnits Align =
CGM.getNaturalTypeAlignment(getContext().getSizeType());
llvm::Value *V;
for (unsigned I = 0; I < NF; ++I) {
V = Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}),
Address(Ops[I], Align));
}
return V;
}
}] in {
defvar PV = PVString<nf, /*signed=*/true>.S;
defvar PUV = PVString<nf, /*signed=*/false>.S;
def : RVVBuiltin<"v", "0" # PV # "PCe", type>;
if !not(IsFloat<type>.val) then {
def : RVVBuiltin<"Uv", "0" # PUV # "PCUe", type>;
}
}
}
}
}

multiclass RVVUnitStridedSegLoadFF<string op> {
foreach type = TypeList in {
defvar eew = !cond(!eq(type, "c") : "8",
!eq(type, "s") : "16",
!eq(type, "i") : "32",
!eq(type, "l") : "64",
!eq(type, "h") : "16",
!eq(type, "f") : "32",
!eq(type, "d") : "64");
foreach nf = NFList in {
let Name = op # nf # "e" # eew # "ff_v",
IRName = op # nf # "ff",
IRNameMask = op # nf # "ff_mask",
NF = nf,
HasNoMaskedOverloaded = false,
ManualCodegen = [{
{
// builtin: (val0 address, val1 address, ..., ptr, new_vl, vl)
IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(),
Ops[NF + 2]->getType()};
// intrinsic: (ptr, vl)
llvm::Value *Operands[] = {Ops[NF], Ops[NF + 2]};
Value *NewVL = Ops[NF + 1];
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
clang::CharUnits Align =
CGM.getNaturalTypeAlignment(getContext().getSizeType());
for (unsigned I = 0; I < NF; ++I) {
Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}),
Address(Ops[I], Align));
}
// Store new_vl.
return Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {NF}),
Address(NewVL, Align));
}
}],
ManualCodegenMask = [{
{
// builtin: (val0 address, ..., mask, maskedoff0, ..., ptr, new_vl, vl)
// intrinsic: (maskedoff0, ..., ptr, mask, vl)
IntrinsicTypes = {Ops[0]->getType()->getPointerElementType(),
Ops[2 * NF + 3]->getType()};
SmallVector<llvm::Value*, 12> Operands;
for (unsigned I = 0; I < NF; ++I)
Operands.push_back(Ops[NF + I + 1]);
Operands.push_back(Ops[2 * NF + 1]);
Operands.push_back(Ops[NF]);
Operands.push_back(Ops[2 * NF + 3]);
Value *NewVL = Ops[2 * NF + 2];
assert(Operands.size() == NF + 3);
llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
clang::CharUnits Align =
CGM.getNaturalTypeAlignment(getContext().getSizeType());
for (unsigned I = 0; I < NF; ++I) {
Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {I}),
Address(Ops[I], Align));
}
// Store new_vl.
return Builder.CreateStore(Builder.CreateExtractValue(LoadValue, {NF}),
Address(NewVL, Align));
}
}] in {
defvar PV = PVString<nf, /*signed=*/true>.S;
defvar PUV = PVString<nf, /*signed=*/false>.S;
def : RVVBuiltin<"v", "0" # PV # "PCe" # "Pz", type>;
if !not(IsFloat<type>.val) then {
def : RVVBuiltin<"Uv", "0" # PUV # "PCUe" # "Pz", type>;
}
}
}
}
}

multiclass RVVAMOBuiltinSet<bit has_signed = false, bit has_unsigned = false,
bit has_fp = false> {
defvar type_list = !if(has_fp, ["i","l","f","d"], ["i","l"]);
Expand Down Expand Up @@ -1083,6 +1242,12 @@ defm vle16ff: RVVVLEFFBuiltin<["s"]>;
defm vle32ff: RVVVLEFFBuiltin<["i", "f"]>;
defm vle64ff: RVVVLEFFBuiltin<["l", "d"]>;

// 7.8 Vector Load/Store Segment Instructions
let RequiredExtension = "Zvlsseg" in {
defm : RVVUnitStridedSegLoad<"vlseg">;
defm : RVVUnitStridedSegLoadFF<"vlseg">;
}

// 8. Vector AMO Operations
let RequiredExtension = "Zvamo" in {
defm vamoswap : RVVAMOBuiltinSet< /* hasSigned */ true, /* hasUnsigned */ true, /* hasFP */ true>;
Expand Down
8 changes: 8 additions & 0 deletions clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2534,6 +2534,14 @@ bool VarDecl::isNonEscapingByref() const {
return hasAttr<BlocksAttr>() && !NonParmVarDeclBits.EscapingByref;
}

bool VarDecl::hasDependentAlignment() const {
QualType T = getType();
return T->isDependentType() || T->isUndeducedAutoType() ||
llvm::any_of(specific_attrs<AlignedAttr>(), [](const AlignedAttr *AA) {
return AA->isAlignmentDependent();
});
}

VarDecl *VarDecl::getTemplateInstantiationPattern() const {
const VarDecl *VD = this;

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ bool ItaniumMangleContextImpl::isUniqueInternalLinkageDecl(

// For C functions without prototypes, return false as their
// names should not be mangled.
if (!FD->hasPrototype())
if (!FD->getType()->getAs<FunctionProtoType>())
return false;

if (isInternalLinkageDecl(ND))
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Basic/Targets/OSTargets.h
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ class AIXTargetInfo : public OSTargetInfo<Target> {
Builder.defineMacro("_POWER");

Builder.defineMacro("_AIX");
Builder.defineMacro("__TOS_AIX__");

if (Opts.C11) {
Builder.defineMacro("__STDC_NO_ATOMICS__");
Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18062,6 +18062,7 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned BuiltinID,
Ops.push_back(EmitScalarExpr(E->getArg(i)));

Intrinsic::ID ID = Intrinsic::not_intrinsic;
unsigned NF = 1;

// Required for overloaded intrinsics.
llvm::SmallVector<llvm::Type *, 2> IntrinsicTypes;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGDebugInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3546,7 +3546,7 @@ void CGDebugInfo::collectFunctionDeclProps(GlobalDecl GD, llvm::DIFile *Unit,
const auto *FD = cast<FunctionDecl>(GD.getCanonicalDecl().getDecl());
Name = getFunctionName(FD);
// Use mangled name as linkage name for C/C++ functions.
if (FD->hasPrototype()) {
if (FD->getType()->getAs<FunctionProtoType>()) {
LinkageName = CGM.getMangledName(GD);
Flags |= llvm::DINode::FlagPrototyped;
}
Expand Down
13 changes: 1 addition & 12 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13310,16 +13310,6 @@ void Sema::CheckCompleteVariableDeclaration(VarDecl *var) {
CheckCompleteDecompositionDeclaration(DD);
}

/// Determines if a variable's alignment is dependent.
static bool hasDependentAlignment(VarDecl *VD) {
if (VD->getType()->isDependentType())
return true;
for (auto *I : VD->specific_attrs<AlignedAttr>())
if (I->isAlignmentDependent())
return true;
return false;
}

/// Check if VD needs to be dllexport/dllimport due to being in a
/// dllexport/import function.
void Sema::CheckStaticLocalForDllExport(VarDecl *VD) {
Expand Down Expand Up @@ -13408,8 +13398,7 @@ void Sema::FinalizeDeclaration(Decl *ThisDecl) {
if (unsigned MaxAlign = Context.getTargetInfo().getMaxTLSAlign()) {
// Protect the check so that it's not performed on dependent types and
// dependent alignments (we can't determine the alignment in that case).
if (VD->getTLSKind() && !hasDependentAlignment(VD) &&
!VD->isInvalidDecl()) {
if (VD->getTLSKind() && !VD->hasDependentAlignment()) {
CharUnits MaxAlignChars = Context.toCharUnitsFromBits(MaxAlign);
if (Context.getDeclAlign(VD) > MaxAlignChars) {
Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3395,7 +3395,7 @@ Sema::NamedReturnInfo Sema::getNamedReturnInfo(const VarDecl *VD) {

// Variables with higher required alignment than their type's ABI
// alignment cannot use NRVO.
if (!VDType->isDependentType() && VD->hasAttr<AlignedAttr>() &&
if (!VD->hasDependentAlignment() &&
Context.getDeclAlign(VD) > Context.getTypeAlignInChars(VDType))
Info.S = NamedReturnInfo::MoveEligible;

Expand Down
1 change: 1 addition & 0 deletions clang/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ if( NOT CLANG_BUILT_STANDALONE )
llvm-config
FileCheck count not
llc
llvm-ar
llvm-as
llvm-bcanalyzer
llvm-cat
Expand Down
26 changes: 26 additions & 0 deletions clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,3 +487,29 @@ void test5() try {
}

} // namespace test_simpler_implicit_move

namespace test_auto_variables {

struct S {};

template <class T> struct range {
S *begin() const;
S *end() const;
};

template <class T> S test_dependent_ranged_for() {
for (auto x : range<T>())
return x;
return S();
}
template S test_dependent_ranged_for<int>();

template <class T> struct X {};

template <class T> X<T> test_dependent_invalid_decl() {
auto x = X<T>().foo(); // expected-error {{no member named 'foo'}}
return x;
}
template X<int> test_dependent_invalid_decl<int>(); // expected-note {{requested here}}

} // namespace test_auto_variables
Loading

0 comments on commit 7b0c636

Please sign in to comment.