Skip to content

Commit

Permalink
Merged master:ef748583c24d into amd-gfx:ffaf4aaa460d
Browse files Browse the repository at this point in the history
Local branch amd-gfx ffaf4aa Revert "[AMDGPU] Insert waterfall loops for divergent calls"
Remote branch master ef74858 [CostModel] rearrange basic intrinsic cost implementation

Change-Id: Idf1971e3fb0b297ab705beb11f0d071fcf12535a
  • Loading branch information
piotrAMD committed Oct 14, 2020
2 parents ffaf4aa + ef74858 commit b2b452e
Show file tree
Hide file tree
Showing 501 changed files with 13,058 additions and 3,654 deletions.
1 change: 1 addition & 0 deletions clang-tools-extra/clangd/ClangdServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
BGOpts.ContextProvider = [this](PathRef P) {
return createProcessingContext(P);
};
BGOpts.CollectMainFileRefs = Opts.CollectMainFileRefs;
BackgroundIdx = std::make_unique<BackgroundIndex>(
TFS, CDB,
BackgroundIndexStorage::createDiskBackedStorageFactory(
Expand Down
36 changes: 28 additions & 8 deletions clang-tools-extra/clangd/FindSymbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,13 @@ namespace {
llvm::Optional<DocumentSymbol> declToSym(ASTContext &Ctx, const NamedDecl &ND) {
auto &SM = Ctx.getSourceManager();

SourceLocation NameLoc = nameLocation(ND, SM);
SourceLocation BeginLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getBeginLoc()));
SourceLocation EndLoc = SM.getSpellingLoc(SM.getFileLoc(ND.getEndLoc()));
const auto SymbolRange =
toHalfOpenFileRange(SM, Ctx.getLangOpts(), {BeginLoc, EndLoc});
if (!SymbolRange)
return llvm::None;

Position NameBegin = sourceLocToPosition(SM, NameLoc);
Position NameEnd = sourceLocToPosition(
SM, Lexer::getLocForEndOfToken(NameLoc, 0, SM, Ctx.getLangOpts()));

index::SymbolInfo SymInfo = index::getSymbolInfo(&ND);
// FIXME: this is not classifying constructors, destructors and operators
// correctly (they're all "methods").
Expand All @@ -194,10 +189,35 @@ llvm::Optional<DocumentSymbol> declToSym(ASTContext &Ctx, const NamedDecl &ND) {
SI.deprecated = ND.isDeprecated();
SI.range = Range{sourceLocToPosition(SM, SymbolRange->getBegin()),
sourceLocToPosition(SM, SymbolRange->getEnd())};
SI.selectionRange = Range{NameBegin, NameEnd};

SourceLocation NameLoc = ND.getLocation();
SourceLocation FallbackNameLoc;
if (NameLoc.isMacroID()) {
if (isSpelledInSource(NameLoc, SM)) {
// Prefer the spelling loc, but save the expansion loc as a fallback.
FallbackNameLoc = SM.getExpansionLoc(NameLoc);
NameLoc = SM.getSpellingLoc(NameLoc);
} else {
NameLoc = SM.getExpansionLoc(NameLoc);
}
}
auto ComputeSelectionRange = [&](SourceLocation L) -> Range {
Position NameBegin = sourceLocToPosition(SM, L);
Position NameEnd = sourceLocToPosition(
SM, Lexer::getLocForEndOfToken(L, 0, SM, Ctx.getLangOpts()));
return Range{NameBegin, NameEnd};
};

SI.selectionRange = ComputeSelectionRange(NameLoc);
if (!SI.range.contains(SI.selectionRange) && FallbackNameLoc.isValid()) {
// 'selectionRange' must be contained in 'range'. In cases where clang
// reports unrelated ranges, we first try falling back to the expansion
// loc for the selection range.
SI.selectionRange = ComputeSelectionRange(FallbackNameLoc);
}
if (!SI.range.contains(SI.selectionRange)) {
// 'selectionRange' must be contained in 'range', so in cases where clang
// reports unrelated ranges we need to reconcile somehow.
// If the containment relationship still doesn't hold, throw away
// 'range' and use 'selectionRange' for both.
SI.range = SI.selectionRange;
}
return SI;
Expand Down
66 changes: 55 additions & 11 deletions clang-tools-extra/clangd/FindTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ const auto StaticFilter = [](const NamedDecl *D) {
return !D->isCXXInstanceMember();
};
const auto ValueFilter = [](const NamedDecl *D) { return isa<ValueDecl>(D); };
const auto TypeFilter = [](const NamedDecl *D) { return isa<TypeDecl>(D); };
const auto TemplateFilter = [](const NamedDecl *D) {
return isa<TemplateDecl>(D);
};

// Given the type T of a dependent expression that appears of the LHS of a
// "->", heuristically find a corresponding pointee type in whose scope we
Expand Down Expand Up @@ -219,19 +223,45 @@ std::vector<const NamedDecl *> resolveExprToDecls(const Expr *E) {
return {};
}

// Try to heuristically resolve the type of a possibly-dependent expression `E`.
const Type *resolveExprToType(const Expr *E) {
std::vector<const NamedDecl *> Decls = resolveExprToDecls(E);
const Type *resolveDeclsToType(const std::vector<const NamedDecl *> &Decls) {
if (Decls.size() != 1) // Names an overload set -- just bail.
return nullptr;
if (const auto *TD = dyn_cast<TypeDecl>(Decls[0])) {
return TD->getTypeForDecl();
} else if (const auto *VD = dyn_cast<ValueDecl>(Decls[0])) {
}
if (const auto *VD = dyn_cast<ValueDecl>(Decls[0])) {
return VD->getType().getTypePtrOrNull();
}
return nullptr;
}

// Try to heuristically resolve the type of a possibly-dependent expression `E`.
const Type *resolveExprToType(const Expr *E) {
return resolveDeclsToType(resolveExprToDecls(E));
}

// Try to heuristically resolve the type of a possibly-dependent nested name
// specifier.
const Type *resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS) {
if (!NNS)
return nullptr;

switch (NNS->getKind()) {
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate:
return NNS->getAsType();
case NestedNameSpecifier::Identifier: {
return resolveDeclsToType(getMembersReferencedViaDependentName(
resolveNestedNameSpecifierToType(NNS->getPrefix()),
[&](const ASTContext &) { return NNS->getAsIdentifier(); },
TypeFilter));
}
default:
break;
}
return nullptr;
}

const NamedDecl *getTemplatePattern(const NamedDecl *D) {
if (const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(D)) {
if (const auto *Result = CRD->getTemplateInstantiationPattern())
Expand Down Expand Up @@ -291,10 +321,8 @@ const NamedDecl *getTemplatePattern(const NamedDecl *D) {
// and both are lossy. We must know upfront what the caller ultimately wants.
//
// FIXME: improve common dependent scope using name lookup in primary templates.
// We currently handle DependentScopeDeclRefExpr and
// CXXDependentScopeMemberExpr, but some other constructs remain to be handled:
// - DependentTemplateSpecializationType,
// - DependentNameType
// We currently handle several dependent constructs, but some others remain to
// be handled:
// - UnresolvedUsingTypenameDecl
struct TargetFinder {
using RelSet = DeclRelationSet;
Expand Down Expand Up @@ -536,6 +564,23 @@ struct TargetFinder {
if (auto *TD = DTST->getTemplateName().getAsTemplateDecl())
Outer.add(TD->getTemplatedDecl(), Flags | Rel::TemplatePattern);
}
void VisitDependentNameType(const DependentNameType *DNT) {
for (const NamedDecl *ND : getMembersReferencedViaDependentName(
resolveNestedNameSpecifierToType(DNT->getQualifier()),
[DNT](ASTContext &) { return DNT->getIdentifier(); },
TypeFilter)) {
Outer.add(ND, Flags);
}
}
void VisitDependentTemplateSpecializationType(
const DependentTemplateSpecializationType *DTST) {
for (const NamedDecl *ND : getMembersReferencedViaDependentName(
resolveNestedNameSpecifierToType(DTST->getQualifier()),
[DTST](ASTContext &) { return DTST->getIdentifier(); },
TemplateFilter)) {
Outer.add(ND, Flags);
}
}
void VisitTypedefType(const TypedefType *TT) {
Outer.add(TT->getDecl(), Flags);
}
Expand Down Expand Up @@ -591,17 +636,16 @@ struct TargetFinder {
return;
debug(*NNS, Flags);
switch (NNS->getKind()) {
case NestedNameSpecifier::Identifier:
return;
case NestedNameSpecifier::Namespace:
add(NNS->getAsNamespace(), Flags);
return;
case NestedNameSpecifier::NamespaceAlias:
add(NNS->getAsNamespaceAlias(), Flags);
return;
case NestedNameSpecifier::Identifier:
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate:
add(QualType(NNS->getAsType(), 0), Flags);
add(QualType(resolveNestedNameSpecifierToType(NNS), 0), Flags);
return;
case NestedNameSpecifier::Global:
// This should be TUDecl, but we can't get a pointer to it!
Expand Down
18 changes: 13 additions & 5 deletions clang-tools-extra/clangd/unittests/FindSymbolsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,19 +639,27 @@ TEST(DocumentSymbols, FromMacro) {
#define FF(name) \
class name##_Test {};
$expansion[[FF]](abc);
$expansion1[[FF]](abc);
#define FF2() \
class $spelling[[Test]] {};
class Test {};
FF2();
$expansion2[[FF2]]();
#define FF3() \
void waldo()
$fullDef[[FF3() {
int var = 42;
}]]
)");
TU.Code = Main.code().str();
EXPECT_THAT(
getSymbols(TU.build()),
ElementsAre(
AllOf(WithName("abc_Test"), SymNameRange(Main.range("expansion"))),
AllOf(WithName("Test"), SymNameRange(Main.range("spelling")))));
AllOf(WithName("abc_Test"), SymNameRange(Main.range("expansion1"))),
AllOf(WithName("Test"), SymNameRange(Main.range("expansion2"))),
AllOf(WithName("waldo"), SymRange(Main.range("fullDef")))));
}

TEST(DocumentSymbols, FuncTemplates) {
Expand Down
48 changes: 48 additions & 0 deletions clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,54 @@ TEST_F(TargetDeclTest, DependentExprs) {
"template <typename T> T convert() const");
}

TEST_F(TargetDeclTest, DependentTypes) {
Flags = {"-fno-delayed-template-parsing"};

// Heuristic resolution of dependent type name
Code = R"cpp(
template <typename>
struct A { struct B {}; };
template <typename T>
void foo(typename A<T>::[[B]]);
)cpp";
EXPECT_DECLS("DependentNameTypeLoc", "struct B");

// Heuristic resolution of dependent type name which doesn't get a TypeLoc
Code = R"cpp(
template <typename>
struct A { struct B { struct C {}; }; };
template <typename T>
void foo(typename A<T>::[[B]]::C);
)cpp";
EXPECT_DECLS("NestedNameSpecifierLoc", "struct B");

// Heuristic resolution of dependent type name whose qualifier is also
// dependent
Code = R"cpp(
template <typename>
struct A { struct B { struct C {}; }; };
template <typename T>
void foo(typename A<T>::B::[[C]]);
)cpp";
EXPECT_DECLS("DependentNameTypeLoc", "struct C");

// Heuristic resolution of dependent template name
Code = R"cpp(
template <typename>
struct A {
template <typename> struct B {};
};
template <typename T>
void foo(typename A<T>::template [[B]]<int>);
)cpp";
EXPECT_DECLS("DependentTemplateSpecializationTypeLoc",
"template <typename> struct B");
}

TEST_F(TargetDeclTest, ObjC) {
Flags = {"-xobjective-c"};
Code = R"cpp(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ misc-unused-alias-decls


Finds unused namespace alias declarations.

.. code-block:: c++

namespace my_namespace {
class C {};
}
namespace unused_alias = ::my_namespace;
2 changes: 2 additions & 0 deletions clang/docs/ClangCommandLineReference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3261,6 +3261,8 @@ X86

.. option:: -mgfni, -mno-gfni

.. option:: -mhreset, -mno-hreset

.. option:: -minvpcid, -mno-invpcid

.. option:: -mkl, -mno-kl
Expand Down
5 changes: 4 additions & 1 deletion clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ X86 Support in Clang
- The x86 intrinsics ``__rorb``, ``__rorw``, ``__rord``, ``__rorq`, ``_rotr``,
``_rotwr`` and ``_lrotr`` may now be used within constant expressions.

- Support for -march=sapphirerapids was added.
- Support for ``-march=sapphirerapids`` was added.

- Support for ``-march=x86-64-v[234]`` has been added.
See :doc:`UsersManual` for details about these micro-architecture levels.

- The -mtune command line option is no longer ignored for X86. This can be used
to request microarchitectural optimizations independent on -march. -march=<cpu>
Expand Down
5 changes: 5 additions & 0 deletions clang/docs/ThinLTO.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ be reduced to ``N`` via:
- lld-link:
``/opt:lldltojobs=N``

Other possible values for ``N`` are:
- 0: Use one thread per physical core (default)
- 1: Use a single thread only (disable multi-threading)
- all: Use one thread per logical core (uses all hyper-threads)

Incremental
-----------
.. _incremental:
Expand Down
9 changes: 9 additions & 0 deletions clang/docs/UsersManual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3201,6 +3201,15 @@ and the ABI remains 32-bit but the assembler emits instructions
appropriate for a CPU running in 16-bit mode, with address-size and
operand-size prefixes to enable 32-bit addressing and operations.

Several micro-architecture levels as specified by the x86-64 psABI are defined.
They are cumulative in the sense that features from previous levels are
implicitly included in later levels.

- ``-march=x86-64``: CMOV, CMPXCHG8B, FPU, FXSR, MMX, FXSR, SCE, SSE, SSE2
- ``-march=x86-64-v2``: (close to Nehalem) CMPXCHG16B, LAHF-SAHF, POPCNT, SSE3, SSE4.1, SSE4.2, SSSE3
- ``-march=x86-64-v3``: (close to Haswell) AVX, AVX2, BMI1, BMI2, F16C, FMA, LZCNT, MOVBE, XSAVE
- ``-march=x86-64-v4``: AVX512F, AVX512BW, AVX512CD, AVX512DQ, AVX512VL

ARM
^^^

Expand Down
16 changes: 13 additions & 3 deletions clang/include/clang/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,16 @@ struct TypeInfo {
: Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {}
};

struct TypeInfoChars {
CharUnits Width;
CharUnits Align;
bool AlignIsRequired : 1;

TypeInfoChars() : AlignIsRequired(false) {}
TypeInfoChars(CharUnits Width, CharUnits Align, bool AlignIsRequired)
: Width(Width), Align(Align), AlignIsRequired(AlignIsRequired) {}
};

/// Holds long-lived AST nodes (such as types and decls) that can be
/// referred to throughout the semantic analysis of a file.
class ASTContext : public RefCountedBase<ASTContext> {
Expand Down Expand Up @@ -2169,10 +2179,10 @@ class ASTContext : public RefCountedBase<ASTContext> {

// getTypeInfoDataSizeInChars - Return the size of a type, in chars. If the
// type is a record, its data size is returned.
std::pair<CharUnits, CharUnits> getTypeInfoDataSizeInChars(QualType T) const;
TypeInfoChars getTypeInfoDataSizeInChars(QualType T) const;

std::pair<CharUnits, CharUnits> getTypeInfoInChars(const Type *T) const;
std::pair<CharUnits, CharUnits> getTypeInfoInChars(QualType T) const;
TypeInfoChars getTypeInfoInChars(const Type *T) const;
TypeInfoChars getTypeInfoInChars(QualType T) const;

/// Determine if the alignment the type has was required using an
/// alignment attribute.
Expand Down
8 changes: 8 additions & 0 deletions clang/include/clang/AST/OperationKinds.def
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ CAST_OPERATION(IntegralToBoolean)
/// float f = i;
CAST_OPERATION(IntegralToFloating)

/// CK_FloatingToFixedPoint - Floating to fixed point.
/// _Accum a = f;
CAST_OPERATION(FloatingToFixedPoint)

/// CK_FixedPointToFloating - Fixed point to floating.
/// (float) 2.5k
CAST_OPERATION(FixedPointToFloating)

/// CK_FixedPointCast - Fixed point to fixed point.
/// (_Accum) 0.5r
CAST_OPERATION(FixedPointCast)
Expand Down
Loading

0 comments on commit b2b452e

Please sign in to comment.