Skip to content

Commit

Permalink
Manually merged main:1730b0f66ada into amd-gfx:8c001b46dda3
Browse files Browse the repository at this point in the history
Local branch amd-gfx 8c001b4 Merged main:c8a914db5c60 into amd-gfx:7f859d7ffae1
Remote branch main 1730b0f [RISCV] Remove '.mask' from vcompress intrinsic name. NFC

Change-Id: I11cc996f02cde5f8b8aba7d36b044554017c3b7f
  • Loading branch information
perlfu committed Jan 13, 2021
2 parents 8c001b4 + 1730b0f commit b16080c
Show file tree
Hide file tree
Showing 366 changed files with 23,663 additions and 20,725 deletions.
10 changes: 10 additions & 0 deletions clang-tools-extra/clangd/FindTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ struct TargetFinder {
llvm::SmallDenseMap<const NamedDecl *,
std::pair<RelSet, /*InsertionOrder*/ size_t>>
Decls;
llvm::SmallDenseMap<const Decl *, RelSet> Seen;
RelSet Flags;

template <typename T> void debug(T &Node, RelSet Flags) {
Expand Down Expand Up @@ -359,6 +360,15 @@ struct TargetFinder {
if (!D)
return;
debug(*D, Flags);

// Avoid recursion (which can arise in the presence of heuristic
// resolution of dependent names) by exiting early if we have
// already seen this decl with all flags in Flags.
auto Res = Seen.try_emplace(D);
if (!Res.second && Res.first->second.contains(Flags))
return;
Res.first->second |= Flags;

if (const UsingDirectiveDecl *UDD = llvm::dyn_cast<UsingDirectiveDecl>(D))
D = UDD->getNominatedNamespaceAsWritten();

Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/clangd/FindTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ class DeclRelationSet {
S &= Other.S;
return *this;
}
bool contains(DeclRelationSet Other) const {
return (S & Other.S) == Other.S;
}
friend llvm::raw_ostream &operator<<(llvm::raw_ostream &, DeclRelationSet);
};
// The above operators can't be looked up if both sides are enums.
Expand Down
41 changes: 41 additions & 0 deletions clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,47 @@ TEST_F(TargetDeclTest, DependentTypes) {
"template <typename> struct B");
}

TEST_F(TargetDeclTest, TypedefCascade) {
Code = R"cpp(
struct C {
using type = int;
};
struct B {
using type = C::type;
};
struct A {
using type = B::type;
};
A::[[type]] waldo;
)cpp";
EXPECT_DECLS("TypedefTypeLoc",
{"using type = int", Rel::Alias | Rel::Underlying},
{"using type = C::type", Rel::Alias | Rel::Underlying},
{"using type = B::type", Rel::Alias});
}

TEST_F(TargetDeclTest, RecursiveTemplate) {
Flags.push_back("-std=c++20"); // the test case uses concepts

Code = R"cpp(
template <typename T>
concept Leaf = false;
template <typename Tree>
struct descend_left {
using type = typename descend_left<typename Tree::left>::[[type]];
};
template <Leaf Tree>
struct descend_left<Tree> {
using type = typename Tree::value;
};
)cpp";
EXPECT_DECLS("DependentNameTypeLoc",
{"using type = typename descend_left<typename Tree::left>::type",
Rel::Alias | Rel::Underlying});
}

TEST_F(TargetDeclTest, ObjC) {
Flags = {"-xobjective-c"};
Code = R"cpp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
#include "ClangTidyTest.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Tooling/Transformer/RangeSelector.h"
#include "clang/Tooling/Transformer/RewriteRule.h"
#include "clang/Tooling/Transformer/Stencil.h"
#include "clang/Tooling/Transformer/Transformer.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"

namespace clang {
Expand All @@ -25,20 +27,21 @@ using transformer::change;
using transformer::IncludeFormat;
using transformer::makeRule;
using transformer::node;
using transformer::noopEdit;
using transformer::RewriteRule;
using transformer::RootID;
using transformer::statement;

// Invert the code of an if-statement, while maintaining its semantics.
RewriteRule invertIf() {
StringRef C = "C", T = "T", E = "E";
RewriteRule Rule =
makeRule(ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
hasElse(stmt().bind(E))),
change(statement(std::string(RewriteRule::RootID)),
cat("if(!(", node(std::string(C)), ")) ",
statement(std::string(E)), " else ",
statement(std::string(T)))),
cat("negate condition and reverse `then` and `else` branches"));
RewriteRule Rule = makeRule(
ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
hasElse(stmt().bind(E))),
change(statement(RootID), cat("if(!(", node(std::string(C)), ")) ",
statement(std::string(E)), " else ",
statement(std::string(T)))),
cat("negate condition and reverse `then` and `else` branches"));
return Rule;
}

Expand Down Expand Up @@ -68,6 +71,25 @@ TEST(TransformerClangTidyCheckTest, Basic) {
EXPECT_EQ(Expected, test::runCheckOnCode<IfInverterCheck>(Input));
}

TEST(TransformerClangTidyCheckTest, DiagnosticsCorrectlyGenerated) {
class DiagOnlyCheck : public TransformerClangTidyCheck {
public:
DiagOnlyCheck(StringRef Name, ClangTidyContext *Context)
: TransformerClangTidyCheck(
makeRule(returnStmt(), noopEdit(node(RootID)), cat("message")),
Name, Context) {}
};
std::string Input = "int h() { return 5; }";
std::vector<ClangTidyError> Errors;
EXPECT_EQ(Input, test::runCheckOnCode<DiagOnlyCheck>(Input, &Errors));
EXPECT_EQ(Errors.size(), 1U);
EXPECT_EQ(Errors[0].Message.Message, "message");
EXPECT_THAT(Errors[0].Ranges, testing::IsEmpty());

// The diagnostic is anchored to the match, "return 5".
EXPECT_EQ(Errors[0].Message.FileOffset, 10U);
}

class IntLitCheck : public TransformerClangTidyCheck {
public:
IntLitCheck(StringRef Name, ClangTidyContext *Context)
Expand Down
2 changes: 2 additions & 0 deletions clang/docs/ClangCommandLineReference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3145,6 +3145,8 @@ PowerPC

.. option:: -mdirect-move, -mno-direct-move

.. option:: -mefpu2

.. option:: -mfloat128, -mno-float128

.. option:: -mfprnd, -mno-fprnd
Expand Down
30 changes: 5 additions & 25 deletions clang/include/clang/AST/DeclObjC.h
Original file line number Diff line number Diff line change
Expand Up @@ -656,20 +656,8 @@ class ObjCTypeParamDecl : public TypedefNameDecl {
/// \endcode
class ObjCTypeParamList final
: private llvm::TrailingObjects<ObjCTypeParamList, ObjCTypeParamDecl *> {
/// Stores the components of a SourceRange as a POD.
struct PODSourceRange {
unsigned Begin;
unsigned End;
};

union {
/// Location of the left and right angle brackets.
PODSourceRange Brackets;

// Used only for alignment.
ObjCTypeParamDecl *AlignmentHack;
};

/// Location of the left and right angle brackets.
SourceRange Brackets;
/// The number of parameters in the list, which are tail-allocated.
unsigned NumParams;

Expand Down Expand Up @@ -717,17 +705,9 @@ class ObjCTypeParamList final
return *(end() - 1);
}

SourceLocation getLAngleLoc() const {
return SourceLocation::getFromRawEncoding(Brackets.Begin);
}

SourceLocation getRAngleLoc() const {
return SourceLocation::getFromRawEncoding(Brackets.End);
}

SourceRange getSourceRange() const {
return SourceRange(getLAngleLoc(), getRAngleLoc());
}
SourceLocation getLAngleLoc() const { return Brackets.getBegin(); }
SourceLocation getRAngleLoc() const { return Brackets.getEnd(); }
SourceRange getSourceRange() const { return Brackets; }

/// Gather the default set of type arguments to be substituted for
/// these type parameters when dealing with an unspecialized type.
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -3263,7 +3263,7 @@ def warn_attribute_dllexport_explicit_instantiation_def : Warning<
"'dllexport' attribute ignored on explicit instantiation definition">,
InGroup<IgnoredAttributes>;
def warn_invalid_initializer_from_system_header : Warning<
"invalid constructor form class in system header, should not be explicit">,
"invalid constructor from class in system header, should not be explicit">,
InGroup<DiagGroup<"invalid-initializer-from-system-header">>;
def note_used_in_initialization_here : Note<"used in initialization here">;
def err_attribute_dll_member_of_dll_class : Error<
Expand Down
7 changes: 4 additions & 3 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ def Z_Flag : Flag<["-"], "Z">, Group<Link_Group>;
def Z_Joined : Joined<["-"], "Z">;
def all__load : Flag<["-"], "all_load">;
def allowable__client : Separate<["-"], "allowable_client">;
def ansi : Flag<["-", "--"], "ansi">;
def ansi : Flag<["-", "--"], "ansi">, Group<CompileOnly_Group>;
def arch__errors__fatal : Flag<["-"], "arch_errors_fatal">;
def arch : Separate<["-"], "arch">, Flags<[NoXarchOption]>;
def arch__only : Separate<["-"], "arch_only">;
Expand Down Expand Up @@ -1600,8 +1600,8 @@ def frounding_math : Flag<["-"], "frounding-math">, Group<f_Group>, Flags<[CC1Op
MarshallingInfoFlag<"LangOpts->FPRoundingMode", "llvm::RoundingMode::NearestTiesToEven">,
Normalizer<"makeFlagToValueNormalizer(llvm::RoundingMode::Dynamic)">;
def fno_rounding_math : Flag<["-"], "fno-rounding-math">, Group<f_Group>, Flags<[CC1Option]>;
def ftrapping_math : Flag<["-"], "ftrapping-math">, Group<f_Group>, Flags<[CC1Option]>;
def fno_trapping_math : Flag<["-"], "fno-trapping-math">, Group<f_Group>, Flags<[CC1Option]>;
def ftrapping_math : Flag<["-"], "ftrapping-math">, Group<f_Group>;
def fno_trapping_math : Flag<["-"], "fno-trapping-math">, Group<f_Group>;
def ffp_contract : Joined<["-"], "ffp-contract=">, Group<f_Group>,
Flags<[CC1Option]>, HelpText<"Form fused FP ops (e.g. FMAs):"
" fast (fuses across statements disregarding pragmas)"
Expand Down Expand Up @@ -3040,6 +3040,7 @@ def mpcrel: Flag<["-"], "mpcrel">, Group<m_ppc_Features_Group>;
def mno_pcrel: Flag<["-"], "mno-pcrel">, Group<m_ppc_Features_Group>;
def mspe : Flag<["-"], "mspe">, Group<m_ppc_Features_Group>;
def mno_spe : Flag<["-"], "mno-spe">, Group<m_ppc_Features_Group>;
def mefpu2 : Flag<["-"], "mefpu2">, Group<m_ppc_Features_Group>;
def mabi_EQ_vec_extabi : Flag<["-"], "mabi=vec-extabi">, Group<m_Group>, Flags<[CC1Option]>,
HelpText<"Enable the extended Altivec ABI on AIX (AIX only). Uses volatile and nonvolatile vector registers">;
def mabi_EQ_vec_default : Flag<["-"], "mabi=vec-default">, Group<m_Group>, Flags<[CC1Option]>,
Expand Down
4 changes: 1 addition & 3 deletions clang/lib/AST/DeclObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,9 +1461,7 @@ SourceRange ObjCTypeParamDecl::getSourceRange() const {
ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
ArrayRef<ObjCTypeParamDecl *> typeParams,
SourceLocation rAngleLoc)
: NumParams(typeParams.size()) {
Brackets.Begin = lAngleLoc.getRawEncoding();
Brackets.End = rAngleLoc.getRawEncoding();
: Brackets(lAngleLoc, rAngleLoc), NumParams(typeParams.size()) {
std::copy(typeParams.begin(), typeParams.end(), begin());
}

Expand Down
6 changes: 5 additions & 1 deletion clang/lib/Basic/Targets/PPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
HasP10Vector = true;
} else if (Feature == "+pcrelative-memops") {
HasPCRelativeMemops = true;
} else if (Feature == "+spe") {
} else if (Feature == "+spe" || Feature == "+efpu2") {
HasSPE = true;
LongDoubleWidth = LongDoubleAlign = 64;
LongDoubleFormat = &llvm::APFloat::IEEEdouble();
Expand Down Expand Up @@ -402,6 +402,8 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const {
void PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
StringRef Name, bool Enabled) const {
if (Enabled) {
if (Name == "efpu2")
Features["spe"] = true;
// If we're enabling any of the vsx based features then enable vsx and
// altivec. We'll diagnose any problems later.
bool FeatureHasVSX = llvm::StringSwitch<bool>(Name)
Expand All @@ -425,6 +427,8 @@ void PPCTargetInfo::setFeatureEnabled(llvm::StringMap<bool> &Features,
else
Features[Name] = true;
} else {
if (Name == "spe")
Features["efpu2"] = false;
// If we're disabling altivec or vsx go ahead and disable all of the vsx
// features.
if ((Name == "altivec") || (Name == "vsx"))
Expand Down
7 changes: 7 additions & 0 deletions clang/lib/CodeGen/CGCXXABI.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ class CGCXXABI {
/// 'this' parameter of C++ instance methods.
virtual bool isSRetParameterAfterThis() const { return false; }

/// Returns true if the ABI permits the argument to be a homogeneous
/// aggregate.
virtual bool
isPermittedToBeHomogeneousAggregate(const CXXRecordDecl *RD) const {
return true;
};

/// Find the LLVM type used to represent the given member pointer
/// type.
virtual llvm::Type *
Expand Down
16 changes: 8 additions & 8 deletions clang/lib/CodeGen/CGCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1985,7 +1985,9 @@ void CodeGenModule::ConstructAttributeList(
FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
NBA = Fn->getAttr<NoBuiltinAttr>();
}
if (!AttrOnCallSite && TargetDecl->hasAttr<NoMergeAttr>())
// Only place nomerge attribute on call sites, never functions. This
// allows it to work on indirect virtual function calls.
if (AttrOnCallSite && TargetDecl->hasAttr<NoMergeAttr>())
FuncAttrs.addAttribute(llvm::Attribute::NoMerge);
}

Expand Down Expand Up @@ -5018,13 +5020,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
llvm::Attribute::StrictFP);

// Add nomerge attribute to the call-site if the callee function doesn't have
// the attribute.
if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(TargetDecl))
if (!FD->hasAttr<NoMergeAttr>() && InNoMergeAttributedStmt)
Attrs = Attrs.addAttribute(getLLVMContext(),
llvm::AttributeList::FunctionIndex,
llvm::Attribute::NoMerge);
// Add call-site nomerge attribute if exists.
if (InNoMergeAttributedStmt)
Attrs =
Attrs.addAttribute(getLLVMContext(), llvm::AttributeList::FunctionIndex,
llvm::Attribute::NoMerge);

// Apply some call-site-specific attributes.
// TODO: work this into building the attribute set.
Expand Down
37 changes: 24 additions & 13 deletions clang/lib/CodeGen/CGExprScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1212,13 +1212,14 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
// padding is enabled because overflow into this bit is undefined
// behavior.
return Builder.CreateIsNotNull(Src, "tobool");
if (DstType->isFixedPointType() || DstType->isIntegerType())
if (DstType->isFixedPointType() || DstType->isIntegerType() ||
DstType->isRealFloatingType())
return EmitFixedPointConversion(Src, SrcType, DstType, Loc);

llvm_unreachable(
"Unhandled scalar conversion from a fixed point type to another type.");
} else if (DstType->isFixedPointType()) {
if (SrcType->isIntegerType())
if (SrcType->isIntegerType() || SrcType->isRealFloatingType())
// This also includes converting booleans and enums to fixed point types.
return EmitFixedPointConversion(Src, SrcType, DstType, Loc);

Expand Down Expand Up @@ -1434,19 +1435,29 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
Value *ScalarExprEmitter::EmitFixedPointConversion(Value *Src, QualType SrcTy,
QualType DstTy,
SourceLocation Loc) {
auto SrcFPSema = CGF.getContext().getFixedPointSemantics(SrcTy);
auto DstFPSema = CGF.getContext().getFixedPointSemantics(DstTy);
llvm::FixedPointBuilder<CGBuilderTy> FPBuilder(Builder);
llvm::Value *Result;
if (DstTy->isIntegerType())
Result = FPBuilder.CreateFixedToInteger(Src, SrcFPSema,
DstFPSema.getWidth(),
DstFPSema.isSigned());
else if (SrcTy->isIntegerType())
Result = FPBuilder.CreateIntegerToFixed(Src, SrcFPSema.isSigned(),
DstFPSema);
else
Result = FPBuilder.CreateFixedToFixed(Src, SrcFPSema, DstFPSema);
if (SrcTy->isRealFloatingType())
Result = FPBuilder.CreateFloatingToFixed(Src,
CGF.getContext().getFixedPointSemantics(DstTy));
else if (DstTy->isRealFloatingType())
Result = FPBuilder.CreateFixedToFloating(Src,
CGF.getContext().getFixedPointSemantics(SrcTy),
ConvertType(DstTy));
else {
auto SrcFPSema = CGF.getContext().getFixedPointSemantics(SrcTy);
auto DstFPSema = CGF.getContext().getFixedPointSemantics(DstTy);

if (DstTy->isIntegerType())
Result = FPBuilder.CreateFixedToInteger(Src, SrcFPSema,
DstFPSema.getWidth(),
DstFPSema.isSigned());
else if (SrcTy->isIntegerType())
Result = FPBuilder.CreateIntegerToFixed(Src, SrcFPSema.isSigned(),
DstFPSema);
else
Result = FPBuilder.CreateFixedToFixed(Src, SrcFPSema, DstFPSema);
}
return Result;
}

Expand Down
3 changes: 0 additions & 3 deletions clang/lib/CodeGen/CodeGenModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1772,9 +1772,6 @@ void CodeGenModule::SetLLVMFunctionAttributesForDefinition(const Decl *D,
B.addAttribute(llvm::Attribute::MinSize);
}

if (D->hasAttr<NoMergeAttr>())
B.addAttribute(llvm::Attribute::NoMerge);

F->addAttributes(llvm::AttributeList::FunctionIndex, B);

unsigned alignment = D->getMaxAlignment() / Context.getCharWidth();
Expand Down
Loading

0 comments on commit b16080c

Please sign in to comment.