svn commit: r359336 - in vendor/llvm-project/release-10.x: clang/include/clang/Sema clang/lib/Driver/ToolChains clang/lib/Parse clang/lib/Sema llvm/lib/Transforms/Scalar
Dimitry Andric
dim at FreeBSD.org
Thu Mar 26 17:51:40 UTC 2020
Author: dim
Date: Thu Mar 26 17:40:50 2020
New Revision: 359336
URL: https://svnweb.freebsd.org/changeset/base/359336
Log:
Vendor import of llvm-project tag llvmorg-10.0.0-0-gd32170dbd5b (aka
10.0.0 release).
Modified:
vendor/llvm-project/release-10.x/clang/include/clang/Sema/Sema.h
vendor/llvm-project/release-10.x/clang/lib/Driver/ToolChains/Cuda.cpp
vendor/llvm-project/release-10.x/clang/lib/Driver/ToolChains/Cuda.h
vendor/llvm-project/release-10.x/clang/lib/Parse/ParseDecl.cpp
vendor/llvm-project/release-10.x/clang/lib/Parse/ParseTemplate.cpp
vendor/llvm-project/release-10.x/clang/lib/Sema/SemaTemplate.cpp
vendor/llvm-project/release-10.x/clang/lib/Sema/TreeTransform.h
vendor/llvm-project/release-10.x/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
Modified: vendor/llvm-project/release-10.x/clang/include/clang/Sema/Sema.h
==============================================================================
--- vendor/llvm-project/release-10.x/clang/include/clang/Sema/Sema.h Thu Mar 26 17:34:17 2020 (r359335)
+++ vendor/llvm-project/release-10.x/clang/include/clang/Sema/Sema.h Thu Mar 26 17:40:50 2020 (r359336)
@@ -6885,7 +6885,8 @@ class Sema final { (public)
QualType ObjectType, bool EnteringContext,
bool &MemberOfUnknownSpecialization,
SourceLocation TemplateKWLoc = SourceLocation(),
- AssumedTemplateKind *ATK = nullptr);
+ AssumedTemplateKind *ATK = nullptr,
+ bool Disambiguation = false);
TemplateNameKind isTemplateName(Scope *S,
CXXScopeSpec &SS,
@@ -6894,7 +6895,8 @@ class Sema final { (public)
ParsedType ObjectType,
bool EnteringContext,
TemplateTy &Template,
- bool &MemberOfUnknownSpecialization);
+ bool &MemberOfUnknownSpecialization,
+ bool Disambiguation = false);
/// Try to resolve an undeclared template name as a type template.
///
Modified: vendor/llvm-project/release-10.x/clang/lib/Driver/ToolChains/Cuda.cpp
==============================================================================
--- vendor/llvm-project/release-10.x/clang/lib/Driver/ToolChains/Cuda.cpp Thu Mar 26 17:34:17 2020 (r359335)
+++ vendor/llvm-project/release-10.x/clang/lib/Driver/ToolChains/Cuda.cpp Thu Mar 26 17:40:50 2020 (r359336)
@@ -32,26 +32,30 @@ using namespace llvm::opt;
// Parses the contents of version.txt in an CUDA installation. It should
// contain one line of the from e.g. "CUDA Version 7.5.2".
-static CudaVersion ParseCudaVersionFile(const Driver &D, llvm::StringRef V) {
+void CudaInstallationDetector::ParseCudaVersionFile(llvm::StringRef V) {
+ Version = CudaVersion::UNKNOWN;
if (!V.startswith("CUDA Version "))
- return CudaVersion::UNKNOWN;
+ return;
V = V.substr(strlen("CUDA Version "));
SmallVector<StringRef,4> VersionParts;
V.split(VersionParts, '.');
if (VersionParts.size() < 2)
- return CudaVersion::UNKNOWN;
- std::string MajorMinor = join_items(".", VersionParts[0], VersionParts[1]);
- CudaVersion Version = CudaStringToVersion(MajorMinor);
+ return;
+ DetectedVersion = join_items(".", VersionParts[0], VersionParts[1]);
+ Version = CudaStringToVersion(DetectedVersion);
if (Version != CudaVersion::UNKNOWN)
- return Version;
+ return;
- // Issue a warning and assume that the version we've found is compatible with
- // the latest version we support.
- D.Diag(diag::warn_drv_unknown_cuda_version)
- << MajorMinor << CudaVersionToString(CudaVersion::LATEST);
- return CudaVersion::LATEST;
+ Version = CudaVersion::LATEST;
+ DetectedVersionIsNotSupported = true;
}
+void CudaInstallationDetector::WarnIfUnsupportedVersion() {
+ if (DetectedVersionIsNotSupported)
+ D.Diag(diag::warn_drv_unknown_cuda_version)
+ << DetectedVersion << CudaVersionToString(Version);
+}
+
CudaInstallationDetector::CudaInstallationDetector(
const Driver &D, const llvm::Triple &HostTriple,
const llvm::opt::ArgList &Args)
@@ -147,7 +151,7 @@ CudaInstallationDetector::CudaInstallationDetector(
// version.txt isn't present.
Version = CudaVersion::CUDA_70;
} else {
- Version = ParseCudaVersionFile(D, (*VersionFile)->getBuffer());
+ ParseCudaVersionFile((*VersionFile)->getBuffer());
}
if (Version >= CudaVersion::CUDA_90) {
@@ -565,8 +569,10 @@ CudaToolChain::CudaToolChain(const Driver &D, const ll
const Action::OffloadKind OK)
: ToolChain(D, Triple, Args), HostTC(HostTC),
CudaInstallation(D, HostTC.getTriple(), Args), OK(OK) {
- if (CudaInstallation.isValid())
+ if (CudaInstallation.isValid()) {
+ CudaInstallation.WarnIfUnsupportedVersion();
getProgramPaths().push_back(CudaInstallation.getBinPath());
+ }
// Lookup binaries into the driver directory, this is used to
// discover the clang-offload-bundler executable.
getProgramPaths().push_back(getDriver().Dir);
Modified: vendor/llvm-project/release-10.x/clang/lib/Driver/ToolChains/Cuda.h
==============================================================================
--- vendor/llvm-project/release-10.x/clang/lib/Driver/ToolChains/Cuda.h Thu Mar 26 17:34:17 2020 (r359335)
+++ vendor/llvm-project/release-10.x/clang/lib/Driver/ToolChains/Cuda.h Thu Mar 26 17:40:50 2020 (r359336)
@@ -30,6 +30,8 @@ class CudaInstallationDetector { (private)
const Driver &D;
bool IsValid = false;
CudaVersion Version = CudaVersion::UNKNOWN;
+ std::string DetectedVersion;
+ bool DetectedVersionIsNotSupported = false;
std::string InstallPath;
std::string BinPath;
std::string LibPath;
@@ -75,6 +77,10 @@ class CudaInstallationDetector { (private)
std::string getLibDeviceFile(StringRef Gpu) const {
return LibDeviceMap.lookup(Gpu);
}
+ void WarnIfUnsupportedVersion();
+
+private:
+ void ParseCudaVersionFile(llvm::StringRef V);
};
namespace tools {
Modified: vendor/llvm-project/release-10.x/clang/lib/Parse/ParseDecl.cpp
==============================================================================
--- vendor/llvm-project/release-10.x/clang/lib/Parse/ParseDecl.cpp Thu Mar 26 17:34:17 2020 (r359335)
+++ vendor/llvm-project/release-10.x/clang/lib/Parse/ParseDecl.cpp Thu Mar 26 17:40:50 2020 (r359336)
@@ -3252,6 +3252,9 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
goto DoneWithDeclSpec;
if (isTypeConstraintAnnotation())
continue;
+ if (NextToken().is(tok::annot_template_id))
+ // Might have been annotated by TryAnnotateTypeConstraint.
+ continue;
// Eat the scope spec so the identifier is current.
ConsumeAnnotationToken();
ParsedAttributesWithRange Attrs(AttrFactory);
@@ -3404,6 +3407,9 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
if (TryAnnotateTypeConstraint())
goto DoneWithDeclSpec;
if (isTypeConstraintAnnotation())
+ continue;
+ if (Tok.is(tok::annot_template_id))
+ // Might have been annotated by TryAnnotateTypeConstraint.
continue;
ParsedAttributesWithRange Attrs(AttrFactory);
if (ParseImplicitInt(DS, nullptr, TemplateInfo, AS, DSContext, Attrs)) {
Modified: vendor/llvm-project/release-10.x/clang/lib/Parse/ParseTemplate.cpp
==============================================================================
--- vendor/llvm-project/release-10.x/clang/lib/Parse/ParseTemplate.cpp Thu Mar 26 17:34:17 2020 (r359335)
+++ vendor/llvm-project/release-10.x/clang/lib/Parse/ParseTemplate.cpp Thu Mar 26 17:40:50 2020 (r359336)
@@ -710,7 +710,8 @@ bool Parser::TryAnnotateTypeConstraint() {
/*ObjectType=*/ParsedType(),
/*EnteringContext=*/false,
PossibleConcept,
- MemberOfUnknownSpecialization);
+ MemberOfUnknownSpecialization,
+ /*Disambiguation=*/true);
if (MemberOfUnknownSpecialization || !PossibleConcept ||
TNK != TNK_Concept_template) {
if (SS.isNotEmpty())
Modified: vendor/llvm-project/release-10.x/clang/lib/Sema/SemaTemplate.cpp
==============================================================================
--- vendor/llvm-project/release-10.x/clang/lib/Sema/SemaTemplate.cpp Thu Mar 26 17:34:17 2020 (r359335)
+++ vendor/llvm-project/release-10.x/clang/lib/Sema/SemaTemplate.cpp Thu Mar 26 17:40:50 2020 (r359336)
@@ -174,7 +174,8 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
ParsedType ObjectTypePtr,
bool EnteringContext,
TemplateTy &TemplateResult,
- bool &MemberOfUnknownSpecialization) {
+ bool &MemberOfUnknownSpecialization,
+ bool Disambiguation) {
assert(getLangOpts().CPlusPlus && "No template names in C!");
DeclarationName TName;
@@ -204,7 +205,7 @@ TemplateNameKind Sema::isTemplateName(Scope *S,
LookupResult R(*this, TName, Name.getBeginLoc(), LookupOrdinaryName);
if (LookupTemplateName(R, S, SS, ObjectType, EnteringContext,
MemberOfUnknownSpecialization, SourceLocation(),
- &AssumedTemplate))
+ &AssumedTemplate, Disambiguation))
return TNK_Non_template;
if (AssumedTemplate != AssumedTemplateKind::None) {
@@ -371,7 +372,8 @@ bool Sema::LookupTemplateName(LookupResult &Found,
bool EnteringContext,
bool &MemberOfUnknownSpecialization,
SourceLocation TemplateKWLoc,
- AssumedTemplateKind *ATK) {
+ AssumedTemplateKind *ATK,
+ bool Disambiguation) {
if (ATK)
*ATK = AssumedTemplateKind::None;
@@ -494,8 +496,9 @@ bool Sema::LookupTemplateName(LookupResult &Found,
}
}
- if (Found.empty() && !IsDependent) {
- // If we did not find any names, attempt to correct any typos.
+ if (Found.empty() && !IsDependent && !Disambiguation) {
+ // If we did not find any names, and this is not a disambiguation, attempt
+ // to correct any typos.
DeclarationName Name = Found.getLookupName();
Found.clear();
// Simple filter callback that, for keywords, only accepts the C++ *_cast
Modified: vendor/llvm-project/release-10.x/clang/lib/Sema/TreeTransform.h
==============================================================================
--- vendor/llvm-project/release-10.x/clang/lib/Sema/TreeTransform.h Thu Mar 26 17:34:17 2020 (r359335)
+++ vendor/llvm-project/release-10.x/clang/lib/Sema/TreeTransform.h Thu Mar 26 17:40:50 2020 (r359336)
@@ -11303,7 +11303,7 @@ TreeTransform<Derived>::TransformRequiresExpr(Requires
SemaRef, Sema::ExpressionEvaluationContext::Unevaluated);
RequiresExprBodyDecl *Body = RequiresExprBodyDecl::Create(
- getSema().Context, E->getBody()->getDeclContext(),
+ getSema().Context, getSema().CurContext,
E->getBody()->getBeginLoc());
Sema::ContextRAII SavedContext(getSema(), Body, /*NewThisContext*/false);
Modified: vendor/llvm-project/release-10.x/llvm/lib/Transforms/Scalar/EarlyCSE.cpp
==============================================================================
--- vendor/llvm-project/release-10.x/llvm/lib/Transforms/Scalar/EarlyCSE.cpp Thu Mar 26 17:34:17 2020 (r359335)
+++ vendor/llvm-project/release-10.x/llvm/lib/Transforms/Scalar/EarlyCSE.cpp Thu Mar 26 17:40:50 2020 (r359336)
@@ -152,13 +152,50 @@ static bool matchSelectWithOptionalNotCond(Value *V, V
std::swap(A, B);
}
- // Set flavor if we find a match, or set it to unknown otherwise; in
- // either case, return true to indicate that this is a select we can
- // process.
- if (auto *CmpI = dyn_cast<ICmpInst>(Cond))
- Flavor = matchDecomposedSelectPattern(CmpI, A, B, A, B).Flavor;
- else
- Flavor = SPF_UNKNOWN;
+ // Match canonical forms of abs/nabs/min/max. We are not using ValueTracking's
+ // more powerful matchSelectPattern() because it may rely on instruction flags
+ // such as "nsw". That would be incompatible with the current hashing
+ // mechanism that may remove flags to increase the likelihood of CSE.
+
+ // These are the canonical forms of abs(X) and nabs(X) created by instcombine:
+ // %N = sub i32 0, %X
+ // %C = icmp slt i32 %X, 0
+ // %ABS = select i1 %C, i32 %N, i32 %X
+ //
+ // %N = sub i32 0, %X
+ // %C = icmp slt i32 %X, 0
+ // %NABS = select i1 %C, i32 %X, i32 %N
+ Flavor = SPF_UNKNOWN;
+ CmpInst::Predicate Pred;
+ if (match(Cond, m_ICmp(Pred, m_Specific(B), m_ZeroInt())) &&
+ Pred == ICmpInst::ICMP_SLT && match(A, m_Neg(m_Specific(B)))) {
+ // ABS: B < 0 ? -B : B
+ Flavor = SPF_ABS;
+ return true;
+ }
+ if (match(Cond, m_ICmp(Pred, m_Specific(A), m_ZeroInt())) &&
+ Pred == ICmpInst::ICMP_SLT && match(B, m_Neg(m_Specific(A)))) {
+ // NABS: A < 0 ? A : -A
+ Flavor = SPF_NABS;
+ return true;
+ }
+
+ if (!match(Cond, m_ICmp(Pred, m_Specific(A), m_Specific(B)))) {
+ // Check for commuted variants of min/max by swapping predicate.
+ // If we do not match the standard or commuted patterns, this is not a
+ // recognized form of min/max, but it is still a select, so return true.
+ if (!match(Cond, m_ICmp(Pred, m_Specific(B), m_Specific(A))))
+ return true;
+ Pred = ICmpInst::getSwappedPredicate(Pred);
+ }
+
+ switch (Pred) {
+ case CmpInst::ICMP_UGT: Flavor = SPF_UMAX; break;
+ case CmpInst::ICMP_ULT: Flavor = SPF_UMIN; break;
+ case CmpInst::ICMP_SGT: Flavor = SPF_SMAX; break;
+ case CmpInst::ICMP_SLT: Flavor = SPF_SMIN; break;
+ default: break;
+ }
return true;
}
More information about the svn-src-vendor
mailing list