aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/tools
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/tools')
-rw-r--r--contrib/llvm/tools/clang/include/clang-c/Index.h6
-rw-r--r--contrib/llvm/tools/clang/include/clang/AST/Decl.h4
-rw-r--r--contrib/llvm/tools/clang/include/clang/AST/DeclTemplate.h3
-rw-r--r--contrib/llvm/tools/clang/include/clang/AST/RecursiveASTVisitor.h3
-rw-r--r--contrib/llvm/tools/clang/include/clang/AST/StmtOpenMP.h69
-rw-r--r--contrib/llvm/tools/clang/include/clang/AST/TypeLoc.h28
-rw-r--r--contrib/llvm/tools/clang/include/clang/Basic/AttrDocs.td1
-rw-r--r--contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td4
-rw-r--r--contrib/llvm/tools/clang/include/clang/Basic/OpenMPKinds.def35
-rw-r--r--contrib/llvm/tools/clang/include/clang/Basic/StmtNodes.td1
-rw-r--r--contrib/llvm/tools/clang/include/clang/Driver/CLCompatOptions.td7
-rw-r--r--contrib/llvm/tools/clang/include/clang/Driver/Options.td1
-rw-r--r--contrib/llvm/tools/clang/include/clang/Index/IndexSymbol.h8
-rw-r--r--contrib/llvm/tools/clang/include/clang/Lex/HeaderSearch.h3
-rw-r--r--contrib/llvm/tools/clang/include/clang/Lex/ModuleMap.h8
-rw-r--r--contrib/llvm/tools/clang/include/clang/Parse/Parser.h7
-rw-r--r--contrib/llvm/tools/clang/include/clang/Sema/Sema.h20
-rw-r--r--contrib/llvm/tools/clang/include/clang/Serialization/ASTBitCodes.h1
-rw-r--r--contrib/llvm/tools/clang/lib/AST/ASTImporter.cpp3
-rw-r--r--contrib/llvm/tools/clang/lib/AST/Decl.cpp12
-rw-r--r--contrib/llvm/tools/clang/lib/AST/DeclTemplate.cpp4
-rw-r--r--contrib/llvm/tools/clang/lib/AST/Expr.cpp8
-rw-r--r--contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp13
-rw-r--r--contrib/llvm/tools/clang/lib/AST/StmtOpenMP.cpp56
-rw-r--r--contrib/llvm/tools/clang/lib/AST/StmtPrinter.cpp6
-rw-r--r--contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp5
-rw-r--r--contrib/llvm/tools/clang/lib/Analysis/BodyFarm.cpp2
-rw-r--r--contrib/llvm/tools/clang/lib/Analysis/CFG.cpp77
-rw-r--r--contrib/llvm/tools/clang/lib/Analysis/ReachableCode.cpp20
-rw-r--r--contrib/llvm/tools/clang/lib/Basic/OpenMPKinds.cpp28
-rw-r--r--contrib/llvm/tools/clang/lib/Basic/Targets.cpp38
-rw-r--r--contrib/llvm/tools/clang/lib/Basic/Version.cpp2
-rw-r--r--contrib/llvm/tools/clang/lib/CodeGen/CGBuiltin.cpp10
-rw-r--r--contrib/llvm/tools/clang/lib/CodeGen/CGDecl.cpp4
-rw-r--r--contrib/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp3
-rw-r--r--contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.cpp16
-rw-r--r--contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.h42
-rw-r--r--contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp223
-rw-r--r--contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h40
-rw-r--r--contrib/llvm/tools/clang/lib/CodeGen/CGStmt.cpp4
-rw-r--r--contrib/llvm/tools/clang/lib/CodeGen/CGStmtOpenMP.cpp10
-rw-r--r--contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h2
-rw-r--r--contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp8
-rw-r--r--contrib/llvm/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp42
-rw-r--r--contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp2
-rw-r--r--contrib/llvm/tools/clang/lib/Driver/Tools.cpp10
-rw-r--r--contrib/llvm/tools/clang/lib/Format/ContinuationIndenter.cpp5
-rw-r--r--contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp10
-rw-r--r--contrib/llvm/tools/clang/lib/Headers/altivec.h6
-rw-r--r--contrib/llvm/tools/clang/lib/Index/IndexDecl.cpp28
-rw-r--r--contrib/llvm/tools/clang/lib/Index/IndexSymbol.cpp18
-rw-r--r--contrib/llvm/tools/clang/lib/Index/IndexTypeSourceInfo.cpp20
-rw-r--r--contrib/llvm/tools/clang/lib/Index/IndexingContext.cpp15
-rw-r--r--contrib/llvm/tools/clang/lib/Index/IndexingContext.h6
-rw-r--r--contrib/llvm/tools/clang/lib/Lex/HeaderSearch.cpp47
-rw-r--r--contrib/llvm/tools/clang/lib/Lex/ModuleMap.cpp20
-rw-r--r--contrib/llvm/tools/clang/lib/Lex/PPDirectives.cpp1
-rw-r--r--contrib/llvm/tools/clang/lib/Parse/ParseDecl.cpp13
-rw-r--r--contrib/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp11
-rw-r--r--contrib/llvm/tools/clang/lib/Parse/ParseExpr.cpp2
-rw-r--r--contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp5
-rw-r--r--contrib/llvm/tools/clang/lib/Parse/ParseOpenMP.cpp8
-rw-r--r--contrib/llvm/tools/clang/lib/Parse/Parser.cpp42
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp10
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/SemaCoroutine.cpp13
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp96
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/SemaDeclObjC.cpp6
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp14
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/SemaOpenMP.cpp97
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/SemaOverload.cpp60
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/SemaStmt.cpp9
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/SemaTemplate.cpp72
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp3
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp13
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/SemaType.cpp2
-rw-r--r--contrib/llvm/tools/clang/lib/Sema/TreeTransform.h13
-rw-r--r--contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp2
-rw-r--r--contrib/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp1
-rw-r--r--contrib/llvm/tools/clang/lib/Serialization/ASTReaderStmt.cpp13
-rw-r--r--contrib/llvm/tools/clang/lib/Serialization/ASTWriter.cpp1
-rw-r--r--contrib/llvm/tools/clang/lib/Serialization/ASTWriterDecl.cpp2
-rw-r--r--contrib/llvm/tools/clang/lib/Serialization/ASTWriterStmt.cpp6
-rw-r--r--contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp6
-rw-r--r--contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp12
-rw-r--r--contrib/llvm/tools/lld/CMakeLists.txt3
-rw-r--r--contrib/llvm/tools/lld/COFF/PDB.cpp94
-rw-r--r--contrib/llvm/tools/lld/ELF/Driver.cpp3
-rw-r--r--contrib/llvm/tools/lld/ELF/Error.cpp4
-rw-r--r--contrib/llvm/tools/lld/ELF/Error.h7
-rw-r--r--contrib/llvm/tools/lld/ELF/InputFiles.cpp4
-rw-r--r--contrib/llvm/tools/lld/ELF/InputSection.cpp73
-rw-r--r--contrib/llvm/tools/lld/ELF/InputSection.h10
-rw-r--r--contrib/llvm/tools/lld/ELF/LinkerScript.cpp33
-rw-r--r--contrib/llvm/tools/lld/ELF/OutputSections.cpp7
-rw-r--r--contrib/llvm/tools/lld/ELF/OutputSections.h2
-rw-r--r--contrib/llvm/tools/lld/ELF/Relocations.cpp34
-rw-r--r--contrib/llvm/tools/lld/ELF/SymbolTable.cpp30
-rw-r--r--contrib/llvm/tools/lld/ELF/Symbols.cpp32
-rw-r--r--contrib/llvm/tools/lld/ELF/Symbols.h12
-rw-r--r--contrib/llvm/tools/lld/ELF/SyntheticSections.cpp33
-rw-r--r--contrib/llvm/tools/lld/ELF/Target.cpp22
-rw-r--r--contrib/llvm/tools/lld/ELF/Writer.cpp63
-rw-r--r--contrib/llvm/tools/lldb/include/lldb/Core/Error.h11
-rw-r--r--contrib/llvm/tools/lldb/include/lldb/Symbol/Type.h5
-rw-r--r--contrib/llvm/tools/lldb/source/Core/Module.cpp12
-rw-r--r--contrib/llvm/tools/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp5
-rw-r--r--contrib/llvm/tools/lldb/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp3
-rw-r--r--contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp3
-rw-r--r--contrib/llvm/tools/lldb/source/Symbol/Type.cpp87
-rw-r--r--contrib/llvm/tools/lldb/source/Symbol/TypeList.cpp10
-rw-r--r--contrib/llvm/tools/lldb/source/Symbol/TypeMap.cpp10
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp37
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/LLVMOutputStyle.h4
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyBuiltinDumper.cpp (renamed from contrib/llvm/tools/llvm-pdbdump/BuiltinDumper.cpp)4
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyBuiltinDumper.h (renamed from contrib/llvm/tools/llvm-pdbdump/BuiltinDumper.h)6
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.cpp (renamed from contrib/llvm/tools/llvm-pdbdump/ClassDefinitionDumper.cpp)13
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.h (renamed from contrib/llvm/tools/llvm-pdbdump/ClassDefinitionDumper.h)8
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyCompilandDumper.cpp (renamed from contrib/llvm/tools/llvm-pdbdump/CompilandDumper.cpp)8
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyCompilandDumper.h (renamed from contrib/llvm/tools/llvm-pdbdump/CompilandDumper.h)6
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyEnumDumper.cpp (renamed from contrib/llvm/tools/llvm-pdbdump/EnumDumper.cpp)6
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyEnumDumper.h (renamed from contrib/llvm/tools/llvm-pdbdump/EnumDumper.h)6
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyExternalSymbolDumper.cpp (renamed from contrib/llvm/tools/llvm-pdbdump/ExternalSymbolDumper.cpp)4
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyExternalSymbolDumper.h (renamed from contrib/llvm/tools/llvm-pdbdump/ExternalSymbolDumper.h)6
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyFunctionDumper.cpp (renamed from contrib/llvm/tools/llvm-pdbdump/FunctionDumper.cpp)6
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyFunctionDumper.h (renamed from contrib/llvm/tools/llvm-pdbdump/FunctionDumper.h)6
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp (renamed from contrib/llvm/tools/llvm-pdbdump/TypeDumper.cpp)12
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyTypeDumper.h (renamed from contrib/llvm/tools/llvm-pdbdump/TypeDumper.h)6
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyTypedefDumper.cpp (renamed from contrib/llvm/tools/llvm-pdbdump/TypedefDumper.cpp)8
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyTypedefDumper.h (renamed from contrib/llvm/tools/llvm-pdbdump/TypedefDumper.h)6
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp (renamed from contrib/llvm/tools/llvm-pdbdump/VariableDumper.cpp)10
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/PrettyVariableDumper.h (renamed from contrib/llvm/tools/llvm-pdbdump/VariableDumper.h)6
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/YAMLOutputStyle.h2
-rw-r--r--contrib/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp10
-rw-r--r--contrib/llvm/tools/llvm-readobj/COFFDumper.cpp26
-rw-r--r--contrib/llvm/tools/llvm-xray/func-id-helper.cc60
-rw-r--r--contrib/llvm/tools/llvm-xray/func-id-helper.h49
-rw-r--r--contrib/llvm/tools/llvm-xray/xray-account.cc485
-rw-r--r--contrib/llvm/tools/llvm-xray/xray-account.h109
-rw-r--r--contrib/llvm/tools/llvm-xray/xray-converter.cc202
-rw-r--r--contrib/llvm/tools/llvm-xray/xray-converter.h39
-rw-r--r--contrib/llvm/tools/llvm-xray/xray-extract.cc63
-rw-r--r--contrib/llvm/tools/llvm-xray/xray-record-yaml.h102
-rw-r--r--contrib/llvm/tools/opt/NewPMDriver.cpp2
143 files changed, 2747 insertions, 789 deletions
diff --git a/contrib/llvm/tools/clang/include/clang-c/Index.h b/contrib/llvm/tools/clang/include/clang-c/Index.h
index e9d9ab03a8b0..15fde19eb974 100644
--- a/contrib/llvm/tools/clang/include/clang-c/Index.h
+++ b/contrib/llvm/tools/clang/include/clang-c/Index.h
@@ -2370,7 +2370,11 @@ enum CXCursorKind {
*/
CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective = 278,
- CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeParallelForSimdDirective,
+ /** \brief OpenMP target teams distribute simd directive.
+ */
+ CXCursor_OMPTargetTeamsDistributeSimdDirective = 279,
+
+ CXCursor_LastStmt = CXCursor_OMPTargetTeamsDistributeSimdDirective,
/**
* \brief Cursor that represents the translation unit itself.
diff --git a/contrib/llvm/tools/clang/include/clang/AST/Decl.h b/contrib/llvm/tools/clang/include/clang/AST/Decl.h
index b2e332d6d85c..8b52891af2f8 100644
--- a/contrib/llvm/tools/clang/include/clang/AST/Decl.h
+++ b/contrib/llvm/tools/clang/include/clang/AST/Decl.h
@@ -2061,6 +2061,10 @@ public:
/// limited representation in the AST.
SourceRange getReturnTypeSourceRange() const;
+ /// \brief Attempt to compute an informative source range covering the
+ /// function exception specification, if any.
+ SourceRange getExceptionSpecSourceRange() const;
+
/// \brief Determine the type of an expression that calls this function.
QualType getCallResultType() const {
assert(getType()->getAs<FunctionType>() && "Expected a FunctionType!");
diff --git a/contrib/llvm/tools/clang/include/clang/AST/DeclTemplate.h b/contrib/llvm/tools/clang/include/clang/AST/DeclTemplate.h
index 2af95c02c460..dc50a190de42 100644
--- a/contrib/llvm/tools/clang/include/clang/AST/DeclTemplate.h
+++ b/contrib/llvm/tools/clang/include/clang/AST/DeclTemplate.h
@@ -2028,8 +2028,7 @@ public:
SourceLocation L,
DeclarationName Name,
TemplateParameterList *Params,
- NamedDecl *Decl,
- ClassTemplateDecl *PrevDecl);
+ NamedDecl *Decl);
/// \brief Create an empty class template node.
static ClassTemplateDecl *CreateDeserialized(ASTContext &C, unsigned ID);
diff --git a/contrib/llvm/tools/clang/include/clang/AST/RecursiveASTVisitor.h b/contrib/llvm/tools/clang/include/clang/AST/RecursiveASTVisitor.h
index cbf0bee69f00..10a930abe6fb 100644
--- a/contrib/llvm/tools/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/contrib/llvm/tools/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -2672,6 +2672,9 @@ DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeParallelForDirective,
DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeParallelForSimdDirective,
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
+DEF_TRAVERSE_STMT(OMPTargetTeamsDistributeSimdDirective,
+ { TRY_TO(TraverseOMPExecutableDirective(S)); })
+
// OpenMP clauses.
template <typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseOMPClause(OMPClause *C) {
diff --git a/contrib/llvm/tools/clang/include/clang/AST/StmtOpenMP.h b/contrib/llvm/tools/clang/include/clang/AST/StmtOpenMP.h
index 61cae7b6d258..ec532ecd5881 100644
--- a/contrib/llvm/tools/clang/include/clang/AST/StmtOpenMP.h
+++ b/contrib/llvm/tools/clang/include/clang/AST/StmtOpenMP.h
@@ -3711,6 +3711,75 @@ public:
}
};
+/// This represents '#pragma omp target teams distribute simd' combined
+/// directive.
+///
+/// \code
+/// #pragma omp target teams distribute simd private(x)
+/// \endcode
+/// In this example directive '#pragma omp target teams distribute simd'
+/// has clause 'private' with the variables 'x'
+///
+class OMPTargetTeamsDistributeSimdDirective final : public OMPLoopDirective {
+ friend class ASTStmtReader;
+
+ /// Build directive with the given start and end location.
+ ///
+ /// \param StartLoc Starting location of the directive kind.
+ /// \param EndLoc Ending location of the directive.
+ /// \param CollapsedNum Number of collapsed nested loops.
+ /// \param NumClauses Number of clauses.
+ ///
+ OMPTargetTeamsDistributeSimdDirective(SourceLocation StartLoc,
+ SourceLocation EndLoc,
+ unsigned CollapsedNum,
+ unsigned NumClauses)
+ : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass,
+ OMPD_target_teams_distribute_simd, StartLoc, EndLoc,
+ CollapsedNum, NumClauses) {}
+
+ /// Build an empty directive.
+ ///
+ /// \param CollapsedNum Number of collapsed nested loops.
+ /// \param NumClauses Number of clauses.
+ ///
+ explicit OMPTargetTeamsDistributeSimdDirective(unsigned CollapsedNum,
+ unsigned NumClauses)
+ : OMPLoopDirective(this, OMPTargetTeamsDistributeSimdDirectiveClass,
+ OMPD_target_teams_distribute_simd, SourceLocation(),
+ SourceLocation(), CollapsedNum, NumClauses) {}
+
+public:
+ /// Creates directive with a list of \a Clauses.
+ ///
+ /// \param C AST context.
+ /// \param StartLoc Starting location of the directive kind.
+ /// \param EndLoc Ending Location of the directive.
+ /// \param CollapsedNum Number of collapsed loops.
+ /// \param Clauses List of clauses.
+ /// \param AssociatedStmt Statement, associated with the directive.
+ /// \param Exprs Helper expressions for CodeGen.
+ ///
+ static OMPTargetTeamsDistributeSimdDirective *
+ Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
+ unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses,
+ Stmt *AssociatedStmt, const HelperExprs &Exprs);
+
+ /// Creates an empty directive with the place for \a NumClauses clauses.
+ ///
+ /// \param C AST context.
+ /// \param CollapsedNum Number of collapsed nested loops.
+ /// \param NumClauses Number of clauses.
+ ///
+ static OMPTargetTeamsDistributeSimdDirective *
+ CreateEmpty(const ASTContext &C, unsigned NumClauses, unsigned CollapsedNum,
+ EmptyShell);
+
+ static bool classof(const Stmt *T) {
+ return T->getStmtClass() == OMPTargetTeamsDistributeSimdDirectiveClass;
+ }
+};
+
} // end namespace clang
#endif
diff --git a/contrib/llvm/tools/clang/include/clang/AST/TypeLoc.h b/contrib/llvm/tools/clang/include/clang/AST/TypeLoc.h
index 7de666838d44..5b7d9e6e3ce1 100644
--- a/contrib/llvm/tools/clang/include/clang/AST/TypeLoc.h
+++ b/contrib/llvm/tools/clang/include/clang/AST/TypeLoc.h
@@ -1351,6 +1351,19 @@ class FunctionTypeLoc : public ConcreteTypeLoc<UnqualTypeLoc,
FunctionTypeLoc,
FunctionType,
FunctionLocInfo> {
+ bool hasExceptionSpec() const {
+ if (auto *FPT = dyn_cast<FunctionProtoType>(getTypePtr())) {
+ return FPT->hasExceptionSpec();
+ }
+ return false;
+ }
+
+ SourceRange *getExceptionSpecRangePtr() const {
+ assert(hasExceptionSpec() && "No exception spec range");
+ // After the Info comes the ParmVarDecl array, and after that comes the
+ // exception specification information.
+ return (SourceRange *)(getParmArray() + getNumParams());
+ }
public:
SourceLocation getLocalRangeBegin() const {
return getLocalData()->LocalRangeBegin;
@@ -1384,6 +1397,16 @@ public:
return SourceRange(getLParenLoc(), getRParenLoc());
}
+ SourceRange getExceptionSpecRange() const {
+ if (hasExceptionSpec())
+ return *getExceptionSpecRangePtr();
+ return SourceRange();
+ }
+ void setExceptionSpecRange(SourceRange R) {
+ if (hasExceptionSpec())
+ *getExceptionSpecRangePtr() = R;
+ }
+
ArrayRef<ParmVarDecl *> getParams() const {
return llvm::makeArrayRef(getParmArray(), getNumParams());
}
@@ -1416,12 +1439,15 @@ public:
setLocalRangeEnd(Loc);
for (unsigned i = 0, e = getNumParams(); i != e; ++i)
setParam(i, nullptr);
+ if (hasExceptionSpec())
+ setExceptionSpecRange(Loc);
}
/// \brief Returns the size of the type source info data block that is
/// specific to this type.
unsigned getExtraLocalDataSize() const {
- return getNumParams() * sizeof(ParmVarDecl *);
+ unsigned ExceptSpecSize = hasExceptionSpec() ? sizeof(SourceRange) : 0;
+ return (getNumParams() * sizeof(ParmVarDecl *)) + ExceptSpecSize;
}
unsigned getExtraLocalDataAlignment() const { return alignof(ParmVarDecl *); }
diff --git a/contrib/llvm/tools/clang/include/clang/Basic/AttrDocs.td b/contrib/llvm/tools/clang/include/clang/Basic/AttrDocs.td
index 49b0a533cec3..8f6a7ea601b3 100644
--- a/contrib/llvm/tools/clang/include/clang/Basic/AttrDocs.td
+++ b/contrib/llvm/tools/clang/include/clang/Basic/AttrDocs.td
@@ -386,6 +386,7 @@ warnings or errors at compile-time if calls to the attributed function meet
certain user-defined criteria. For example:
.. code-block:: c
+
void abs(int a)
__attribute__((diagnose_if(a >= 0, "Redundant abs call", "warning")));
void must_abs(int a)
diff --git a/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td b/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6a8933f23ecd..3971cf60d5e0 100644
--- a/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/contrib/llvm/tools/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8720,10 +8720,6 @@ def err_coroutine_invalid_func_context : Error<
"|a copy assignment operator|a move assignment operator|the 'main' function"
"|a constexpr function|a function with a deduced return type"
"|a varargs function}0">;
-def ext_coroutine_without_co_await_co_yield : ExtWarn<
- "'co_return' used in a function "
- "that uses neither 'co_await' nor 'co_yield'">,
- InGroup<DiagGroup<"coreturn-without-coawait">>;
def err_implied_std_coroutine_traits_not_found : Error<
"you need to include <experimental/coroutine> before defining a coroutine">;
def err_malformed_std_coroutine_traits : Error<
diff --git a/contrib/llvm/tools/clang/include/clang/Basic/OpenMPKinds.def b/contrib/llvm/tools/clang/include/clang/Basic/OpenMPKinds.def
index 58b54ce0bcd6..74ec26f19ac2 100644
--- a/contrib/llvm/tools/clang/include/clang/Basic/OpenMPKinds.def
+++ b/contrib/llvm/tools/clang/include/clang/Basic/OpenMPKinds.def
@@ -165,6 +165,9 @@
#ifndef OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE
#define OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(Name)
#endif
+#ifndef OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE
+#define OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(Name)
+#endif
// OpenMP directives.
OPENMP_DIRECTIVE(threadprivate)
@@ -218,6 +221,7 @@ OPENMP_DIRECTIVE_EXT(target_teams, "target teams")
OPENMP_DIRECTIVE_EXT(target_teams_distribute, "target teams distribute")
OPENMP_DIRECTIVE_EXT(target_teams_distribute_parallel_for, "target teams distribute parallel for")
OPENMP_DIRECTIVE_EXT(target_teams_distribute_parallel_for_simd, "target teams distribute parallel for simd")
+OPENMP_DIRECTIVE_EXT(target_teams_distribute_simd, "target teams distribute simd")
// OpenMP clauses.
OPENMP_CLAUSE(if, OMPIfClause)
@@ -446,7 +450,6 @@ OPENMP_TARGET_CLAUSE(firstprivate)
OPENMP_TARGET_CLAUSE(is_device_ptr)
// Clauses allowed for OpenMP directive 'target data'.
-// TODO More clauses for 'target data' directive.
OPENMP_TARGET_DATA_CLAUSE(if)
OPENMP_TARGET_DATA_CLAUSE(device)
OPENMP_TARGET_DATA_CLAUSE(map)
@@ -483,7 +486,6 @@ OPENMP_TARGET_PARALLEL_CLAUSE(reduction)
OPENMP_TARGET_PARALLEL_CLAUSE(is_device_ptr)
// Clauses allowed for OpenMP directive 'target parallel for'.
-// TODO: add target clauses 'is_device_ptr'
OPENMP_TARGET_PARALLEL_FOR_CLAUSE(if)
OPENMP_TARGET_PARALLEL_FOR_CLAUSE(device)
OPENMP_TARGET_PARALLEL_FOR_CLAUSE(map)
@@ -502,9 +504,9 @@ OPENMP_TARGET_PARALLEL_FOR_CLAUSE(collapse)
OPENMP_TARGET_PARALLEL_FOR_CLAUSE(schedule)
OPENMP_TARGET_PARALLEL_FOR_CLAUSE(ordered)
OPENMP_TARGET_PARALLEL_FOR_CLAUSE(linear)
+OPENMP_TARGET_PARALLEL_FOR_CLAUSE(is_device_ptr)
// Clauses allowed for OpenMP directive 'target update'.
-// TODO More clauses for 'target update' directive.
OPENMP_TARGET_UPDATE_CLAUSE(if)
OPENMP_TARGET_UPDATE_CLAUSE(device)
OPENMP_TARGET_UPDATE_CLAUSE(to)
@@ -513,7 +515,6 @@ OPENMP_TARGET_UPDATE_CLAUSE(nowait)
OPENMP_TARGET_UPDATE_CLAUSE(depend)
// Clauses allowed for OpenMP directive 'teams'.
-// TODO More clauses for 'teams' directive.
OPENMP_TEAMS_CLAUSE(default)
OPENMP_TEAMS_CLAUSE(private)
OPENMP_TEAMS_CLAUSE(firstprivate)
@@ -523,7 +524,6 @@ OPENMP_TEAMS_CLAUSE(num_teams)
OPENMP_TEAMS_CLAUSE(thread_limit)
// Clauses allowed for OpenMP directive 'ordered'.
-// TODO More clauses for 'ordered' directive.
OPENMP_ORDERED_CLAUSE(threads)
OPENMP_ORDERED_CLAUSE(simd)
OPENMP_ORDERED_CLAUSE(depend)
@@ -633,7 +633,6 @@ OPENMP_DISTRIBUTE_SIMD_CLAUSE(simdlen)
OPENMP_DISTRIBUTE_SIMD_CLAUSE(reduction)
// Clauses allowed for OpenMP directive 'target parallel for simd'.
-// TODO: add target clauses 'is_device_ptr'
OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(if)
OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(device)
OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(map)
@@ -655,6 +654,7 @@ OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(linear)
OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(safelen)
OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(simdlen)
OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(aligned)
+OPENMP_TARGET_PARALLEL_FOR_SIMD_CLAUSE(is_device_ptr)
// Clauses allowed for OpenMP directive 'target simd'.
OPENMP_TARGET_SIMD_CLAUSE(if)
@@ -824,6 +824,28 @@ OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(aligned)
OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(safelen)
OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(simdlen)
+// Clauses allowed for OpenMP directive 'target teams distribute simd'.
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(if)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(device)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(map)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(private)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(nowait)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(depend)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(defaultmap)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(firstprivate)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(lastprivate)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(is_device_ptr)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(shared)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(reduction)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(num_teams)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(thread_limit)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(collapse)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(dist_schedule)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(linear)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(aligned)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(safelen)
+OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(simdlen)
+
#undef OPENMP_TASKLOOP_SIMD_CLAUSE
#undef OPENMP_TASKLOOP_CLAUSE
#undef OPENMP_LINEAR_KIND
@@ -875,3 +897,4 @@ OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE(simdlen)
#undef OPENMP_TARGET_TEAMS_DISTRIBUTE_CLAUSE
#undef OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_CLAUSE
#undef OPENMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_CLAUSE
+#undef OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE
diff --git a/contrib/llvm/tools/clang/include/clang/Basic/StmtNodes.td b/contrib/llvm/tools/clang/include/clang/Basic/StmtNodes.td
index 2e92e5006ff4..67a5ab773aa6 100644
--- a/contrib/llvm/tools/clang/include/clang/Basic/StmtNodes.td
+++ b/contrib/llvm/tools/clang/include/clang/Basic/StmtNodes.td
@@ -244,3 +244,4 @@ def OMPTargetTeamsDirective : DStmt<OMPExecutableDirective>;
def OMPTargetTeamsDistributeDirective : DStmt<OMPLoopDirective>;
def OMPTargetTeamsDistributeParallelForDirective : DStmt<OMPLoopDirective>;
def OMPTargetTeamsDistributeParallelForSimdDirective : DStmt<OMPLoopDirective>;
+def OMPTargetTeamsDistributeSimdDirective : DStmt<OMPLoopDirective>;
diff --git a/contrib/llvm/tools/clang/include/clang/Driver/CLCompatOptions.td b/contrib/llvm/tools/clang/include/clang/Driver/CLCompatOptions.td
index cb2745afb7e4..60048c49c0f7 100644
--- a/contrib/llvm/tools/clang/include/clang/Driver/CLCompatOptions.td
+++ b/contrib/llvm/tools/clang/include/clang/Driver/CLCompatOptions.td
@@ -27,7 +27,7 @@ class CLCompileFlag<string name> : Option<["/", "-"], name, KIND_FLAG>,
Group<cl_compile_Group>, Flags<[CLOption, DriverOption]>;
class CLIgnoredFlag<string name> : Option<["/", "-"], name, KIND_FLAG>,
- Group<cl_ignored_Group>, Flags<[CLOption, DriverOption, HelpHidden]>;
+ Group<cl_ignored_Group>, Flags<[CLOption, DriverOption]>;
class CLJoined<string name> : Option<["/", "-"], name, KIND_JOINED>,
Group<cl_Group>, Flags<[CLOption, DriverOption]>;
@@ -299,7 +299,7 @@ def _SLASH_d2Zi_PLUS : CLIgnoredFlag<"d2Zi+">;
def _SLASH_errorReport : CLIgnoredJoined<"errorReport">;
def _SLASH_FC : CLIgnoredFlag<"FC">;
def _SLASH_Fd : CLIgnoredJoined<"Fd">;
-def _SLASH_FS : CLIgnoredFlag<"FS">, HelpText<"Force synchronous PDB writes">;
+def _SLASH_FS : CLIgnoredFlag<"FS">;
def _SLASH_GF : CLIgnoredFlag<"GF">;
def _SLASH_kernel_ : CLIgnoredFlag<"kernel-">;
def _SLASH_nologo : CLIgnoredFlag<"nologo">;
@@ -308,7 +308,8 @@ def _SLASH_openmp_ : CLIgnoredFlag<"openmp-">;
def _SLASH_RTC : CLIgnoredJoined<"RTC">;
def _SLASH_sdl : CLIgnoredFlag<"sdl">;
def _SLASH_sdl_ : CLIgnoredFlag<"sdl-">;
-def _SLASH_utf8 : CLIgnoredFlag<"utf-8">;
+def _SLASH_utf8 : CLIgnoredFlag<"utf-8">,
+ HelpText<"Set source and runtime encoding to UTF-8 (default)">;
def _SLASH_w : CLIgnoredJoined<"w">;
def _SLASH_Zc_auto : CLIgnoredFlag<"Zc:auto">;
def _SLASH_Zc_forScope : CLIgnoredFlag<"Zc:forScope">;
diff --git a/contrib/llvm/tools/clang/include/clang/Driver/Options.td b/contrib/llvm/tools/clang/include/clang/Driver/Options.td
index 7f4e59a2d233..6be159fad694 100644
--- a/contrib/llvm/tools/clang/include/clang/Driver/Options.td
+++ b/contrib/llvm/tools/clang/include/clang/Driver/Options.td
@@ -1032,6 +1032,7 @@ def fno_ms_extensions : Flag<["-"], "fno-ms-extensions">, Group<f_Group>,
def fno_ms_compatibility : Flag<["-"], "fno-ms-compatibility">, Group<f_Group>,
Flags<[CoreOption]>;
def fno_delayed_template_parsing : Flag<["-"], "fno-delayed-template-parsing">, Group<f_Group>,
+ HelpText<"Disable delayed template parsing">,
Flags<[DriverOption, CoreOption]>;
def fno_objc_exceptions: Flag<["-"], "fno-objc-exceptions">, Group<f_Group>;
def fno_objc_legacy_dispatch : Flag<["-"], "fno-objc-legacy-dispatch">, Group<f_Group>;
diff --git a/contrib/llvm/tools/clang/include/clang/Index/IndexSymbol.h b/contrib/llvm/tools/clang/include/clang/Index/IndexSymbol.h
index 559b212b9266..d19e5ebef2f0 100644
--- a/contrib/llvm/tools/clang/include/clang/Index/IndexSymbol.h
+++ b/contrib/llvm/tools/clang/include/clang/Index/IndexSymbol.h
@@ -64,6 +64,8 @@ enum class SymbolSubKind {
None,
CXXCopyConstructor,
CXXMoveConstructor,
+ AccessorGetter,
+ AccessorSetter,
};
/// Set of properties that provide additional info about a symbol.
@@ -80,7 +82,7 @@ static const unsigned SymbolPropertyBitNum = 7;
typedef unsigned SymbolPropertySet;
/// Set of roles that are attributed to symbol occurrences.
-enum class SymbolRole : uint16_t {
+enum class SymbolRole : uint32_t {
Declaration = 1 << 0,
Definition = 1 << 1,
Reference = 1 << 2,
@@ -99,8 +101,10 @@ enum class SymbolRole : uint16_t {
RelationCalledBy = 1 << 13,
RelationExtendedBy = 1 << 14,
RelationAccessorOf = 1 << 15,
+ RelationContainedBy = 1 << 16,
+ RelationIBTypeOf = 1 << 17,
};
-static const unsigned SymbolRoleBitNum = 16;
+static const unsigned SymbolRoleBitNum = 18;
typedef unsigned SymbolRoleSet;
/// Represents a relation to another symbol for a symbol occurrence.
diff --git a/contrib/llvm/tools/clang/include/clang/Lex/HeaderSearch.h b/contrib/llvm/tools/clang/include/clang/Lex/HeaderSearch.h
index 4df3e783117a..51983b9ab5d8 100644
--- a/contrib/llvm/tools/clang/include/clang/Lex/HeaderSearch.h
+++ b/contrib/llvm/tools/clang/include/clang/Lex/HeaderSearch.h
@@ -406,7 +406,8 @@ public:
/// \return false if \#including the file will have no effect or true
/// if we should include it.
bool ShouldEnterIncludeFile(Preprocessor &PP, const FileEntry *File,
- bool isImport, Module *CorrespondingModule);
+ bool isImport, bool ModulesEnabled,
+ Module *CorrespondingModule);
/// \brief Return whether the specified file is a normal header,
/// a system header, or a C++ friendly system header.
diff --git a/contrib/llvm/tools/clang/include/clang/Lex/ModuleMap.h b/contrib/llvm/tools/clang/include/clang/Lex/ModuleMap.h
index b3a2421af86e..46136725d87a 100644
--- a/contrib/llvm/tools/clang/include/clang/Lex/ModuleMap.h
+++ b/contrib/llvm/tools/clang/include/clang/Lex/ModuleMap.h
@@ -316,6 +316,14 @@ public:
BuiltinIncludeDir = Dir;
}
+ /// \brief Get the directory that contains Clang-supplied include files.
+ const DirectoryEntry *getBuiltinDir() const {
+ return BuiltinIncludeDir;
+ }
+
+ /// \brief Is this a compiler builtin header?
+ static bool isBuiltinHeader(StringRef FileName);
+
/// \brief Add a module map callback.
void addModuleMapCallbacks(std::unique_ptr<ModuleMapCallbacks> Callback) {
Callbacks.push_back(std::move(Callback));
diff --git a/contrib/llvm/tools/clang/include/clang/Parse/Parser.h b/contrib/llvm/tools/clang/include/clang/Parse/Parser.h
index 972f13daca46..fe159022c223 100644
--- a/contrib/llvm/tools/clang/include/clang/Parse/Parser.h
+++ b/contrib/llvm/tools/clang/include/clang/Parse/Parser.h
@@ -600,11 +600,8 @@ private:
public:
// If NeedType is true, then TryAnnotateTypeOrScopeToken will try harder to
// find a type name by attempting typo correction.
- bool TryAnnotateTypeOrScopeToken(bool EnteringContext = false,
- bool NeedType = false);
- bool TryAnnotateTypeOrScopeTokenAfterScopeSpec(bool EnteringContext,
- bool NeedType,
- CXXScopeSpec &SS,
+ bool TryAnnotateTypeOrScopeToken();
+ bool TryAnnotateTypeOrScopeTokenAfterScopeSpec(CXXScopeSpec &SS,
bool IsNewScope);
bool TryAnnotateCXXScopeToken(bool EnteringContext = false);
diff --git a/contrib/llvm/tools/clang/include/clang/Sema/Sema.h b/contrib/llvm/tools/clang/include/clang/Sema/Sema.h
index d5e4b069f8b7..c180a8ea3ee1 100644
--- a/contrib/llvm/tools/clang/include/clang/Sema/Sema.h
+++ b/contrib/llvm/tools/clang/include/clang/Sema/Sema.h
@@ -1709,7 +1709,8 @@ public:
static bool adjustContextForLocalExternDecl(DeclContext *&DC);
void DiagnoseFunctionSpecifiers(const DeclSpec &DS);
- void CheckShadow(Scope *S, VarDecl *D, const LookupResult& R);
+ NamedDecl *getShadowedDeclaration(const VarDecl *D, const LookupResult &R);
+ void CheckShadow(VarDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R);
void CheckShadow(Scope *S, VarDecl *D);
/// Warn if 'E', which is an expression that is about to be modified, refers
@@ -1790,9 +1791,8 @@ public:
bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
SourceLocation EqualLoc);
- void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit,
- bool TypeMayContainAuto);
- void ActOnUninitializedDecl(Decl *dcl, bool TypeMayContainAuto);
+ void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit);
+ void ActOnUninitializedDecl(Decl *dcl);
void ActOnInitializerError(Decl *Dcl);
bool canInitializeWithParenthesizedList(QualType TargetType);
@@ -1807,8 +1807,7 @@ public:
void FinalizeDeclaration(Decl *D);
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
ArrayRef<Decl *> Group);
- DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef<Decl *> Group,
- bool TypeMayContainAuto = true);
+ DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef<Decl *> Group);
/// Should be called on all declarations that might have attached
/// documentation comments.
@@ -4920,8 +4919,7 @@ public:
TypeSourceInfo *AllocTypeInfo,
Expr *ArraySize,
SourceRange DirectInitRange,
- Expr *Initializer,
- bool TypeMayContainAuto = true);
+ Expr *Initializer);
bool CheckAllocatedType(QualType AllocType, SourceLocation Loc,
SourceRange R);
@@ -8584,6 +8582,12 @@ public:
ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
SourceLocation EndLoc,
llvm::DenseMap<ValueDecl *, Expr *> &VarsWithImplicitDSA);
+ /// Called on well-formed '\#pragma omp target teams distribute simd' after
+ /// parsing of the associated statement.
+ StmtResult ActOnOpenMPTargetTeamsDistributeSimdDirective(
+ ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
+ SourceLocation EndLoc,
+ llvm::DenseMap<ValueDecl *, Expr *> &VarsWithImplicitDSA);
/// Checks correctness of linear modifiers.
bool CheckOpenMPLinearModifier(OpenMPLinearClauseKind LinKind,
diff --git a/contrib/llvm/tools/clang/include/clang/Serialization/ASTBitCodes.h b/contrib/llvm/tools/clang/include/clang/Serialization/ASTBitCodes.h
index 61e2f18045ea..acbd6d1deb5b 100644
--- a/contrib/llvm/tools/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/contrib/llvm/tools/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1517,6 +1517,7 @@ namespace clang {
STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE,
STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE,
STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE,
+ STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE,
EXPR_OMP_ARRAY_SECTION,
// ARC
diff --git a/contrib/llvm/tools/clang/lib/AST/ASTImporter.cpp b/contrib/llvm/tools/clang/lib/AST/ASTImporter.cpp
index 67e96ea828bd..1ccb746633a7 100644
--- a/contrib/llvm/tools/clang/lib/AST/ASTImporter.cpp
+++ b/contrib/llvm/tools/clang/lib/AST/ASTImporter.cpp
@@ -4671,8 +4671,7 @@ Decl *ASTNodeImporter::VisitClassTemplateDecl(ClassTemplateDecl *D) {
ClassTemplateDecl *D2 = ClassTemplateDecl::Create(Importer.getToContext(), DC,
Loc, Name, TemplateParams,
- D2Templated,
- /*PrevDecl=*/nullptr);
+ D2Templated);
D2Templated->setDescribedClassTemplate(D2);
D2->setAccess(D->getAccess());
diff --git a/contrib/llvm/tools/clang/lib/AST/Decl.cpp b/contrib/llvm/tools/clang/lib/AST/Decl.cpp
index c3fa1c87affd..81f08787d515 100644
--- a/contrib/llvm/tools/clang/lib/AST/Decl.cpp
+++ b/contrib/llvm/tools/clang/lib/AST/Decl.cpp
@@ -2990,6 +2990,18 @@ SourceRange FunctionDecl::getReturnTypeSourceRange() const {
return RTRange;
}
+SourceRange FunctionDecl::getExceptionSpecSourceRange() const {
+ const TypeSourceInfo *TSI = getTypeSourceInfo();
+ if (!TSI)
+ return SourceRange();
+ FunctionTypeLoc FTL =
+ TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>();
+ if (!FTL)
+ return SourceRange();
+
+ return FTL.getExceptionSpecRange();
+}
+
const Attr *FunctionDecl::getUnusedResultAttr() const {
QualType RetType = getReturnType();
if (RetType->isRecordType()) {
diff --git a/contrib/llvm/tools/clang/lib/AST/DeclTemplate.cpp b/contrib/llvm/tools/clang/lib/AST/DeclTemplate.cpp
index 8643cbfcd960..a5fbb0a3baec 100644
--- a/contrib/llvm/tools/clang/lib/AST/DeclTemplate.cpp
+++ b/contrib/llvm/tools/clang/lib/AST/DeclTemplate.cpp
@@ -297,12 +297,10 @@ ClassTemplateDecl *ClassTemplateDecl::Create(ASTContext &C,
SourceLocation L,
DeclarationName Name,
TemplateParameterList *Params,
- NamedDecl *Decl,
- ClassTemplateDecl *PrevDecl) {
+ NamedDecl *Decl) {
AdoptTemplateParameterList(Params, cast<DeclContext>(Decl));
ClassTemplateDecl *New = new (C, DC) ClassTemplateDecl(C, DC, L, Name,
Params, Decl);
- New->setPreviousDecl(PrevDecl);
return New;
}
diff --git a/contrib/llvm/tools/clang/lib/AST/Expr.cpp b/contrib/llvm/tools/clang/lib/AST/Expr.cpp
index 93f3ad5f2bdd..14f31d0c6b8c 100644
--- a/contrib/llvm/tools/clang/lib/AST/Expr.cpp
+++ b/contrib/llvm/tools/clang/lib/AST/Expr.cpp
@@ -562,8 +562,7 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) {
FT = dyn_cast<FunctionProtoType>(AFT);
if (IT == FuncSig) {
- assert(FT && "We must have a written prototype in this case.");
- switch (FT->getCallConv()) {
+ switch (AFT->getCallConv()) {
case CC_C: POut << "__cdecl "; break;
case CC_X86StdCall: POut << "__stdcall "; break;
case CC_X86FastCall: POut << "__fastcall "; break;
@@ -587,12 +586,15 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) {
if (FT->isVariadic()) {
if (FD->getNumParams()) POut << ", ";
POut << "...";
+ } else if ((IT == FuncSig || !Context.getLangOpts().CPlusPlus) &&
+ !Decl->getNumParams()) {
+ POut << "void";
}
}
POut << ")";
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
- const FunctionType *FT = MD->getType()->castAs<FunctionType>();
+ assert(FT && "We must have a written prototype in this case.");
if (FT->isConst())
POut << " const";
if (FT->isVolatile())
diff --git a/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp b/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp
index fe77c7f6f3bf..a8512b294055 100644
--- a/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp
+++ b/contrib/llvm/tools/clang/lib/AST/ExprConstant.cpp
@@ -1627,8 +1627,17 @@ static bool CheckLiteralType(EvalInfo &Info, const Expr *E,
// C++1y: A constant initializer for an object o [...] may also invoke
// constexpr constructors for o and its subobjects even if those objects
// are of non-literal class types.
- if (Info.getLangOpts().CPlusPlus14 && This &&
- Info.EvaluatingDecl == This->getLValueBase())
+ //
+ // C++11 missed this detail for aggregates, so classes like this:
+ // struct foo_t { union { int i; volatile int j; } u; };
+ // are not (obviously) initializable like so:
+ // __attribute__((__require_constant_initialization__))
+ // static const foo_t x = {{0}};
+ // because "i" is a subobject with non-literal initialization (due to the
+ // volatile member of the union). See:
+ // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#1677
+ // Therefore, we use the C++1y behavior.
+ if (This && Info.EvaluatingDecl == This->getLValueBase())
return true;
// Prvalue constant expressions must be of literal types.
diff --git a/contrib/llvm/tools/clang/lib/AST/StmtOpenMP.cpp b/contrib/llvm/tools/clang/lib/AST/StmtOpenMP.cpp
index a7c71bb5f45c..880817a1339b 100644
--- a/contrib/llvm/tools/clang/lib/AST/StmtOpenMP.cpp
+++ b/contrib/llvm/tools/clang/lib/AST/StmtOpenMP.cpp
@@ -1720,3 +1720,59 @@ OMPTargetTeamsDistributeParallelForSimdDirective::CreateEmpty(
CollapsedNum, NumClauses);
}
+OMPTargetTeamsDistributeSimdDirective *
+OMPTargetTeamsDistributeSimdDirective::Create(
+ const ASTContext &C, SourceLocation StartLoc, SourceLocation EndLoc,
+ unsigned CollapsedNum, ArrayRef<OMPClause *> Clauses, Stmt *AssociatedStmt,
+ const HelperExprs &Exprs) {
+ auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
+ alignof(OMPClause *));
+ void *Mem = C.Allocate(
+ Size + sizeof(OMPClause *) * Clauses.size() +
+ sizeof(Stmt *) *
+ numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
+ OMPTargetTeamsDistributeSimdDirective *Dir = new (Mem)
+ OMPTargetTeamsDistributeSimdDirective(StartLoc, EndLoc, CollapsedNum,
+ Clauses.size());
+ Dir->setClauses(Clauses);
+ Dir->setAssociatedStmt(AssociatedStmt);
+ Dir->setIterationVariable(Exprs.IterationVarRef);
+ Dir->setLastIteration(Exprs.LastIteration);
+ Dir->setCalcLastIteration(Exprs.CalcLastIteration);
+ Dir->setPreCond(Exprs.PreCond);
+ Dir->setCond(Exprs.Cond);
+ Dir->setInit(Exprs.Init);
+ Dir->setInc(Exprs.Inc);
+ Dir->setIsLastIterVariable(Exprs.IL);
+ Dir->setLowerBoundVariable(Exprs.LB);
+ Dir->setUpperBoundVariable(Exprs.UB);
+ Dir->setStrideVariable(Exprs.ST);
+ Dir->setEnsureUpperBound(Exprs.EUB);
+ Dir->setNextLowerBound(Exprs.NLB);
+ Dir->setNextUpperBound(Exprs.NUB);
+ Dir->setNumIterations(Exprs.NumIterations);
+ Dir->setPrevLowerBoundVariable(Exprs.PrevLB);
+ Dir->setPrevUpperBoundVariable(Exprs.PrevUB);
+ Dir->setCounters(Exprs.Counters);
+ Dir->setPrivateCounters(Exprs.PrivateCounters);
+ Dir->setInits(Exprs.Inits);
+ Dir->setUpdates(Exprs.Updates);
+ Dir->setFinals(Exprs.Finals);
+ Dir->setPreInits(Exprs.PreInits);
+ return Dir;
+}
+
+OMPTargetTeamsDistributeSimdDirective *
+OMPTargetTeamsDistributeSimdDirective::CreateEmpty(const ASTContext &C,
+ unsigned NumClauses,
+ unsigned CollapsedNum,
+ EmptyShell) {
+ auto Size = llvm::alignTo(sizeof(OMPTargetTeamsDistributeSimdDirective),
+ alignof(OMPClause *));
+ void *Mem = C.Allocate(
+ Size + sizeof(OMPClause *) * NumClauses +
+ sizeof(Stmt *) *
+ numLoopChildren(CollapsedNum, OMPD_target_teams_distribute_simd));
+ return new (Mem)
+ OMPTargetTeamsDistributeSimdDirective(CollapsedNum, NumClauses);
+}
diff --git a/contrib/llvm/tools/clang/lib/AST/StmtPrinter.cpp b/contrib/llvm/tools/clang/lib/AST/StmtPrinter.cpp
index a9c64c3ba6ae..1ba1aa40ec5c 100644
--- a/contrib/llvm/tools/clang/lib/AST/StmtPrinter.cpp
+++ b/contrib/llvm/tools/clang/lib/AST/StmtPrinter.cpp
@@ -1250,6 +1250,12 @@ void StmtPrinter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
PrintOMPExecutableDirective(Node);
}
+void StmtPrinter::VisitOMPTargetTeamsDistributeSimdDirective(
+ OMPTargetTeamsDistributeSimdDirective *Node) {
+ Indent() << "#pragma omp target teams distribute simd ";
+ PrintOMPExecutableDirective(Node);
+}
+
//===----------------------------------------------------------------------===//
// Expr printing methods.
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp b/contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp
index df36bf06b843..bcd2e96875e7 100644
--- a/contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp
+++ b/contrib/llvm/tools/clang/lib/AST/StmtProfile.cpp
@@ -768,6 +768,11 @@ void StmtProfiler::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
VisitOMPLoopDirective(S);
}
+void StmtProfiler::VisitOMPTargetTeamsDistributeSimdDirective(
+ const OMPTargetTeamsDistributeSimdDirective *S) {
+ VisitOMPLoopDirective(S);
+}
+
void StmtProfiler::VisitExpr(const Expr *S) {
VisitStmt(S);
}
diff --git a/contrib/llvm/tools/clang/lib/Analysis/BodyFarm.cpp b/contrib/llvm/tools/clang/lib/Analysis/BodyFarm.cpp
index d202a0406461..56c812c34c50 100644
--- a/contrib/llvm/tools/clang/lib/Analysis/BodyFarm.cpp
+++ b/contrib/llvm/tools/clang/lib/Analysis/BodyFarm.cpp
@@ -467,6 +467,8 @@ static Stmt *createObjCPropertyGetter(ASTContext &Ctx,
ASTMaker M(Ctx);
const VarDecl *selfVar = Prop->getGetterMethodDecl()->getSelfDecl();
+ if (!selfVar)
+ return nullptr;
Expr *loadedIVar =
M.makeObjCIvarRef(
diff --git a/contrib/llvm/tools/clang/lib/Analysis/CFG.cpp b/contrib/llvm/tools/clang/lib/Analysis/CFG.cpp
index a1a463f1d037..d56e0e8fa1d0 100644
--- a/contrib/llvm/tools/clang/lib/Analysis/CFG.cpp
+++ b/contrib/llvm/tools/clang/lib/Analysis/CFG.cpp
@@ -2175,19 +2175,15 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
// Create local scope for C++17 if init-stmt if one exists.
- if (Stmt *Init = I->getInit()) {
- LocalScope::const_iterator BeginScopePos = ScopePos;
+ if (Stmt *Init = I->getInit())
addLocalScopeForStmt(Init);
- addAutomaticObjDtors(ScopePos, BeginScopePos, I);
- }
// Create local scope for possible condition variable.
// Store scope position. Add implicit destructor.
- if (VarDecl *VD = I->getConditionVariable()) {
- LocalScope::const_iterator BeginScopePos = ScopePos;
+ if (VarDecl *VD = I->getConditionVariable())
addLocalScopeForVarDecl(VD);
- addAutomaticObjDtors(ScopePos, BeginScopePos, I);
- }
+
+ addAutomaticObjDtors(ScopePos, save_scope_pos.get(), I);
// The block we were processing is now finished. Make it the successor
// block.
@@ -2256,36 +2252,39 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
// removes infeasible paths from the control-flow graph by having the
// control-flow transfer of '&&' or '||' go directly into the then/else
// blocks directly.
- if (!I->getConditionVariable())
- if (BinaryOperator *Cond =
- dyn_cast<BinaryOperator>(I->getCond()->IgnoreParens()))
- if (Cond->isLogicalOp())
- return VisitLogicalOperator(Cond, I, ThenBlock, ElseBlock).first;
-
- // Now create a new block containing the if statement.
- Block = createBlock(false);
+ BinaryOperator *Cond =
+ I->getConditionVariable()
+ ? nullptr
+ : dyn_cast<BinaryOperator>(I->getCond()->IgnoreParens());
+ CFGBlock *LastBlock;
+ if (Cond && Cond->isLogicalOp())
+ LastBlock = VisitLogicalOperator(Cond, I, ThenBlock, ElseBlock).first;
+ else {
+ // Now create a new block containing the if statement.
+ Block = createBlock(false);
- // Set the terminator of the new block to the If statement.
- Block->setTerminator(I);
+ // Set the terminator of the new block to the If statement.
+ Block->setTerminator(I);
- // See if this is a known constant.
- const TryResult &KnownVal = tryEvaluateBool(I->getCond());
+ // See if this is a known constant.
+ const TryResult &KnownVal = tryEvaluateBool(I->getCond());
- // Add the successors. If we know that specific branches are
- // unreachable, inform addSuccessor() of that knowledge.
- addSuccessor(Block, ThenBlock, /* isReachable = */ !KnownVal.isFalse());
- addSuccessor(Block, ElseBlock, /* isReachable = */ !KnownVal.isTrue());
+ // Add the successors. If we know that specific branches are
+ // unreachable, inform addSuccessor() of that knowledge.
+ addSuccessor(Block, ThenBlock, /* isReachable = */ !KnownVal.isFalse());
+ addSuccessor(Block, ElseBlock, /* isReachable = */ !KnownVal.isTrue());
- // Add the condition as the last statement in the new block. This may create
- // new blocks as the condition may contain control-flow. Any newly created
- // blocks will be pointed to be "Block".
- CFGBlock *LastBlock = addStmt(I->getCond());
+ // Add the condition as the last statement in the new block. This may
+ // create new blocks as the condition may contain control-flow. Any newly
+ // created blocks will be pointed to be "Block".
+ LastBlock = addStmt(I->getCond());
- // If the IfStmt contains a condition variable, add it and its
- // initializer to the CFG.
- if (const DeclStmt* DS = I->getConditionVariableDeclStmt()) {
- autoCreateBlock();
- LastBlock = addStmt(const_cast<DeclStmt *>(DS));
+ // If the IfStmt contains a condition variable, add it and its
+ // initializer to the CFG.
+ if (const DeclStmt* DS = I->getConditionVariableDeclStmt()) {
+ autoCreateBlock();
+ LastBlock = addStmt(const_cast<DeclStmt *>(DS));
+ }
}
// Finally, if the IfStmt contains a C++17 init-stmt, add it to the CFG.
@@ -3078,19 +3077,15 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(SwitchStmt *Terminator) {
SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
// Create local scope for C++17 switch init-stmt if one exists.
- if (Stmt *Init = Terminator->getInit()) {
- LocalScope::const_iterator BeginScopePos = ScopePos;
+ if (Stmt *Init = Terminator->getInit())
addLocalScopeForStmt(Init);
- addAutomaticObjDtors(ScopePos, BeginScopePos, Terminator);
- }
// Create local scope for possible condition variable.
// Store scope position. Add implicit destructor.
- if (VarDecl *VD = Terminator->getConditionVariable()) {
- LocalScope::const_iterator SwitchBeginScopePos = ScopePos;
+ if (VarDecl *VD = Terminator->getConditionVariable())
addLocalScopeForVarDecl(VD);
- addAutomaticObjDtors(ScopePos, SwitchBeginScopePos, Terminator);
- }
+
+ addAutomaticObjDtors(ScopePos, save_scope_pos.get(), Terminator);
if (Block) {
if (badCFG)
diff --git a/contrib/llvm/tools/clang/lib/Analysis/ReachableCode.cpp b/contrib/llvm/tools/clang/lib/Analysis/ReachableCode.cpp
index 69d000c03bac..a2f3203762f7 100644
--- a/contrib/llvm/tools/clang/lib/Analysis/ReachableCode.cpp
+++ b/contrib/llvm/tools/clang/lib/Analysis/ReachableCode.cpp
@@ -218,11 +218,21 @@ static bool isConfigurationValue(const Stmt *S,
}
case Stmt::UnaryOperatorClass: {
const UnaryOperator *UO = cast<UnaryOperator>(S);
- if (SilenceableCondVal)
- *SilenceableCondVal = UO->getSourceRange();
- return UO->getOpcode() == UO_LNot &&
- isConfigurationValue(UO->getSubExpr(), PP, SilenceableCondVal,
- IncludeIntegers, WrappedInParens);
+ if (UO->getOpcode() != UO_LNot)
+ return false;
+ bool SilenceableCondValNotSet =
+ SilenceableCondVal && SilenceableCondVal->getBegin().isInvalid();
+ bool IsSubExprConfigValue =
+ isConfigurationValue(UO->getSubExpr(), PP, SilenceableCondVal,
+ IncludeIntegers, WrappedInParens);
+ // Update the silenceable condition value source range only if the range
+ // was set directly by the child expression.
+ if (SilenceableCondValNotSet &&
+ SilenceableCondVal->getBegin().isValid() &&
+ *SilenceableCondVal ==
+ UO->getSubExpr()->IgnoreCasts()->getSourceRange())
+ *SilenceableCondVal = UO->getSourceRange();
+ return IsSubExprConfigValue;
}
default:
return false;
diff --git a/contrib/llvm/tools/clang/lib/Basic/OpenMPKinds.cpp b/contrib/llvm/tools/clang/lib/Basic/OpenMPKinds.cpp
index 7bd1f8762bff..905c3693d378 100644
--- a/contrib/llvm/tools/clang/lib/Basic/OpenMPKinds.cpp
+++ b/contrib/llvm/tools/clang/lib/Basic/OpenMPKinds.cpp
@@ -700,6 +700,16 @@ bool clang::isAllowedClauseForDirective(OpenMPDirectiveKind DKind,
break;
}
break;
+ case OMPD_target_teams_distribute_simd:
+ switch (CKind) {
+#define OPENMP_TARGET_TEAMS_DISTRIBUTE_SIMD_CLAUSE(Name) \
+ case OMPC_##Name: \
+ return true;
+#include "clang/Basic/OpenMPKinds.def"
+ default:
+ break;
+ }
+ break;
case OMPD_declare_target:
case OMPD_end_declare_target:
case OMPD_unknown:
@@ -732,7 +742,8 @@ bool clang::isOpenMPLoopDirective(OpenMPDirectiveKind DKind) {
DKind == OMPD_teams_distribute_parallel_for ||
DKind == OMPD_target_teams_distribute ||
DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd;
+ DKind == OMPD_target_teams_distribute_parallel_for_simd ||
+ DKind == OMPD_target_teams_distribute_simd;
}
bool clang::isOpenMPWorksharingDirective(OpenMPDirectiveKind DKind) {
@@ -773,7 +784,8 @@ bool clang::isOpenMPTargetExecutionDirective(OpenMPDirectiveKind DKind) {
DKind == OMPD_target_parallel_for_simd || DKind == OMPD_target_simd ||
DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd;
+ DKind == OMPD_target_teams_distribute_parallel_for_simd ||
+ DKind == OMPD_target_teams_distribute_simd;
}
bool clang::isOpenMPTargetDataManagementDirective(OpenMPDirectiveKind DKind) {
@@ -792,7 +804,8 @@ bool clang::isOpenMPTeamsDirective(OpenMPDirectiveKind DKind) {
return isOpenMPNestingTeamsDirective(DKind) ||
DKind == OMPD_target_teams || DKind == OMPD_target_teams_distribute ||
DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd;
+ DKind == OMPD_target_teams_distribute_parallel_for_simd ||
+ DKind == OMPD_target_teams_distribute_simd;
}
bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {
@@ -802,7 +815,8 @@ bool clang::isOpenMPSimdDirective(OpenMPDirectiveKind DKind) {
DKind == OMPD_distribute_simd || DKind == OMPD_target_simd ||
DKind == OMPD_teams_distribute_simd ||
DKind == OMPD_teams_distribute_parallel_for_simd ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd;
+ DKind == OMPD_target_teams_distribute_parallel_for_simd ||
+ DKind == OMPD_target_teams_distribute_simd;
}
bool clang::isOpenMPNestingDistributeDirective(OpenMPDirectiveKind Kind) {
@@ -819,7 +833,8 @@ bool clang::isOpenMPDistributeDirective(OpenMPDirectiveKind Kind) {
Kind == OMPD_teams_distribute_parallel_for ||
Kind == OMPD_target_teams_distribute ||
Kind == OMPD_target_teams_distribute_parallel_for ||
- Kind == OMPD_target_teams_distribute_parallel_for_simd;
+ Kind == OMPD_target_teams_distribute_parallel_for_simd ||
+ Kind == OMPD_target_teams_distribute_simd;
}
bool clang::isOpenMPPrivate(OpenMPClauseKind Kind) {
@@ -845,5 +860,6 @@ bool clang::isOpenMPLoopBoundSharingDirective(OpenMPDirectiveKind Kind) {
Kind == OMPD_teams_distribute_parallel_for ||
Kind == OMPD_target_teams_distribute ||
Kind == OMPD_target_teams_distribute_parallel_for ||
- Kind == OMPD_target_teams_distribute_parallel_for_simd;
+ Kind == OMPD_target_teams_distribute_parallel_for_simd ||
+ Kind == OMPD_target_teams_distribute_simd;
}
diff --git a/contrib/llvm/tools/clang/lib/Basic/Targets.cpp b/contrib/llvm/tools/clang/lib/Basic/Targets.cpp
index 4d2b3d007599..89e3f3ebbe3f 100644
--- a/contrib/llvm/tools/clang/lib/Basic/Targets.cpp
+++ b/contrib/llvm/tools/clang/lib/Basic/Targets.cpp
@@ -2663,6 +2663,12 @@ class X86TargetInfo : public TargetInfo {
CK_BDVER4,
//@}
+ /// \name zen
+ /// Zen architecture processors.
+ //@{
+ CK_ZNVER1,
+ //@}
+
/// This specification is deprecated and will be removed in the future.
/// Users should prefer \see CK_K8.
// FIXME: Warn on this when the CPU is set to it.
@@ -2744,6 +2750,7 @@ class X86TargetInfo : public TargetInfo {
.Case("bdver2", CK_BDVER2)
.Case("bdver3", CK_BDVER3)
.Case("bdver4", CK_BDVER4)
+ .Case("znver1", CK_ZNVER1)
.Case("x86-64", CK_x86_64)
.Case("geode", CK_Geode)
.Default(CK_Generic);
@@ -2943,6 +2950,7 @@ public:
case CK_BDVER2:
case CK_BDVER3:
case CK_BDVER4:
+ case CK_ZNVER1:
case CK_x86_64:
return true;
}
@@ -3190,6 +3198,33 @@ bool X86TargetInfo::initFeatureMap(
setFeatureEnabledImpl(Features, "cx16", true);
setFeatureEnabledImpl(Features, "fxsr", true);
break;
+ case CK_ZNVER1:
+ setFeatureEnabledImpl(Features, "adx", true);
+ setFeatureEnabledImpl(Features, "aes", true);
+ setFeatureEnabledImpl(Features, "avx2", true);
+ setFeatureEnabledImpl(Features, "bmi", true);
+ setFeatureEnabledImpl(Features, "bmi2", true);
+ setFeatureEnabledImpl(Features, "clflushopt", true);
+ setFeatureEnabledImpl(Features, "cx16", true);
+ setFeatureEnabledImpl(Features, "f16c", true);
+ setFeatureEnabledImpl(Features, "fma", true);
+ setFeatureEnabledImpl(Features, "fsgsbase", true);
+ setFeatureEnabledImpl(Features, "fxsr", true);
+ setFeatureEnabledImpl(Features, "lzcnt", true);
+ setFeatureEnabledImpl(Features, "mwaitx", true);
+ setFeatureEnabledImpl(Features, "movbe", true);
+ setFeatureEnabledImpl(Features, "pclmul", true);
+ setFeatureEnabledImpl(Features, "popcnt", true);
+ setFeatureEnabledImpl(Features, "prfchw", true);
+ setFeatureEnabledImpl(Features, "rdrnd", true);
+ setFeatureEnabledImpl(Features, "rdseed", true);
+ setFeatureEnabledImpl(Features, "sha", true);
+ setFeatureEnabledImpl(Features, "sse4a", true);
+ setFeatureEnabledImpl(Features, "xsave", true);
+ setFeatureEnabledImpl(Features, "xsavec", true);
+ setFeatureEnabledImpl(Features, "xsaveopt", true);
+ setFeatureEnabledImpl(Features, "xsaves", true);
+ break;
case CK_BDVER4:
setFeatureEnabledImpl(Features, "avx2", true);
setFeatureEnabledImpl(Features, "bmi2", true);
@@ -3741,6 +3776,9 @@ void X86TargetInfo::getTargetDefines(const LangOptions &Opts,
case CK_BDVER4:
defineCPUMacros(Builder, "bdver4");
break;
+ case CK_ZNVER1:
+ defineCPUMacros(Builder, "znver1");
+ break;
case CK_Geode:
defineCPUMacros(Builder, "geode");
break;
diff --git a/contrib/llvm/tools/clang/lib/Basic/Version.cpp b/contrib/llvm/tools/clang/lib/Basic/Version.cpp
index a1a67c2bc144..b91efeb34c7f 100644
--- a/contrib/llvm/tools/clang/lib/Basic/Version.cpp
+++ b/contrib/llvm/tools/clang/lib/Basic/Version.cpp
@@ -36,7 +36,7 @@ std::string getClangRepositoryPath() {
// If the SVN_REPOSITORY is empty, try to use the SVN keyword. This helps us
// pick up a tag in an SVN export, for example.
- StringRef SVNRepository("$URL: https://llvm.org/svn/llvm-project/cfe/trunk/lib/Basic/Version.cpp $");
+ StringRef SVNRepository("$URL: https://llvm.org/svn/llvm-project/cfe/branches/release_40/lib/Basic/Version.cpp $");
if (URL.empty()) {
URL = SVNRepository.slice(SVNRepository.find(':'),
SVNRepository.find("/lib/Basic"));
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGBuiltin.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CGBuiltin.cpp
index 4d34b3e9222f..2ede1d46b3d5 100644
--- a/contrib/llvm/tools/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/contrib/llvm/tools/clang/lib/CodeGen/CGBuiltin.cpp
@@ -4318,9 +4318,9 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
}
if (BuiltinID == ARM::BI__builtin_arm_rbit) {
- return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::arm_rbit),
- EmitScalarExpr(E->getArg(0)),
- "rbit");
+ llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
+ return Builder.CreateCall(
+ CGM.getIntrinsic(Intrinsic::bitreverse, Arg->getType()), Arg, "rbit");
}
if (BuiltinID == ARM::BI__clear_cache) {
@@ -5226,14 +5226,14 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
"rbit of unusual size!");
llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
return Builder.CreateCall(
- CGM.getIntrinsic(Intrinsic::aarch64_rbit, Arg->getType()), Arg, "rbit");
+ CGM.getIntrinsic(Intrinsic::bitreverse, Arg->getType()), Arg, "rbit");
}
if (BuiltinID == AArch64::BI__builtin_arm_rbit64) {
assert((getContext().getTypeSize(E->getType()) == 64) &&
"rbit of unusual size!");
llvm::Value *Arg = EmitScalarExpr(E->getArg(0));
return Builder.CreateCall(
- CGM.getIntrinsic(Intrinsic::aarch64_rbit, Arg->getType()), Arg, "rbit");
+ CGM.getIntrinsic(Intrinsic::bitreverse, Arg->getType()), Arg, "rbit");
}
if (BuiltinID == AArch64::BI__clear_cache) {
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGDecl.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CGDecl.cpp
index d76136380160..0a88b2310beb 100644
--- a/contrib/llvm/tools/clang/lib/CodeGen/CGDecl.cpp
+++ b/contrib/llvm/tools/clang/lib/CodeGen/CGDecl.cpp
@@ -311,7 +311,7 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D,
if (!Init) {
if (!getLangOpts().CPlusPlus)
CGM.ErrorUnsupported(D.getInit(), "constant l-value expression");
- else if (Builder.GetInsertBlock()) {
+ else if (HaveInsertPoint()) {
// Since we have a static initializer, this global variable can't
// be constant.
GV->setConstant(false);
@@ -352,7 +352,7 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D,
GV->setConstant(CGM.isTypeConstant(D.getType(), true));
GV->setInitializer(Init);
- if (hasNontrivialDestruction(D.getType())) {
+ if (hasNontrivialDestruction(D.getType()) && HaveInsertPoint()) {
// We have a constant initializer, but a nontrivial destructor. We still
// need to perform a guarded "initialization" in order to register the
// destructor.
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp
index 8d9d0b21bfe1..f56e18216931 100644
--- a/contrib/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/contrib/llvm/tools/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -353,9 +353,6 @@ CodeGenModule::EmitCXXGlobalVarDeclInitFunc(const VarDecl *D,
if (D->getTLSKind()) {
// FIXME: Should we support init_priority for thread_local?
- // FIXME: Ideally, initialization of instantiated thread_local static data
- // members of class templates should not trigger initialization of other
- // entities in the TU.
// FIXME: We only need to register one __cxa_thread_atexit function for the
// entire TU.
CXXThreadLocalInits.push_back(Fn);
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 27af344fae87..db9de2ab6ad5 100644
--- a/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -99,10 +99,11 @@ class CGOpenMPOutlinedRegionInfo final : public CGOpenMPRegionInfo {
public:
CGOpenMPOutlinedRegionInfo(const CapturedStmt &CS, const VarDecl *ThreadIDVar,
const RegionCodeGenTy &CodeGen,
- OpenMPDirectiveKind Kind, bool HasCancel)
+ OpenMPDirectiveKind Kind, bool HasCancel,
+ StringRef HelperName)
: CGOpenMPRegionInfo(CS, ParallelOutlinedRegion, CodeGen, Kind,
HasCancel),
- ThreadIDVar(ThreadIDVar) {
+ ThreadIDVar(ThreadIDVar), HelperName(HelperName) {
assert(ThreadIDVar != nullptr && "No ThreadID in OpenMP region.");
}
@@ -111,7 +112,7 @@ public:
const VarDecl *getThreadIDVariable() const override { return ThreadIDVar; }
/// \brief Get the name of the capture helper.
- StringRef getHelperName() const override { return ".omp_outlined."; }
+ StringRef getHelperName() const override { return HelperName; }
static bool classof(const CGCapturedStmtInfo *Info) {
return CGOpenMPRegionInfo::classof(Info) &&
@@ -123,6 +124,7 @@ private:
/// \brief A variable or parameter storing global thread id for OpenMP
/// constructs.
const VarDecl *ThreadIDVar;
+ StringRef HelperName;
};
/// \brief API for captured statement code generation in OpenMP constructs.
@@ -855,7 +857,7 @@ llvm::Value *CGOpenMPRuntime::emitParallelOrTeamsOutlinedFunction(
else if (auto *OPFD = dyn_cast<OMPParallelForDirective>(&D))
HasCancel = OPFD->hasCancel();
CGOpenMPOutlinedRegionInfo CGInfo(*CS, ThreadIDVar, CodeGen, InnermostKind,
- HasCancel);
+ HasCancel, getOutlinedHelperName());
CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(CGF, &CGInfo);
return CGF.GenerateOpenMPCapturedStmtFunction(*CS);
}
@@ -1892,9 +1894,9 @@ llvm::Function *CGOpenMPRuntime::emitThreadPrivateVarDefinition(
/// } else {
/// ElseGen();
/// }
-static void emitOMPIfClause(CodeGenFunction &CGF, const Expr *Cond,
- const RegionCodeGenTy &ThenGen,
- const RegionCodeGenTy &ElseGen) {
+void CGOpenMPRuntime::emitOMPIfClause(CodeGenFunction &CGF, const Expr *Cond,
+ const RegionCodeGenTy &ThenGen,
+ const RegionCodeGenTy &ElseGen) {
CodeGenFunction::LexicalScope ConditionScope(CGF, Cond->getSourceRange());
// If the condition constant folds and can be elided, try to avoid emitting
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.h b/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.h
index 9a784dff0ae8..61ddc702ed24 100644
--- a/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -130,6 +130,35 @@ protected:
bool IsOffloadEntry,
const RegionCodeGenTy &CodeGen);
+ /// \brief Emits code for OpenMP 'if' clause using specified \a CodeGen
+ /// function. Here is the logic:
+ /// if (Cond) {
+ /// ThenGen();
+ /// } else {
+ /// ElseGen();
+ /// }
+ void emitOMPIfClause(CodeGenFunction &CGF, const Expr *Cond,
+ const RegionCodeGenTy &ThenGen,
+ const RegionCodeGenTy &ElseGen);
+
+ /// \brief Emits object of ident_t type with info for source location.
+ /// \param Flags Flags for OpenMP location.
+ ///
+ llvm::Value *emitUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc,
+ unsigned Flags = 0);
+
+ /// \brief Returns pointer to ident_t type.
+ llvm::Type *getIdentTyPointerTy();
+
+ /// \brief Gets thread id value for the current thread.
+ ///
+ llvm::Value *getThreadID(CodeGenFunction &CGF, SourceLocation Loc);
+
+ /// \brief Get the function name of an outlined region.
+ // The name can be customized depending on the target.
+ //
+ virtual StringRef getOutlinedHelperName() const { return ".omp_outlined."; }
+
private:
/// \brief Default const ident_t object used for initialization of all other
/// ident_t objects.
@@ -388,15 +417,6 @@ private:
/// \brief Build type kmp_routine_entry_t (if not built yet).
void emitKmpRoutineEntryT(QualType KmpInt32Ty);
- /// \brief Emits object of ident_t type with info for source location.
- /// \param Flags Flags for OpenMP location.
- ///
- llvm::Value *emitUpdateLocation(CodeGenFunction &CGF, SourceLocation Loc,
- unsigned Flags = 0);
-
- /// \brief Returns pointer to ident_t type.
- llvm::Type *getIdentTyPointerTy();
-
/// \brief Returns pointer to kmpc_micro type.
llvm::Type *getKmpc_MicroPointerTy();
@@ -432,10 +452,6 @@ private:
/// stored.
virtual Address emitThreadIDAddress(CodeGenFunction &CGF, SourceLocation Loc);
- /// \brief Gets thread id value for the current thread.
- ///
- llvm::Value *getThreadID(CodeGenFunction &CGF, SourceLocation Loc);
-
/// \brief Gets (if variable with the given name already exist) or creates
/// internal global variable with the specified Name. The created variable has
/// linkage CommonLinkage by default and is initialized by null value.
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
index bc1458b1c203..6a6d832e33cd 100644
--- a/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ b/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -26,8 +26,57 @@ enum OpenMPRTLFunctionNVPTX {
OMPRTL_NVPTX__kmpc_kernel_init,
/// \brief Call to void __kmpc_kernel_deinit();
OMPRTL_NVPTX__kmpc_kernel_deinit,
+ /// \brief Call to void __kmpc_kernel_prepare_parallel(void
+ /// *outlined_function);
+ OMPRTL_NVPTX__kmpc_kernel_prepare_parallel,
+ /// \brief Call to bool __kmpc_kernel_parallel(void **outlined_function);
+ OMPRTL_NVPTX__kmpc_kernel_parallel,
+ /// \brief Call to void __kmpc_kernel_end_parallel();
+ OMPRTL_NVPTX__kmpc_kernel_end_parallel,
+ /// Call to void __kmpc_serialized_parallel(ident_t *loc, kmp_int32
+ /// global_tid);
+ OMPRTL_NVPTX__kmpc_serialized_parallel,
+ /// Call to void __kmpc_end_serialized_parallel(ident_t *loc, kmp_int32
+ /// global_tid);
+ OMPRTL_NVPTX__kmpc_end_serialized_parallel,
};
-} // namespace
+
+/// Pre(post)-action for different OpenMP constructs specialized for NVPTX.
+class NVPTXActionTy final : public PrePostActionTy {
+ llvm::Value *EnterCallee;
+ ArrayRef<llvm::Value *> EnterArgs;
+ llvm::Value *ExitCallee;
+ ArrayRef<llvm::Value *> ExitArgs;
+ bool Conditional;
+ llvm::BasicBlock *ContBlock = nullptr;
+
+public:
+ NVPTXActionTy(llvm::Value *EnterCallee, ArrayRef<llvm::Value *> EnterArgs,
+ llvm::Value *ExitCallee, ArrayRef<llvm::Value *> ExitArgs,
+ bool Conditional = false)
+ : EnterCallee(EnterCallee), EnterArgs(EnterArgs), ExitCallee(ExitCallee),
+ ExitArgs(ExitArgs), Conditional(Conditional) {}
+ void Enter(CodeGenFunction &CGF) override {
+ llvm::Value *EnterRes = CGF.EmitRuntimeCall(EnterCallee, EnterArgs);
+ if (Conditional) {
+ llvm::Value *CallBool = CGF.Builder.CreateIsNotNull(EnterRes);
+ auto *ThenBlock = CGF.createBasicBlock("omp_if.then");
+ ContBlock = CGF.createBasicBlock("omp_if.end");
+ // Generate the branch (If-stmt)
+ CGF.Builder.CreateCondBr(CallBool, ThenBlock, ContBlock);
+ CGF.EmitBlock(ThenBlock);
+ }
+ }
+ void Done(CodeGenFunction &CGF) {
+ // Emit the rest of blocks/branches
+ CGF.EmitBranch(ContBlock);
+ CGF.EmitBlock(ContBlock, true);
+ }
+ void Exit(CodeGenFunction &CGF) override {
+ CGF.EmitRuntimeCall(ExitCallee, ExitArgs);
+ }
+};
+} // anonymous namespace
/// Get the GPU warp size.
static llvm::Value *getNVPTXWarpSize(CodeGenFunction &CGF) {
@@ -118,6 +167,7 @@ void CGOpenMPRuntimeNVPTX::emitGenericKernel(const OMPExecutableDirective &D,
const RegionCodeGenTy &CodeGen) {
EntryFunctionState EST;
WorkerFunctionState WST(CGM);
+ Work.clear();
// Emit target region as a standalone region.
class NVPTXPrePostActionTy : public PrePostActionTy {
@@ -246,7 +296,10 @@ void CGOpenMPRuntimeNVPTX::emitWorkerLoop(CodeGenFunction &CGF,
CGF.InitTempAlloca(ExecStatus, Bld.getInt8(/*C=*/0));
CGF.InitTempAlloca(WorkFn, llvm::Constant::getNullValue(CGF.Int8PtrTy));
- // TODO: Call into runtime to get parallel work.
+ llvm::Value *Args[] = {WorkFn.getPointer()};
+ llvm::Value *Ret = CGF.EmitRuntimeCall(
+ createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_parallel), Args);
+ Bld.CreateStore(Bld.CreateZExt(Ret, CGF.Int8Ty), ExecStatus);
// On termination condition (workid == 0), exit loop.
llvm::Value *ShouldTerminate =
@@ -261,10 +314,42 @@ void CGOpenMPRuntimeNVPTX::emitWorkerLoop(CodeGenFunction &CGF,
// Signal start of parallel region.
CGF.EmitBlock(ExecuteBB);
- // TODO: Add parallel work.
+
+ // Process work items: outlined parallel functions.
+ for (auto *W : Work) {
+ // Try to match this outlined function.
+ auto *ID = Bld.CreatePointerBitCastOrAddrSpaceCast(W, CGM.Int8PtrTy);
+
+ llvm::Value *WorkFnMatch =
+ Bld.CreateICmpEQ(Bld.CreateLoad(WorkFn), ID, "work_match");
+
+ llvm::BasicBlock *ExecuteFNBB = CGF.createBasicBlock(".execute.fn");
+ llvm::BasicBlock *CheckNextBB = CGF.createBasicBlock(".check.next");
+ Bld.CreateCondBr(WorkFnMatch, ExecuteFNBB, CheckNextBB);
+
+ // Execute this outlined function.
+ CGF.EmitBlock(ExecuteFNBB);
+
+ // Insert call to work function.
+ // FIXME: Pass arguments to outlined function from master thread.
+ auto *Fn = cast<llvm::Function>(W);
+ Address ZeroAddr =
+ CGF.CreateDefaultAlignTempAlloca(CGF.Int32Ty, /*Name=*/".zero.addr");
+ CGF.InitTempAlloca(ZeroAddr, CGF.Builder.getInt32(/*C=*/0));
+ llvm::Value *FnArgs[] = {ZeroAddr.getPointer(), ZeroAddr.getPointer()};
+ CGF.EmitCallOrInvoke(Fn, FnArgs);
+
+ // Go to end of parallel region.
+ CGF.EmitBranch(TerminateBB);
+
+ CGF.EmitBlock(CheckNextBB);
+ }
// Signal end of parallel region.
CGF.EmitBlock(TerminateBB);
+ CGF.EmitRuntimeCall(
+ createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_end_parallel),
+ llvm::None);
CGF.EmitBranch(BarrierBB);
// All active and inactive workers wait at a barrier after parallel region.
@@ -296,10 +381,53 @@ CGOpenMPRuntimeNVPTX::createNVPTXRuntimeFunction(unsigned Function) {
case OMPRTL_NVPTX__kmpc_kernel_deinit: {
// Build void __kmpc_kernel_deinit();
llvm::FunctionType *FnTy =
- llvm::FunctionType::get(CGM.VoidTy, {}, /*isVarArg*/ false);
+ llvm::FunctionType::get(CGM.VoidTy, llvm::None, /*isVarArg*/ false);
RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_kernel_deinit");
break;
}
+ case OMPRTL_NVPTX__kmpc_kernel_prepare_parallel: {
+ /// Build void __kmpc_kernel_prepare_parallel(
+ /// void *outlined_function);
+ llvm::Type *TypeParams[] = {CGM.Int8PtrTy};
+ llvm::FunctionType *FnTy =
+ llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
+ RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_kernel_prepare_parallel");
+ break;
+ }
+ case OMPRTL_NVPTX__kmpc_kernel_parallel: {
+ /// Build bool __kmpc_kernel_parallel(void **outlined_function);
+ llvm::Type *TypeParams[] = {CGM.Int8PtrPtrTy};
+ llvm::Type *RetTy = CGM.getTypes().ConvertType(CGM.getContext().BoolTy);
+ llvm::FunctionType *FnTy =
+ llvm::FunctionType::get(RetTy, TypeParams, /*isVarArg*/ false);
+ RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_kernel_parallel");
+ break;
+ }
+ case OMPRTL_NVPTX__kmpc_kernel_end_parallel: {
+ /// Build void __kmpc_kernel_end_parallel();
+ llvm::FunctionType *FnTy =
+ llvm::FunctionType::get(CGM.VoidTy, llvm::None, /*isVarArg*/ false);
+ RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_kernel_end_parallel");
+ break;
+ }
+ case OMPRTL_NVPTX__kmpc_serialized_parallel: {
+ // Build void __kmpc_serialized_parallel(ident_t *loc, kmp_int32
+ // global_tid);
+ llvm::Type *TypeParams[] = {getIdentTyPointerTy(), CGM.Int32Ty};
+ llvm::FunctionType *FnTy =
+ llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
+ RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_serialized_parallel");
+ break;
+ }
+ case OMPRTL_NVPTX__kmpc_end_serialized_parallel: {
+ // Build void __kmpc_end_serialized_parallel(ident_t *loc, kmp_int32
+ // global_tid);
+ llvm::Type *TypeParams[] = {getIdentTyPointerTy(), CGM.Int32Ty};
+ llvm::FunctionType *FnTy =
+ llvm::FunctionType::get(CGM.VoidTy, TypeParams, /*isVarArg*/ false);
+ RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_end_serialized_parallel");
+ break;
+ }
}
return RTLFn;
}
@@ -362,9 +490,12 @@ llvm::Value *CGOpenMPRuntimeNVPTX::emitParallelOrTeamsOutlinedFunction(
OutlinedFun = cast<llvm::Function>(OutlinedFunVal);
OutlinedFun->removeFnAttr(llvm::Attribute::NoInline);
OutlinedFun->addFnAttr(llvm::Attribute::AlwaysInline);
- } else
- llvm_unreachable("parallel directive is not yet supported for nvptx "
- "backend.");
+ } else {
+ llvm::Value *OutlinedFunVal =
+ CGOpenMPRuntime::emitParallelOrTeamsOutlinedFunction(
+ D, ThreadIDVar, InnermostKind, CodeGen);
+ OutlinedFun = cast<llvm::Function>(OutlinedFunVal);
+ }
return OutlinedFun;
}
@@ -387,3 +518,81 @@ void CGOpenMPRuntimeNVPTX::emitTeamsCall(CodeGenFunction &CGF,
OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
CGF.EmitCallOrInvoke(OutlinedFn, OutlinedFnArgs);
}
+
+void CGOpenMPRuntimeNVPTX::emitParallelCall(
+ CodeGenFunction &CGF, SourceLocation Loc, llvm::Value *OutlinedFn,
+ ArrayRef<llvm::Value *> CapturedVars, const Expr *IfCond) {
+ if (!CGF.HaveInsertPoint())
+ return;
+
+ emitGenericParallelCall(CGF, Loc, OutlinedFn, CapturedVars, IfCond);
+}
+
+void CGOpenMPRuntimeNVPTX::emitGenericParallelCall(
+ CodeGenFunction &CGF, SourceLocation Loc, llvm::Value *OutlinedFn,
+ ArrayRef<llvm::Value *> CapturedVars, const Expr *IfCond) {
+ llvm::Function *Fn = cast<llvm::Function>(OutlinedFn);
+
+ auto &&L0ParallelGen = [this, Fn, &CapturedVars](CodeGenFunction &CGF,
+ PrePostActionTy &) {
+ CGBuilderTy &Bld = CGF.Builder;
+
+ // Prepare for parallel region. Indicate the outlined function.
+ llvm::Value *Args[] = {Bld.CreateBitOrPointerCast(Fn, CGM.Int8PtrTy)};
+ CGF.EmitRuntimeCall(
+ createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_kernel_prepare_parallel),
+ Args);
+
+ // Activate workers. This barrier is used by the master to signal
+ // work for the workers.
+ syncCTAThreads(CGF);
+
+ // OpenMP [2.5, Parallel Construct, p.49]
+ // There is an implied barrier at the end of a parallel region. After the
+ // end of a parallel region, only the master thread of the team resumes
+ // execution of the enclosing task region.
+ //
+ // The master waits at this barrier until all workers are done.
+ syncCTAThreads(CGF);
+
+ // Remember for post-processing in worker loop.
+ Work.push_back(Fn);
+ };
+
+ auto *RTLoc = emitUpdateLocation(CGF, Loc);
+ auto *ThreadID = getThreadID(CGF, Loc);
+ llvm::Value *Args[] = {RTLoc, ThreadID};
+
+ auto &&SeqGen = [this, Fn, &CapturedVars, &Args](CodeGenFunction &CGF,
+ PrePostActionTy &) {
+ auto &&CodeGen = [this, Fn, &CapturedVars, &Args](CodeGenFunction &CGF,
+ PrePostActionTy &Action) {
+ Action.Enter(CGF);
+
+ llvm::SmallVector<llvm::Value *, 16> OutlinedFnArgs;
+ OutlinedFnArgs.push_back(
+ llvm::ConstantPointerNull::get(CGM.Int32Ty->getPointerTo()));
+ OutlinedFnArgs.push_back(
+ llvm::ConstantPointerNull::get(CGM.Int32Ty->getPointerTo()));
+ OutlinedFnArgs.append(CapturedVars.begin(), CapturedVars.end());
+ CGF.EmitCallOrInvoke(Fn, OutlinedFnArgs);
+ };
+
+ RegionCodeGenTy RCG(CodeGen);
+ NVPTXActionTy Action(
+ createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_serialized_parallel),
+ Args,
+ createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_end_serialized_parallel),
+ Args);
+ RCG.setAction(Action);
+ RCG(CGF);
+ };
+
+ if (IfCond)
+ emitOMPIfClause(CGF, IfCond, L0ParallelGen, SeqGen);
+ else {
+ CodeGenFunction::RunCleanupsScope Scope(CGF);
+ RegionCodeGenTy ThenRCG(L0ParallelGen);
+ ThenRCG(CGF);
+ }
+}
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h b/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
index 63a02965a5bd..4010b46a4cbd 100644
--- a/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
+++ b/contrib/llvm/tools/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.h
@@ -25,6 +25,9 @@ namespace CodeGen {
class CGOpenMPRuntimeNVPTX : public CGOpenMPRuntime {
private:
+ // Parallel outlined function work for workers to execute.
+ llvm::SmallVector<llvm::Function *, 16> Work;
+
struct EntryFunctionState {
llvm::BasicBlock *ExitBB = nullptr;
};
@@ -100,6 +103,29 @@ private:
bool IsOffloadEntry,
const RegionCodeGenTy &CodeGen) override;
+ /// \brief Emits code for parallel or serial call of the \a OutlinedFn with
+ /// variables captured in a record which address is stored in \a
+ /// CapturedStruct.
+ /// This call is for the Generic Execution Mode.
+ /// \param OutlinedFn Outlined function to be run in parallel threads. Type of
+ /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
+ /// \param CapturedVars A pointer to the record with the references to
+ /// variables used in \a OutlinedFn function.
+ /// \param IfCond Condition in the associated 'if' clause, if it was
+ /// specified, nullptr otherwise.
+ void emitGenericParallelCall(CodeGenFunction &CGF, SourceLocation Loc,
+ llvm::Value *OutlinedFn,
+ ArrayRef<llvm::Value *> CapturedVars,
+ const Expr *IfCond);
+
+protected:
+ /// \brief Get the function name of an outlined region.
+ // The name can be customized depending on the target.
+ //
+ StringRef getOutlinedHelperName() const override {
+ return "__omp_outlined__";
+ }
+
public:
explicit CGOpenMPRuntimeNVPTX(CodeGenModule &CGM);
@@ -137,6 +163,20 @@ public:
void emitTeamsCall(CodeGenFunction &CGF, const OMPExecutableDirective &D,
SourceLocation Loc, llvm::Value *OutlinedFn,
ArrayRef<llvm::Value *> CapturedVars) override;
+
+ /// \brief Emits code for parallel or serial call of the \a OutlinedFn with
+ /// variables captured in a record which address is stored in \a
+ /// CapturedStruct.
+ /// \param OutlinedFn Outlined function to be run in parallel threads. Type of
+ /// this function is void(*)(kmp_int32 *, kmp_int32, struct context_vars*).
+ /// \param CapturedVars A pointer to the record with the references to
+ /// variables used in \a OutlinedFn function.
+ /// \param IfCond Condition in the associated 'if' clause, if it was
+ /// specified, nullptr otherwise.
+ void emitParallelCall(CodeGenFunction &CGF, SourceLocation Loc,
+ llvm::Value *OutlinedFn,
+ ArrayRef<llvm::Value *> CapturedVars,
+ const Expr *IfCond) override;
};
} // CodeGen namespace.
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGStmt.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CGStmt.cpp
index 8d391f95d9f7..8370607db50f 100644
--- a/contrib/llvm/tools/clang/lib/CodeGen/CGStmt.cpp
+++ b/contrib/llvm/tools/clang/lib/CodeGen/CGStmt.cpp
@@ -330,6 +330,10 @@ void CodeGenFunction::EmitStmt(const Stmt *S) {
EmitOMPTargetTeamsDistributeParallelForSimdDirective(
cast<OMPTargetTeamsDistributeParallelForSimdDirective>(*S));
break;
+ case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
+ EmitOMPTargetTeamsDistributeSimdDirective(
+ cast<OMPTargetTeamsDistributeSimdDirective>(*S));
+ break;
}
}
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CGStmtOpenMP.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 386c4f0fe69c..39e1cdfdbe2a 100644
--- a/contrib/llvm/tools/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/contrib/llvm/tools/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -2042,6 +2042,16 @@ void CodeGenFunction::EmitOMPTargetTeamsDistributeParallelForSimdDirective(
});
}
+void CodeGenFunction::EmitOMPTargetTeamsDistributeSimdDirective(
+ const OMPTargetTeamsDistributeSimdDirective &S) {
+ CGM.getOpenMPRuntime().emitInlinedDirective(
+ *this, OMPD_target_teams_distribute_simd,
+ [&S](CodeGenFunction &CGF, PrePostActionTy &) {
+ CGF.EmitStmt(
+ cast<CapturedStmt>(S.getAssociatedStmt())->getCapturedStmt());
+ });
+}
+
/// \brief Emit a helper variable and return corresponding lvalue.
static LValue EmitOMPHelperVar(CodeGenFunction &CGF,
const DeclRefExpr *Helper) {
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h b/contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h
index 05522cd40024..586134023240 100644
--- a/contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h
+++ b/contrib/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h
@@ -2701,6 +2701,8 @@ public:
const OMPTargetTeamsDistributeParallelForDirective &S);
void EmitOMPTargetTeamsDistributeParallelForSimdDirective(
const OMPTargetTeamsDistributeParallelForSimdDirective &S);
+ void EmitOMPTargetTeamsDistributeSimdDirective(
+ const OMPTargetTeamsDistributeSimdDirective &S);
/// Emit outlined function for the target directive.
static std::pair<llvm::Function * /*OutlinedFn*/,
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp b/contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp
index ab29d2dbb566..36005430ae4c 100644
--- a/contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/contrib/llvm/tools/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1243,9 +1243,15 @@ void CodeGenModule::EmitModuleLinkOptions() {
SmallVector<clang::Module *, 16> Stack;
// Seed the stack with imported modules.
- for (Module *M : ImportedModules)
+ for (Module *M : ImportedModules) {
+ // Do not add any link flags when an implementation TU of a module imports
+ // a header of that same module.
+ if (M->getTopLevelModuleName() == getLangOpts().CurrentModule &&
+ !getLangOpts().isCompilingModule())
+ continue;
if (Visited.insert(M).second)
Stack.push_back(M);
+ }
// Find all of the modules to import, making a little effort to prune
// non-leaf modules.
diff --git a/contrib/llvm/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp b/contrib/llvm/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp
index b5d90ea59a49..f7a8dd66c527 100644
--- a/contrib/llvm/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/contrib/llvm/tools/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2272,7 +2272,21 @@ void ItaniumCXXABI::EmitThreadLocalInitFuncs(
ArrayRef<llvm::Function *> CXXThreadLocalInits,
ArrayRef<const VarDecl *> CXXThreadLocalInitVars) {
llvm::Function *InitFunc = nullptr;
- if (!CXXThreadLocalInits.empty()) {
+
+ // Separate initializers into those with ordered (or partially-ordered)
+ // initialization and those with unordered initialization.
+ llvm::SmallVector<llvm::Function *, 8> OrderedInits;
+ llvm::SmallDenseMap<const VarDecl *, llvm::Function *> UnorderedInits;
+ for (unsigned I = 0; I != CXXThreadLocalInits.size(); ++I) {
+ if (isTemplateInstantiation(
+ CXXThreadLocalInitVars[I]->getTemplateSpecializationKind()))
+ UnorderedInits[CXXThreadLocalInitVars[I]->getCanonicalDecl()] =
+ CXXThreadLocalInits[I];
+ else
+ OrderedInits.push_back(CXXThreadLocalInits[I]);
+ }
+
+ if (!OrderedInits.empty()) {
// Generate a guarded initialization function.
llvm::FunctionType *FTy =
llvm::FunctionType::get(CGM.VoidTy, /*isVarArg=*/false);
@@ -2289,24 +2303,28 @@ void ItaniumCXXABI::EmitThreadLocalInitFuncs(
CharUnits GuardAlign = CharUnits::One();
Guard->setAlignment(GuardAlign.getQuantity());
- CodeGenFunction(CGM)
- .GenerateCXXGlobalInitFunc(InitFunc, CXXThreadLocalInits,
- Address(Guard, GuardAlign));
+ CodeGenFunction(CGM).GenerateCXXGlobalInitFunc(InitFunc, OrderedInits,
+ Address(Guard, GuardAlign));
// On Darwin platforms, use CXX_FAST_TLS calling convention.
if (CGM.getTarget().getTriple().isOSDarwin()) {
InitFunc->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
InitFunc->addFnAttr(llvm::Attribute::NoUnwind);
}
}
+
+ // Emit thread wrappers.
for (const VarDecl *VD : CXXThreadLocals) {
llvm::GlobalVariable *Var =
cast<llvm::GlobalVariable>(CGM.GetGlobalValue(CGM.getMangledName(VD)));
+ llvm::Function *Wrapper = getOrCreateThreadLocalWrapper(VD, Var);
// Some targets require that all access to thread local variables go through
// the thread wrapper. This means that we cannot attempt to create a thread
// wrapper or a thread helper.
- if (isThreadWrapperReplaceable(VD, CGM) && !VD->hasDefinition())
+ if (isThreadWrapperReplaceable(VD, CGM) && !VD->hasDefinition()) {
+ Wrapper->setLinkage(llvm::Function::ExternalLinkage);
continue;
+ }
// Mangle the name for the thread_local initialization function.
SmallString<256> InitFnName;
@@ -2322,18 +2340,21 @@ void ItaniumCXXABI::EmitThreadLocalInitFuncs(
bool InitIsInitFunc = false;
if (VD->hasDefinition()) {
InitIsInitFunc = true;
- if (InitFunc)
+ llvm::Function *InitFuncToUse = InitFunc;
+ if (isTemplateInstantiation(VD->getTemplateSpecializationKind()))
+ InitFuncToUse = UnorderedInits.lookup(VD->getCanonicalDecl());
+ if (InitFuncToUse)
Init = llvm::GlobalAlias::create(Var->getLinkage(), InitFnName.str(),
- InitFunc);
+ InitFuncToUse);
} else {
// Emit a weak global function referring to the initialization function.
// This function will not exist if the TU defining the thread_local
// variable in question does not need any dynamic initialization for
// its thread_local variables.
llvm::FunctionType *FnTy = llvm::FunctionType::get(CGM.VoidTy, false);
- Init = llvm::Function::Create(
- FnTy, llvm::GlobalVariable::ExternalWeakLinkage, InitFnName.str(),
- &CGM.getModule());
+ Init = llvm::Function::Create(FnTy,
+ llvm::GlobalVariable::ExternalWeakLinkage,
+ InitFnName.str(), &CGM.getModule());
const CGFunctionInfo &FI = CGM.getTypes().arrangeNullaryFunction();
CGM.SetLLVMFunctionAttributes(nullptr, FI, cast<llvm::Function>(Init));
}
@@ -2341,7 +2362,6 @@ void ItaniumCXXABI::EmitThreadLocalInitFuncs(
if (Init)
Init->setVisibility(Var->getVisibility());
- llvm::Function *Wrapper = getOrCreateThreadLocalWrapper(VD, Var);
llvm::LLVMContext &Context = CGM.getModule().getContext();
llvm::BasicBlock *Entry = llvm::BasicBlock::Create(Context, "", Wrapper);
CGBuilderTy Builder(CGM, Entry);
diff --git a/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp b/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp
index 547e660ae09b..9bc9ae4f6a52 100644
--- a/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp
+++ b/contrib/llvm/tools/clang/lib/Driver/ToolChains.cpp
@@ -1531,7 +1531,7 @@ bool Generic_GCC::GCCInstallationDetector::getBiarchSibling(Multilib &M) const {
static const char *const AArch64LibDirs[] = {"/lib64", "/lib"};
static const char *const AArch64Triples[] = {
"aarch64-none-linux-gnu", "aarch64-linux-gnu", "aarch64-linux-android",
- "aarch64-redhat-linux"};
+ "aarch64-redhat-linux", "aarch64-suse-linux"};
static const char *const AArch64beLibDirs[] = {"/lib"};
static const char *const AArch64beTriples[] = {"aarch64_be-none-linux-gnu",
"aarch64_be-linux-gnu"};
diff --git a/contrib/llvm/tools/clang/lib/Driver/Tools.cpp b/contrib/llvm/tools/clang/lib/Driver/Tools.cpp
index e267cdb2649f..b4a83347defa 100644
--- a/contrib/llvm/tools/clang/lib/Driver/Tools.cpp
+++ b/contrib/llvm/tools/clang/lib/Driver/Tools.cpp
@@ -6431,11 +6431,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
A->claim();
// We translate this by hand to the -cc1 argument, since nightly test uses
- // it and developers have been trained to spell it with -mllvm.
- if (StringRef(A->getValue(0)) == "-disable-llvm-passes") {
- CmdArgs.push_back("-disable-llvm-passes");
- } else
+ // it and developers have been trained to spell it with -mllvm. Both
+ // spellings are now deprecated and should be removed.
+ if (StringRef(A->getValue(0)) == "-disable-llvm-optzns") {
+ CmdArgs.push_back("-disable-llvm-optzns");
+ } else {
A->render(Args, CmdArgs);
+ }
}
// With -save-temps, we want to save the unoptimized bitcode output from the
diff --git a/contrib/llvm/tools/clang/lib/Format/ContinuationIndenter.cpp b/contrib/llvm/tools/clang/lib/Format/ContinuationIndenter.cpp
index bf075ab6d53e..6bb6fb306035 100644
--- a/contrib/llvm/tools/clang/lib/Format/ContinuationIndenter.cpp
+++ b/contrib/llvm/tools/clang/lib/Format/ContinuationIndenter.cpp
@@ -1003,12 +1003,15 @@ void ContinuationIndenter::moveStatePastScopeOpener(LineState &State,
// Generally inherit NoLineBreak from the current scope to nested scope.
// However, don't do this for non-empty nested blocks, dict literals and
// array literals as these follow different indentation rules.
+ const FormatToken *Previous = Current.getPreviousNonComment();
bool NoLineBreak =
Current.Children.empty() &&
!Current.isOneOf(TT_DictLiteral, TT_ArrayInitializerLSquare) &&
(State.Stack.back().NoLineBreak ||
(Current.is(TT_TemplateOpener) &&
- State.Stack.back().ContainsUnwrappedBuilder));
+ State.Stack.back().ContainsUnwrappedBuilder) ||
+ (Current.is(tok::l_brace) && !Newline && Previous &&
+ Previous->is(tok::comma)));
State.Stack.push_back(ParenState(NewIndent, NewIndentLevel, LastSpace,
AvoidBinPacking, NoLineBreak));
State.Stack.back().NestedBlockIndent = NestedBlockIndent;
diff --git a/contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp b/contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp
index 17603ada11d1..4502c92499a7 100644
--- a/contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/contrib/llvm/tools/clang/lib/Frontend/InitPreprocessor.cpp
@@ -286,12 +286,12 @@ static void DefineFastIntType(unsigned TypeWidth, bool IsSigned,
/// Get the value the ATOMIC_*_LOCK_FREE macro should have for a type with
/// the specified properties.
-static const char *getLockFreeValue(unsigned TypeWidth, unsigned TypeAlign,
- unsigned InlineWidth) {
+static const char *getLockFreeValue(unsigned TypeWidth, unsigned InlineWidth) {
// Fully-aligned, power-of-2 sizes no larger than the inline
// width will be inlined as lock-free operations.
- if (TypeWidth == TypeAlign && (TypeWidth & (TypeWidth - 1)) == 0 &&
- TypeWidth <= InlineWidth)
+ // Note: we do not need to check alignment since _Atomic(T) is always
+ // appropriately-aligned in clang.
+ if ((TypeWidth & (TypeWidth - 1)) == 0 && TypeWidth <= InlineWidth)
return "2"; // "always lock free"
// We cannot be certain what operations the lib calls might be
// able to implement as lock-free on future processors.
@@ -881,7 +881,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
#define DEFINE_LOCK_FREE_MACRO(TYPE, Type) \
Builder.defineMacro("__GCC_ATOMIC_" #TYPE "_LOCK_FREE", \
getLockFreeValue(TI.get##Type##Width(), \
- TI.get##Type##Align(), \
InlineWidthBits));
DEFINE_LOCK_FREE_MACRO(BOOL, Bool);
DEFINE_LOCK_FREE_MACRO(CHAR, Char);
@@ -894,7 +893,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
DEFINE_LOCK_FREE_MACRO(LLONG, LongLong);
Builder.defineMacro("__GCC_ATOMIC_POINTER_LOCK_FREE",
getLockFreeValue(TI.getPointerWidth(0),
- TI.getPointerAlign(0),
InlineWidthBits));
#undef DEFINE_LOCK_FREE_MACRO
}
diff --git a/contrib/llvm/tools/clang/lib/Headers/altivec.h b/contrib/llvm/tools/clang/lib/Headers/altivec.h
index a8618816d5bb..a01d9d837ad1 100644
--- a/contrib/llvm/tools/clang/lib/Headers/altivec.h
+++ b/contrib/llvm/tools/clang/lib/Headers/altivec.h
@@ -7664,13 +7664,15 @@ vec_rlmi(vector unsigned long long __a, vector unsigned long long __b,
static __inline__ vector unsigned int __ATTRS_o_ai
vec_rlnm(vector unsigned int __a, vector unsigned int __b,
vector unsigned int __c) {
- return __builtin_altivec_vrlwnm(__a, __b) & __c;
+ vector unsigned int OneByte = { 0x8, 0x8, 0x8, 0x8 };
+ return __builtin_altivec_vrlwnm(__a, ((__c << OneByte) | __b));
}
static __inline__ vector unsigned long long __ATTRS_o_ai
vec_rlnm(vector unsigned long long __a, vector unsigned long long __b,
vector unsigned long long __c) {
- return __builtin_altivec_vrldnm(__a, __b) & __c;
+ vector unsigned long long OneByte = { 0x8, 0x8 };
+ return __builtin_altivec_vrldnm(__a, ((__c << OneByte) | __b));
}
#endif
diff --git a/contrib/llvm/tools/clang/lib/Index/IndexDecl.cpp b/contrib/llvm/tools/clang/lib/Index/IndexDecl.cpp
index 1225391dc2a6..7d60aad3895d 100644
--- a/contrib/llvm/tools/clang/lib/Index/IndexDecl.cpp
+++ b/contrib/llvm/tools/clang/lib/Index/IndexDecl.cpp
@@ -46,10 +46,13 @@ public:
}
void handleDeclarator(const DeclaratorDecl *D,
- const NamedDecl *Parent = nullptr) {
+ const NamedDecl *Parent = nullptr,
+ bool isIBType = false) {
if (!Parent) Parent = D;
- IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), Parent);
+ IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), Parent,
+ Parent->getLexicalDeclContext(),
+ /*isBase=*/false, isIBType);
IndexCtx.indexNestedNameSpecifierLoc(D->getQualifierLoc(), Parent);
if (IndexCtx.shouldIndexFunctionLocalSymbols()) {
// Only index parameters in definitions, parameters in declarations are
@@ -92,8 +95,11 @@ public:
if (!IndexCtx.handleDecl(D, (unsigned)SymbolRole::Dynamic, Relations))
return false;
IndexCtx.indexTypeSourceInfo(D->getReturnTypeSourceInfo(), D);
- for (const auto *I : D->parameters())
- handleDeclarator(I, D);
+ bool hasIBActionAndFirst = D->hasAttr<IBActionAttr>();
+ for (const auto *I : D->parameters()) {
+ handleDeclarator(I, D, /*isIBType=*/hasIBActionAndFirst);
+ hasIBActionAndFirst = false;
+ }
if (D->isThisDeclarationADefinition()) {
const Stmt *Body = D->getBody();
@@ -283,11 +289,12 @@ public:
bool VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
const ObjCInterfaceDecl *C = D->getClassInterface();
- if (C)
- TRY_TO(IndexCtx.handleReference(C, D->getLocation(), D, D,
- SymbolRoleSet(), SymbolRelation{
- (unsigned)SymbolRole::RelationExtendedBy, D
- }));
+ if (!C)
+ return true;
+ TRY_TO(IndexCtx.handleReference(C, D->getLocation(), D, D, SymbolRoleSet(),
+ SymbolRelation{
+ (unsigned)SymbolRole::RelationExtendedBy, D
+ }));
SourceLocation CategoryLoc = D->getCategoryNameLoc();
if (!CategoryLoc.isValid())
CategoryLoc = D->getLocation();
@@ -333,6 +340,9 @@ public:
handleObjCMethod(MD, D);
if (!IndexCtx.handleDecl(D))
return false;
+ if (IBOutletCollectionAttr *attr = D->getAttr<IBOutletCollectionAttr>())
+ IndexCtx.indexTypeSourceInfo(attr->getInterfaceLoc(), D,
+ D->getLexicalDeclContext(), false, true);
IndexCtx.indexTypeSourceInfo(D->getTypeSourceInfo(), D);
return true;
}
diff --git a/contrib/llvm/tools/clang/lib/Index/IndexSymbol.cpp b/contrib/llvm/tools/clang/lib/Index/IndexSymbol.cpp
index be847e762091..84984fce4dc7 100644
--- a/contrib/llvm/tools/clang/lib/Index/IndexSymbol.cpp
+++ b/contrib/llvm/tools/clang/lib/Index/IndexSymbol.cpp
@@ -152,10 +152,18 @@ SymbolInfo index::getSymbolInfo(const Decl *D) {
Info.Lang = SymbolLanguage::ObjC;
break;
case Decl::ObjCMethod:
- if (cast<ObjCMethodDecl>(D)->isInstanceMethod())
+ if (cast<ObjCMethodDecl>(D)->isInstanceMethod()) {
+ const ObjCMethodDecl *MD = cast<ObjCMethodDecl>(D);
Info.Kind = SymbolKind::InstanceMethod;
- else
+ if (MD->isPropertyAccessor()) {
+ if (MD->param_size())
+ Info.SubKind = SymbolSubKind::AccessorSetter;
+ else
+ Info.SubKind = SymbolSubKind::AccessorGetter;
+ }
+ } else {
Info.Kind = SymbolKind::ClassMethod;
+ }
Info.Lang = SymbolLanguage::ObjC;
if (isUnitTest(cast<ObjCMethodDecl>(D)))
Info.Properties |= (unsigned)SymbolProperty::UnitTest;
@@ -289,6 +297,8 @@ void index::applyForEachSymbolRole(SymbolRoleSet Roles,
APPLY_FOR_ROLE(RelationCalledBy);
APPLY_FOR_ROLE(RelationExtendedBy);
APPLY_FOR_ROLE(RelationAccessorOf);
+ APPLY_FOR_ROLE(RelationContainedBy);
+ APPLY_FOR_ROLE(RelationIBTypeOf);
#undef APPLY_FOR_ROLE
}
@@ -317,6 +327,8 @@ void index::printSymbolRoles(SymbolRoleSet Roles, raw_ostream &OS) {
case SymbolRole::RelationCalledBy: OS << "RelCall"; break;
case SymbolRole::RelationExtendedBy: OS << "RelExt"; break;
case SymbolRole::RelationAccessorOf: OS << "RelAcc"; break;
+ case SymbolRole::RelationContainedBy: OS << "RelCont"; break;
+ case SymbolRole::RelationIBTypeOf: OS << "RelIBType"; break;
}
});
}
@@ -375,6 +387,8 @@ StringRef index::getSymbolSubKindString(SymbolSubKind K) {
case SymbolSubKind::None: return "<none>";
case SymbolSubKind::CXXCopyConstructor: return "cxx-copy-ctor";
case SymbolSubKind::CXXMoveConstructor: return "cxx-move-ctor";
+ case SymbolSubKind::AccessorGetter: return "acc-get";
+ case SymbolSubKind::AccessorSetter: return "acc-set";
}
llvm_unreachable("invalid symbol subkind");
}
diff --git a/contrib/llvm/tools/clang/lib/Index/IndexTypeSourceInfo.cpp b/contrib/llvm/tools/clang/lib/Index/IndexTypeSourceInfo.cpp
index 619a9a48befd..38bbb30fedf1 100644
--- a/contrib/llvm/tools/clang/lib/Index/IndexTypeSourceInfo.cpp
+++ b/contrib/llvm/tools/clang/lib/Index/IndexTypeSourceInfo.cpp
@@ -26,12 +26,16 @@ class TypeIndexer : public RecursiveASTVisitor<TypeIndexer> {
public:
TypeIndexer(IndexingContext &indexCtx, const NamedDecl *parent,
- const DeclContext *DC, bool isBase)
+ const DeclContext *DC, bool isBase, bool isIBType)
: IndexCtx(indexCtx), Parent(parent), ParentDC(DC), IsBase(isBase) {
if (IsBase) {
assert(Parent);
Relations.emplace_back((unsigned)SymbolRole::RelationBaseOf, Parent);
}
+ if (isIBType) {
+ assert(Parent);
+ Relations.emplace_back((unsigned)SymbolRole::RelationIBTypeOf, Parent);
+ }
}
bool shouldWalkTypesOfTypeLocs() const { return false; }
@@ -93,13 +97,13 @@ public:
bool VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
return IndexCtx.handleReference(TL.getIFaceDecl(), TL.getNameLoc(),
- Parent, ParentDC, SymbolRoleSet());
+ Parent, ParentDC, SymbolRoleSet(), Relations);
}
bool VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i) {
IndexCtx.handleReference(TL.getProtocol(i), TL.getProtocolLoc(i),
- Parent, ParentDC, SymbolRoleSet());
+ Parent, ParentDC, SymbolRoleSet(), Relations);
}
return true;
}
@@ -130,23 +134,25 @@ public:
void IndexingContext::indexTypeSourceInfo(TypeSourceInfo *TInfo,
const NamedDecl *Parent,
const DeclContext *DC,
- bool isBase) {
+ bool isBase,
+ bool isIBType) {
if (!TInfo || TInfo->getTypeLoc().isNull())
return;
- indexTypeLoc(TInfo->getTypeLoc(), Parent, DC, isBase);
+ indexTypeLoc(TInfo->getTypeLoc(), Parent, DC, isBase, isIBType);
}
void IndexingContext::indexTypeLoc(TypeLoc TL,
const NamedDecl *Parent,
const DeclContext *DC,
- bool isBase) {
+ bool isBase,
+ bool isIBType) {
if (TL.isNull())
return;
if (!DC)
DC = Parent->getLexicalDeclContext();
- TypeIndexer(*this, Parent, DC, isBase).TraverseTypeLoc(TL);
+ TypeIndexer(*this, Parent, DC, isBase, isIBType).TraverseTypeLoc(TL);
}
void IndexingContext::indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
diff --git a/contrib/llvm/tools/clang/lib/Index/IndexingContext.cpp b/contrib/llvm/tools/clang/lib/Index/IndexingContext.cpp
index e623a495b47b..6dd6c0cfb28e 100644
--- a/contrib/llvm/tools/clang/lib/Index/IndexingContext.cpp
+++ b/contrib/llvm/tools/clang/lib/Index/IndexingContext.cpp
@@ -312,9 +312,20 @@ bool IndexingContext::handleDeclOccurrence(const Decl *D, SourceLocation Loc,
Roles |= Rel.Roles;
};
- if (!IsRef && Parent && !cast<DeclContext>(Parent)->isFunctionOrMethod()) {
- addRelation(SymbolRelation{(unsigned)SymbolRole::RelationChildOf, Parent});
+ if (Parent) {
+ if (IsRef) {
+ addRelation(SymbolRelation{
+ (unsigned)SymbolRole::RelationContainedBy,
+ Parent
+ });
+ } else if (!cast<DeclContext>(Parent)->isFunctionOrMethod()) {
+ addRelation(SymbolRelation{
+ (unsigned)SymbolRole::RelationChildOf,
+ Parent
+ });
+ }
}
+
for (auto &Rel : Relations) {
addRelation(SymbolRelation(Rel.Roles,
Rel.RelatedSymbol->getCanonicalDecl()));
diff --git a/contrib/llvm/tools/clang/lib/Index/IndexingContext.h b/contrib/llvm/tools/clang/lib/Index/IndexingContext.h
index 600fc433b58d..dd1dd328cd44 100644
--- a/contrib/llvm/tools/clang/lib/Index/IndexingContext.h
+++ b/contrib/llvm/tools/clang/lib/Index/IndexingContext.h
@@ -85,11 +85,13 @@ public:
void indexTypeSourceInfo(TypeSourceInfo *TInfo, const NamedDecl *Parent,
const DeclContext *DC = nullptr,
- bool isBase = false);
+ bool isBase = false,
+ bool isIBType = false);
void indexTypeLoc(TypeLoc TL, const NamedDecl *Parent,
const DeclContext *DC = nullptr,
- bool isBase = false);
+ bool isBase = false,
+ bool isIBType = false);
void indexNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
const NamedDecl *Parent,
diff --git a/contrib/llvm/tools/clang/lib/Lex/HeaderSearch.cpp b/contrib/llvm/tools/clang/lib/Lex/HeaderSearch.cpp
index fa2a76ef47ca..c667f4bf2207 100644
--- a/contrib/llvm/tools/clang/lib/Lex/HeaderSearch.cpp
+++ b/contrib/llvm/tools/clang/lib/Lex/HeaderSearch.cpp
@@ -1092,13 +1092,51 @@ void HeaderSearch::MarkFileModuleHeader(const FileEntry *FE,
}
bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor &PP,
- const FileEntry *File,
- bool isImport, Module *M) {
+ const FileEntry *File, bool isImport,
+ bool ModulesEnabled, Module *M) {
++NumIncluded; // Count # of attempted #includes.
// Get information about this file.
HeaderFileInfo &FileInfo = getFileInfo(File);
+ // FIXME: this is a workaround for the lack of proper modules-aware support
+ // for #import / #pragma once
+ auto TryEnterImported = [&](void) -> bool {
+ if (!ModulesEnabled)
+ return false;
+ // Modules with builtins are special; multiple modules use builtins as
+ // modular headers, example:
+ //
+ // module stddef { header "stddef.h" export * }
+ //
+ // After module map parsing, this expands to:
+ //
+ // module stddef {
+ // header "/path_to_builtin_dirs/stddef.h"
+ // textual "stddef.h"
+ // }
+ //
+ // It's common that libc++ and system modules will both define such
+ // submodules. Make sure cached results for a builtin header won't
+ // prevent other builtin modules to potentially enter the builtin header.
+ // Note that builtins are header guarded and the decision to actually
+ // enter them is postponed to the controlling macros logic below.
+ bool TryEnterHdr = false;
+ if (FileInfo.isCompilingModuleHeader && FileInfo.isModuleHeader)
+ TryEnterHdr = File->getDir() == ModMap.getBuiltinDir() &&
+ ModuleMap::isBuiltinHeader(
+ llvm::sys::path::filename(File->getName()));
+
+ // Textual headers can be #imported from different modules. Since ObjC
+ // headers find in the wild might rely only on #import and do not contain
+ // controlling macros, be conservative and only try to enter textual headers
+ // if such macro is present.
+ if (!FileInfo.isModuleHeader &&
+ FileInfo.getControllingMacro(ExternalLookup))
+ TryEnterHdr = true;
+ return TryEnterHdr;
+ };
+
// If this is a #import directive, check that we have not already imported
// this header.
if (isImport) {
@@ -1106,11 +1144,12 @@ bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor &PP,
FileInfo.isImport = true;
// Has this already been #import'ed or #include'd?
- if (FileInfo.NumIncludes) return false;
+ if (FileInfo.NumIncludes && !TryEnterImported())
+ return false;
} else {
// Otherwise, if this is a #include of a file that was previously #import'd
// or if this is the second #include of a #pragma once file, ignore it.
- if (FileInfo.isImport)
+ if (FileInfo.isImport && !TryEnterImported())
return false;
}
diff --git a/contrib/llvm/tools/clang/lib/Lex/ModuleMap.cpp b/contrib/llvm/tools/clang/lib/Lex/ModuleMap.cpp
index 9d0f2eb2fa79..1488f624da64 100644
--- a/contrib/llvm/tools/clang/lib/Lex/ModuleMap.cpp
+++ b/contrib/llvm/tools/clang/lib/Lex/ModuleMap.cpp
@@ -144,7 +144,7 @@ static StringRef sanitizeFilenameAsIdentifier(StringRef Name,
/// \brief Determine whether the given file name is the name of a builtin
/// header, supplied by Clang to replace, override, or augment existing system
/// headers.
-static bool isBuiltinHeader(StringRef FileName) {
+bool ModuleMap::isBuiltinHeader(StringRef FileName) {
return llvm::StringSwitch<bool>(FileName)
.Case("float.h", true)
.Case("iso646.h", true)
@@ -165,7 +165,7 @@ ModuleMap::findKnownHeader(const FileEntry *File) {
HeadersMap::iterator Known = Headers.find(File);
if (HeaderInfo.getHeaderSearchOpts().ImplicitModuleMaps &&
Known == Headers.end() && File->getDir() == BuiltinIncludeDir &&
- isBuiltinHeader(llvm::sys::path::filename(File->getName()))) {
+ ModuleMap::isBuiltinHeader(llvm::sys::path::filename(File->getName()))) {
HeaderInfo.loadTopLevelSystemModules();
return Headers.find(File);
}
@@ -446,9 +446,19 @@ ModuleMap::isHeaderUnavailableInModule(const FileEntry *Header,
I = Known->second.begin(),
E = Known->second.end();
I != E; ++I) {
- if (I->isAvailable() && (!RequestingModule ||
- I->getModule()->isSubModuleOf(RequestingModule)))
+
+ if (I->isAvailable() &&
+ (!RequestingModule ||
+ I->getModule()->isSubModuleOf(RequestingModule))) {
+ // When no requesting module is available, the caller is looking if a
+ // header is part a module by only looking into the module map. This is
+ // done by warn_uncovered_module_header checks; don't consider textual
+ // headers part of it in this mode, otherwise we get misleading warnings
+ // that a umbrella header is not including a textual header.
+ if (!RequestingModule && I->getRole() == ModuleMap::TextualHeader)
+ continue;
return false;
+ }
}
return true;
}
@@ -1879,7 +1889,7 @@ void ModuleMapParser::parseHeaderDecl(MMToken::TokenKind LeadingToken,
// supplied by Clang. Find that builtin header.
if (ActiveModule->IsSystem && LeadingToken != MMToken::UmbrellaKeyword &&
BuiltinIncludeDir && BuiltinIncludeDir != Directory &&
- isBuiltinHeader(Header.FileName)) {
+ ModuleMap::isBuiltinHeader(Header.FileName)) {
SmallString<128> BuiltinPathName(BuiltinIncludeDir->getName());
llvm::sys::path::append(BuiltinPathName, Header.FileName);
BuiltinFile = SourceMgr.getFileManager().getFile(BuiltinPathName);
diff --git a/contrib/llvm/tools/clang/lib/Lex/PPDirectives.cpp b/contrib/llvm/tools/clang/lib/Lex/PPDirectives.cpp
index 9661e7b13f72..322c5809cd2c 100644
--- a/contrib/llvm/tools/clang/lib/Lex/PPDirectives.cpp
+++ b/contrib/llvm/tools/clang/lib/Lex/PPDirectives.cpp
@@ -1999,6 +1999,7 @@ void Preprocessor::HandleIncludeDirective(SourceLocation HashLoc,
bool SkipHeader = false;
if (ShouldEnter &&
!HeaderInfo.ShouldEnterIncludeFile(*this, File, isImport,
+ getLangOpts().Modules,
SuggestedModule.getModule())) {
ShouldEnter = false;
SkipHeader = true;
diff --git a/contrib/llvm/tools/clang/lib/Parse/ParseDecl.cpp b/contrib/llvm/tools/clang/lib/Parse/ParseDecl.cpp
index 833d93e4548a..2d320878014b 100644
--- a/contrib/llvm/tools/clang/lib/Parse/ParseDecl.cpp
+++ b/contrib/llvm/tools/clang/lib/Parse/ParseDecl.cpp
@@ -1591,7 +1591,7 @@ Parser::ParseSimpleDeclaration(unsigned Context,
DS.complete(TheDecl);
if (AnonRecord) {
Decl* decls[] = {AnonRecord, TheDecl};
- return Actions.BuildDeclaratorGroup(decls, /*TypeMayContainAuto=*/false);
+ return Actions.BuildDeclaratorGroup(decls);
}
return Actions.ConvertDeclToDeclGroup(TheDecl);
}
@@ -2045,8 +2045,6 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
}
}
- bool TypeContainsAuto = D.getDeclSpec().containsPlaceholderType();
-
// Parse declarator '=' initializer.
// If a '==' or '+=' is found, suggest a fixit to '='.
if (isTokenEqualOrEqualTypo()) {
@@ -2106,7 +2104,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
Actions.ActOnInitializerError(ThisDecl);
} else
Actions.AddInitializerToDecl(ThisDecl, Init.get(),
- /*DirectInit=*/false, TypeContainsAuto);
+ /*DirectInit=*/false);
}
} else if (Tok.is(tok::l_paren)) {
// Parse C++ direct initializer: '(' expression-list ')'
@@ -2149,7 +2147,7 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
T.getCloseLocation(),
Exprs);
Actions.AddInitializerToDecl(ThisDecl, Initializer.get(),
- /*DirectInit=*/true, TypeContainsAuto);
+ /*DirectInit=*/true);
}
} else if (getLangOpts().CPlusPlus11 && Tok.is(tok::l_brace) &&
(!CurParsedObjCImpl || !D.isFunctionDeclarator())) {
@@ -2171,11 +2169,10 @@ Decl *Parser::ParseDeclarationAfterDeclaratorAndAttributes(
if (Init.isInvalid()) {
Actions.ActOnInitializerError(ThisDecl);
} else
- Actions.AddInitializerToDecl(ThisDecl, Init.get(),
- /*DirectInit=*/true, TypeContainsAuto);
+ Actions.AddInitializerToDecl(ThisDecl, Init.get(), /*DirectInit=*/true);
} else {
- Actions.ActOnUninitializedDecl(ThisDecl, TypeContainsAuto);
+ Actions.ActOnUninitializedDecl(ThisDecl);
}
Actions.FinalizeDeclaration(ThisDecl);
diff --git a/contrib/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp b/contrib/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp
index 4002b09d2bc4..3f1fe7e06fe3 100644
--- a/contrib/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/contrib/llvm/tools/clang/lib/Parse/ParseDeclCXX.cpp
@@ -710,7 +710,7 @@ Parser::ParseUsingDeclaration(unsigned Context,
: "using declaration"))
SkipUntil(tok::semi);
- return Actions.BuildDeclaratorGroup(DeclsInGroup, /*MayContainAuto*/false);
+ return Actions.BuildDeclaratorGroup(DeclsInGroup);
}
Decl *Parser::ParseAliasDeclarationAfterDeclarator(
@@ -2539,7 +2539,7 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
DS.complete(TheDecl);
if (AnonRecord) {
Decl* decls[] = {AnonRecord, TheDecl};
- return Actions.BuildDeclaratorGroup(decls, /*TypeMayContainAuto=*/false);
+ return Actions.BuildDeclaratorGroup(decls);
}
return Actions.ConvertDeclToDeclGroup(TheDecl);
}
@@ -2769,11 +2769,10 @@ Parser::ParseCXXClassMemberDeclaration(AccessSpecifier AS,
if (Init.isInvalid())
SkipUntil(tok::comma, StopAtSemi | StopBeforeMatch);
else if (ThisDecl)
- Actions.AddInitializerToDecl(ThisDecl, Init.get(), EqualLoc.isInvalid(),
- DS.containsPlaceholderType());
+ Actions.AddInitializerToDecl(ThisDecl, Init.get(), EqualLoc.isInvalid());
} else if (ThisDecl && DS.getStorageClassSpec() == DeclSpec::SCS_static)
// No initializer.
- Actions.ActOnUninitializedDecl(ThisDecl, DS.containsPlaceholderType());
+ Actions.ActOnUninitializedDecl(ThisDecl);
if (ThisDecl) {
if (!ThisDecl->isInvalidDecl()) {
@@ -3545,7 +3544,7 @@ Parser::tryParseExceptionSpecification(bool Delayed,
Actions.CheckBooleanCondition(KeywordLoc, NoexceptExpr.get());
NoexceptRange = SourceRange(KeywordLoc, T.getCloseLocation());
} else {
- NoexceptType = EST_None;
+ NoexceptType = EST_BasicNoexcept;
}
} else {
// There is no argument.
diff --git a/contrib/llvm/tools/clang/lib/Parse/ParseExpr.cpp b/contrib/llvm/tools/clang/lib/Parse/ParseExpr.cpp
index 55b5ff498574..e7b6c6ff90b3 100644
--- a/contrib/llvm/tools/clang/lib/Parse/ParseExpr.cpp
+++ b/contrib/llvm/tools/clang/lib/Parse/ParseExpr.cpp
@@ -198,7 +198,7 @@ ExprResult Parser::ParseConstantExpression(TypeCastState isTypeCast) {
// An expression is potentially evaluated unless it appears where an
// integral constant expression is required (see 5.19) [...].
// C++98 and C++11 have no such rule, but this is only a defect in C++98.
- EnterExpressionEvaluationContext Unevaluated(Actions,
+ EnterExpressionEvaluationContext ConstantEvaluated(Actions,
Sema::ConstantEvaluated);
ExprResult LHS(ParseCastExpression(false, false, isTypeCast));
diff --git a/contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp b/contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp
index ca1b3b1ad01b..124266a42bd5 100644
--- a/contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp
+++ b/contrib/llvm/tools/clang/lib/Parse/ParseExprCXX.cpp
@@ -735,7 +735,7 @@ ExprResult Parser::TryParseLambdaExpression() {
/// sometimes skip the initializers for init-captures and not fully
/// populate \p Intro. This flag will be set to \c true if we do so.
/// \return A DiagnosticID if it hit something unexpected. The location for
-/// for the diagnostic is that of the current token.
+/// the diagnostic is that of the current token.
Optional<unsigned> Parser::ParseLambdaIntroducer(LambdaIntroducer &Intro,
bool *SkippedInits) {
typedef Optional<unsigned> DiagResult;
@@ -1818,8 +1818,7 @@ Sema::ConditionResult Parser::ParseCXXCondition(StmtResult *InitStmt,
}
if (!InitExpr.isInvalid())
- Actions.AddInitializerToDecl(DeclOut, InitExpr.get(), !CopyInitialization,
- DS.containsPlaceholderType());
+ Actions.AddInitializerToDecl(DeclOut, InitExpr.get(), !CopyInitialization);
else
Actions.ActOnInitializerError(DeclOut);
diff --git a/contrib/llvm/tools/clang/lib/Parse/ParseOpenMP.cpp b/contrib/llvm/tools/clang/lib/Parse/ParseOpenMP.cpp
index f9ea8af00f50..cab7d3432db3 100644
--- a/contrib/llvm/tools/clang/lib/Parse/ParseOpenMP.cpp
+++ b/contrib/llvm/tools/clang/lib/Parse/ParseOpenMP.cpp
@@ -119,6 +119,7 @@ static OpenMPDirectiveKind ParseOpenMPDirectiveKind(Parser &P) {
{ OMPD_target, OMPD_teams, OMPD_target_teams },
{ OMPD_target_teams, OMPD_distribute, OMPD_target_teams_distribute },
{ OMPD_target_teams_distribute, OMPD_parallel, OMPD_target_teams_distribute_parallel },
+ { OMPD_target_teams_distribute, OMPD_simd, OMPD_target_teams_distribute_simd },
{ OMPD_target_teams_distribute_parallel, OMPD_for, OMPD_target_teams_distribute_parallel_for },
{ OMPD_target_teams_distribute_parallel_for, OMPD_simd, OMPD_target_teams_distribute_parallel_for_simd }
};
@@ -760,6 +761,7 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
case OMPD_target_teams_distribute:
case OMPD_target_teams_distribute_parallel_for:
case OMPD_target_teams_distribute_parallel_for_simd:
+ case OMPD_target_teams_distribute_simd:
Diag(Tok, diag::err_omp_unexpected_directive)
<< getOpenMPDirectiveName(DKind);
break;
@@ -799,7 +801,8 @@ Parser::DeclGroupPtrTy Parser::ParseOpenMPDeclarativeDirectiveWithExtDecl(
/// 'teams distribute parallel for' | 'target teams' |
/// 'target teams distribute' |
/// 'target teams distribute parallel for' |
-/// 'target teams distribute parallel for simd' {clause}
+/// 'target teams distribute parallel for simd' |
+/// 'target teams distribute simd' {clause}
/// annot_pragma_openmp_end
///
StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
@@ -916,7 +919,8 @@ StmtResult Parser::ParseOpenMPDeclarativeOrExecutableDirective(
case OMPD_target_teams:
case OMPD_target_teams_distribute:
case OMPD_target_teams_distribute_parallel_for:
- case OMPD_target_teams_distribute_parallel_for_simd: {
+ case OMPD_target_teams_distribute_parallel_for_simd:
+ case OMPD_target_teams_distribute_simd: {
ConsumeToken();
// Parse directive name of the 'critical' directive if any.
if (DKind == OMPD_critical) {
diff --git a/contrib/llvm/tools/clang/lib/Parse/Parser.cpp b/contrib/llvm/tools/clang/lib/Parse/Parser.cpp
index d8a4ea63153a..52e5194e6236 100644
--- a/contrib/llvm/tools/clang/lib/Parse/Parser.cpp
+++ b/contrib/llvm/tools/clang/lib/Parse/Parser.cpp
@@ -938,7 +938,7 @@ Parser::ParseDeclOrFunctionDefInternal(ParsedAttributesWithRange &attrs,
Actions.setCurrentOpenCLExtensionForDecl(TheDecl);
if (AnonRecord) {
Decl* decls[] = {AnonRecord, TheDecl};
- return Actions.BuildDeclaratorGroup(decls, /*TypeMayContainAuto=*/false);
+ return Actions.BuildDeclaratorGroup(decls);
}
return Actions.ConvertDeclToDeclGroup(TheDecl);
}
@@ -1472,8 +1472,7 @@ Parser::TryAnnotateName(bool IsAddressOfOperand,
return ANK_Error;
if (Tok.isNot(tok::identifier) || SS.isInvalid()) {
- if (TryAnnotateTypeOrScopeTokenAfterScopeSpec(EnteringContext, false, SS,
- !WasScopeAnnotation))
+ if (TryAnnotateTypeOrScopeTokenAfterScopeSpec(SS, !WasScopeAnnotation))
return ANK_Error;
return ANK_Unresolved;
}
@@ -1486,8 +1485,7 @@ Parser::TryAnnotateName(bool IsAddressOfOperand,
if (isTentativelyDeclared(Name)) {
// Identifier has been tentatively declared, and thus cannot be resolved as
// an expression. Fall back to annotating it as a type.
- if (TryAnnotateTypeOrScopeTokenAfterScopeSpec(EnteringContext, false, SS,
- !WasScopeAnnotation))
+ if (TryAnnotateTypeOrScopeTokenAfterScopeSpec(SS, !WasScopeAnnotation))
return ANK_Error;
return Tok.is(tok::annot_typename) ? ANK_Success : ANK_TentativeDecl;
}
@@ -1625,7 +1623,7 @@ bool Parser::TryKeywordIdentFallback(bool DisableKeyword) {
///
/// Note that this routine emits an error if you call it with ::new or ::delete
/// as the current tokens, so only call it in contexts where these are invalid.
-bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext, bool NeedType) {
+bool Parser::TryAnnotateTypeOrScopeToken() {
assert((Tok.is(tok::identifier) || Tok.is(tok::coloncolon) ||
Tok.is(tok::kw_typename) || Tok.is(tok::annot_cxxscope) ||
Tok.is(tok::kw_decltype) || Tok.is(tok::annot_template_id) ||
@@ -1642,7 +1640,7 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext, bool NeedType) {
if (getLangOpts().MSVCCompat && NextToken().is(tok::kw_typedef)) {
Token TypedefToken;
PP.Lex(TypedefToken);
- bool Result = TryAnnotateTypeOrScopeToken(EnteringContext, NeedType);
+ bool Result = TryAnnotateTypeOrScopeToken();
PP.EnterToken(Tok);
Tok = TypedefToken;
if (!Result)
@@ -1667,8 +1665,7 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext, bool NeedType) {
Tok.is(tok::annot_decltype)) {
// Attempt to recover by skipping the invalid 'typename'
if (Tok.is(tok::annot_decltype) ||
- (!TryAnnotateTypeOrScopeToken(EnteringContext, NeedType) &&
- Tok.isAnnotation())) {
+ (!TryAnnotateTypeOrScopeToken() && Tok.isAnnotation())) {
unsigned DiagID = diag::err_expected_qualified_after_typename;
// MS compatibility: MSVC permits using known types with typename.
// e.g. "typedef typename T* pointer_type"
@@ -1728,33 +1725,24 @@ bool Parser::TryAnnotateTypeOrScopeToken(bool EnteringContext, bool NeedType) {
CXXScopeSpec SS;
if (getLangOpts().CPlusPlus)
- if (ParseOptionalCXXScopeSpecifier(SS, nullptr, EnteringContext))
+ if (ParseOptionalCXXScopeSpecifier(SS, nullptr, /*EnteringContext*/false))
return true;
- return TryAnnotateTypeOrScopeTokenAfterScopeSpec(EnteringContext, NeedType,
- SS, !WasScopeAnnotation);
+ return TryAnnotateTypeOrScopeTokenAfterScopeSpec(SS, !WasScopeAnnotation);
}
/// \brief Try to annotate a type or scope token, having already parsed an
/// optional scope specifier. \p IsNewScope should be \c true unless the scope
/// specifier was extracted from an existing tok::annot_cxxscope annotation.
-bool Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(bool EnteringContext,
- bool NeedType,
- CXXScopeSpec &SS,
+bool Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(CXXScopeSpec &SS,
bool IsNewScope) {
if (Tok.is(tok::identifier)) {
- IdentifierInfo *CorrectedII = nullptr;
// Determine whether the identifier is a type name.
if (ParsedType Ty = Actions.getTypeName(
*Tok.getIdentifierInfo(), Tok.getLocation(), getCurScope(), &SS,
false, NextToken().is(tok::period), nullptr,
/*IsCtorOrDtorName=*/false,
- /*NonTrivialTypeSourceInfo*/ true,
- NeedType ? &CorrectedII : nullptr)) {
- // A FixIt was applied as a result of typo correction
- if (CorrectedII)
- Tok.setIdentifierInfo(CorrectedII);
-
+ /*NonTrivialTypeSourceInfo*/ true)) {
SourceLocation BeginLoc = Tok.getLocation();
if (SS.isNotEmpty()) // it was a C++ qualified type name.
BeginLoc = SS.getBeginLoc();
@@ -1803,11 +1791,11 @@ bool Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(bool EnteringContext,
UnqualifiedId TemplateName;
TemplateName.setIdentifier(Tok.getIdentifierInfo(), Tok.getLocation());
bool MemberOfUnknownSpecialization;
- if (TemplateNameKind TNK =
- Actions.isTemplateName(getCurScope(), SS,
- /*hasTemplateKeyword=*/false, TemplateName,
- /*ObjectType=*/nullptr, EnteringContext,
- Template, MemberOfUnknownSpecialization)) {
+ if (TemplateNameKind TNK = Actions.isTemplateName(
+ getCurScope(), SS,
+ /*hasTemplateKeyword=*/false, TemplateName,
+ /*ObjectType=*/nullptr, /*EnteringContext*/false, Template,
+ MemberOfUnknownSpecialization)) {
// Consume the identifier.
ConsumeToken();
if (AnnotateTemplateIdToken(Template, TNK, SS, SourceLocation(),
diff --git a/contrib/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp b/contrib/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 5953d020b4fb..a987a8ce0b31 100644
--- a/contrib/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -56,6 +56,8 @@ using namespace clang;
namespace {
class UnreachableCodeHandler : public reachable_code::Callback {
Sema &S;
+ SourceRange PreviousSilenceableCondVal;
+
public:
UnreachableCodeHandler(Sema &s) : S(s) {}
@@ -64,6 +66,14 @@ namespace {
SourceRange SilenceableCondVal,
SourceRange R1,
SourceRange R2) override {
+ // Avoid reporting multiple unreachable code diagnostics that are
+ // triggered by the same conditional value.
+ if (PreviousSilenceableCondVal.isValid() &&
+ SilenceableCondVal.isValid() &&
+ PreviousSilenceableCondVal == SilenceableCondVal)
+ return;
+ PreviousSilenceableCondVal = SilenceableCondVal;
+
unsigned diag = diag::warn_unreachable;
switch (UK) {
case reachable_code::UK_Break:
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaCoroutine.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaCoroutine.cpp
index 3109358df464..9814b4a84f29 100644
--- a/contrib/llvm/tools/clang/lib/Sema/SemaCoroutine.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/SemaCoroutine.cpp
@@ -187,7 +187,7 @@ static FunctionScopeInfo *checkCoroutineContext(Sema &S, SourceLocation Loc,
S.Context.getTrivialTypeSourceInfo(T, Loc), SC_None);
S.CheckVariableDeclarationType(ScopeInfo->CoroutinePromise);
if (!ScopeInfo->CoroutinePromise->isInvalidDecl())
- S.ActOnUninitializedDecl(ScopeInfo->CoroutinePromise, false);
+ S.ActOnUninitializedDecl(ScopeInfo->CoroutinePromise);
}
return ScopeInfo;
@@ -578,17 +578,6 @@ void Sema::CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body) {
isa<CoyieldExpr>(First) ? 1 : 2);
}
- bool AnyCoawaits = false;
- bool AnyCoyields = false;
- for (auto *CoroutineStmt : Fn->CoroutineStmts) {
- AnyCoawaits |= isa<CoawaitExpr>(CoroutineStmt);
- AnyCoyields |= isa<CoyieldExpr>(CoroutineStmt);
- }
-
- if (!AnyCoawaits && !AnyCoyields)
- Diag(Fn->CoroutineStmts.front()->getLocStart(),
- diag::ext_coroutine_without_co_await_co_yield);
-
SourceLocation Loc = FD->getLocation();
// Form a declaration statement for the promise declaration, so that AST
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp
index c32757565dd1..adcf2ee00e75 100644
--- a/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp
@@ -1044,7 +1044,8 @@ Corrected:
}
// We can have a type template here if we're classifying a template argument.
- if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl))
+ if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl) &&
+ !isa<VarTemplateDecl>(FirstDecl))
return NameClassification::TypeTemplate(
TemplateName(cast<TemplateDecl>(FirstDecl)));
@@ -4503,7 +4504,7 @@ Decl *Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS,
// trivial in almost all cases, except if a union member has an in-class
// initializer:
// union { int n = 0; };
- ActOnUninitializedDecl(Anon, /*TypeMayContainAuto=*/false);
+ ActOnUninitializedDecl(Anon);
}
Anon->setImplicit();
@@ -6425,9 +6426,10 @@ NamedDecl *Sema::ActOnVariableDeclarator(
}
}
- // Diagnose shadowed variables before filtering for scope.
- if (D.getCXXScopeSpec().isEmpty())
- CheckShadow(S, NewVD, Previous);
+ // Find the shadowed declaration before filtering for scope.
+ NamedDecl *ShadowedDecl = D.getCXXScopeSpec().isEmpty()
+ ? getShadowedDeclaration(NewVD, Previous)
+ : nullptr;
// Don't consider existing declarations that are in a different
// scope and are out-of-semantic-context declarations (if the new
@@ -6522,6 +6524,10 @@ NamedDecl *Sema::ActOnVariableDeclarator(
}
}
+ // Diagnose shadowed variables iff this isn't a redeclaration.
+ if (ShadowedDecl && !D.isRedeclaration())
+ CheckShadow(NewVD, ShadowedDecl, Previous);
+
ProcessPragmaWeak(S, NewVD);
// If this is the first declaration of an extern C variable, update
@@ -6595,33 +6601,40 @@ static SourceLocation getCaptureLocation(const LambdaScopeInfo *LSI,
return SourceLocation();
}
-/// \brief Diagnose variable or built-in function shadowing. Implements
-/// -Wshadow.
-///
-/// This method is called whenever a VarDecl is added to a "useful"
-/// scope.
-///
-/// \param S the scope in which the shadowing name is being declared
-/// \param R the lookup of the name
-///
-void Sema::CheckShadow(Scope *S, VarDecl *D, const LookupResult& R) {
+/// \brief Return the declaration shadowed by the given variable \p D, or null
+/// if it doesn't shadow any declaration or shadowing warnings are disabled.
+NamedDecl *Sema::getShadowedDeclaration(const VarDecl *D,
+ const LookupResult &R) {
// Return if warning is ignored.
if (Diags.isIgnored(diag::warn_decl_shadow, R.getNameLoc()))
- return;
+ return nullptr;
// Don't diagnose declarations at file scope.
if (D->hasGlobalStorage())
- return;
-
- DeclContext *NewDC = D->getDeclContext();
+ return nullptr;
// Only diagnose if we're shadowing an unambiguous field or variable.
if (R.getResultKind() != LookupResult::Found)
- return;
+ return nullptr;
- NamedDecl* ShadowedDecl = R.getFoundDecl();
- if (!isa<VarDecl>(ShadowedDecl) && !isa<FieldDecl>(ShadowedDecl))
- return;
+ NamedDecl *ShadowedDecl = R.getFoundDecl();
+ return isa<VarDecl>(ShadowedDecl) || isa<FieldDecl>(ShadowedDecl)
+ ? ShadowedDecl
+ : nullptr;
+}
+
+/// \brief Diagnose variable or built-in function shadowing. Implements
+/// -Wshadow.
+///
+/// This method is called whenever a VarDecl is added to a "useful"
+/// scope.
+///
+/// \param ShadowedDecl the declaration that is shadowed by the given variable
+/// \param R the lookup of the name
+///
+void Sema::CheckShadow(VarDecl *D, NamedDecl *ShadowedDecl,
+ const LookupResult &R) {
+ DeclContext *NewDC = D->getDeclContext();
if (FieldDecl *FD = dyn_cast<FieldDecl>(ShadowedDecl)) {
// Fields are not shadowed by variables in C++ static methods.
@@ -6732,7 +6745,8 @@ void Sema::CheckShadow(Scope *S, VarDecl *D) {
LookupResult R(*this, D->getDeclName(), D->getLocation(),
Sema::LookupOrdinaryName, Sema::ForRedeclaration);
LookupName(R, S);
- CheckShadow(S, D, R);
+ if (NamedDecl *ShadowedDecl = getShadowedDeclaration(D, R))
+ CheckShadow(D, ShadowedDecl, R);
}
/// Check if 'E', which is an expression that is about to be modified, refers
@@ -9782,8 +9796,7 @@ QualType Sema::deduceVarTypeFromInitializer(VarDecl *VDecl,
/// AddInitializerToDecl - Adds the initializer Init to the
/// declaration dcl. If DirectInit is true, this is C++ direct
/// initialization rather than copy initialization.
-void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
- bool DirectInit, bool TypeMayContainAuto) {
+void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init, bool DirectInit) {
// If there is no declaration, there was an error parsing it. Just ignore
// the initializer.
if (!RealDecl || RealDecl->isInvalidDecl()) {
@@ -9808,7 +9821,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr *Init,
}
// C++11 [decl.spec.auto]p6. Deduce the type which 'auto' stands in for.
- if (TypeMayContainAuto && VDecl->getType()->isUndeducedType()) {
+ if (VDecl->getType()->isUndeducedType()) {
// Attempt typo correction early so that the type of the init expression can
// be deduced based on the chosen correction if the original init contains a
// TypoExpr.
@@ -10280,8 +10293,7 @@ bool Sema::canInitializeWithParenthesizedList(QualType TargetType) {
TargetType->getContainedAutoType();
}
-void Sema::ActOnUninitializedDecl(Decl *RealDecl,
- bool TypeMayContainAuto) {
+void Sema::ActOnUninitializedDecl(Decl *RealDecl) {
// If there is no declaration, there was an error parsing it. Just ignore it.
if (!RealDecl)
return;
@@ -10297,7 +10309,7 @@ void Sema::ActOnUninitializedDecl(Decl *RealDecl,
}
// C++11 [dcl.spec.auto]p3
- if (TypeMayContainAuto && Type->getContainedAutoType()) {
+ if (Type->isUndeducedType()) {
Diag(Var->getLocation(), diag::err_auto_var_requires_init)
<< Var->getDeclName() << Type;
Var->setInvalidDecl();
@@ -11081,32 +11093,32 @@ Sema::DeclGroupPtrTy Sema::FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS,
}
}
- return BuildDeclaratorGroup(Decls, DS.containsPlaceholderType());
+ return BuildDeclaratorGroup(Decls);
}
/// BuildDeclaratorGroup - convert a list of declarations into a declaration
/// group, performing any necessary semantic checking.
Sema::DeclGroupPtrTy
-Sema::BuildDeclaratorGroup(MutableArrayRef<Decl *> Group,
- bool TypeMayContainAuto) {
- // C++0x [dcl.spec.auto]p7:
- // If the type deduced for the template parameter U is not the same in each
+Sema::BuildDeclaratorGroup(MutableArrayRef<Decl *> Group) {
+ // C++14 [dcl.spec.auto]p7: (DR1347)
+ // If the type that replaces the placeholder type is not the same in each
// deduction, the program is ill-formed.
- // FIXME: When initializer-list support is added, a distinction is needed
- // between the deduced type U and the deduced type which 'auto' stands for.
- // auto a = 0, b = { 1, 2, 3 };
- // is legal because the deduced type U is 'int' in both cases.
- if (TypeMayContainAuto && Group.size() > 1) {
+ if (Group.size() > 1) {
QualType Deduced;
CanQualType DeducedCanon;
VarDecl *DeducedDecl = nullptr;
for (unsigned i = 0, e = Group.size(); i != e; ++i) {
if (VarDecl *D = dyn_cast<VarDecl>(Group[i])) {
AutoType *AT = D->getType()->getContainedAutoType();
+ // FIXME: DR1265: if we have a function pointer declaration, we can have
+ // an 'auto' from a trailing return type. In that case, the return type
+ // must match the various other uses of 'auto'.
+ if (!AT)
+ continue;
// Don't reissue diagnostics when instantiating a template.
- if (AT && D->isInvalidDecl())
+ if (D->isInvalidDecl())
break;
- QualType U = AT ? AT->getDeducedType() : QualType();
+ QualType U = AT->getDeducedType();
if (!U.isNull()) {
CanQualType UCanon = Context.getCanonicalType(U);
if (Deduced.isNull()) {
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaDeclObjC.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaDeclObjC.cpp
index d172c951e749..b43e5b9e3278 100644
--- a/contrib/llvm/tools/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/SemaDeclObjC.cpp
@@ -1712,7 +1712,7 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc,
DeclsInGroup.push_back(PDecl);
}
- return BuildDeclaratorGroup(DeclsInGroup, false);
+ return BuildDeclaratorGroup(DeclsInGroup);
}
Decl *Sema::
@@ -2019,7 +2019,7 @@ Sema::ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef<Decl *> Decls) {
DeclsInGroup.push_back(ObjCImpDecl);
- return BuildDeclaratorGroup(DeclsInGroup, false);
+ return BuildDeclaratorGroup(DeclsInGroup);
}
void Sema::CheckImplementationIvars(ObjCImplementationDecl *ImpDecl,
@@ -3043,7 +3043,7 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc,
DeclsInGroup.push_back(IDecl);
}
- return BuildDeclaratorGroup(DeclsInGroup, false);
+ return BuildDeclaratorGroup(DeclsInGroup);
}
static bool tryMatchRecordTypes(ASTContext &Context,
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp
index 1379440e8a03..b2fb33f53432 100644
--- a/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp
@@ -1504,14 +1504,12 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
SourceLocation PlacementLParen, MultiExprArg PlacementArgs,
SourceLocation PlacementRParen, SourceRange TypeIdParens,
Declarator &D, Expr *Initializer) {
- bool TypeContainsAuto = D.getDeclSpec().containsPlaceholderType();
-
Expr *ArraySize = nullptr;
// If the specified type is an array, unwrap it and save the expression.
if (D.getNumTypeObjects() > 0 &&
D.getTypeObject(0).Kind == DeclaratorChunk::Array) {
- DeclaratorChunk &Chunk = D.getTypeObject(0);
- if (TypeContainsAuto)
+ DeclaratorChunk &Chunk = D.getTypeObject(0);
+ if (D.getDeclSpec().containsPlaceholderType())
return ExprError(Diag(Chunk.Loc, diag::err_new_array_of_auto)
<< D.getSourceRange());
if (Chunk.Arr.hasStatic)
@@ -1588,8 +1586,7 @@ Sema::ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal,
TInfo,
ArraySize,
DirectInitRange,
- Initializer,
- TypeContainsAuto);
+ Initializer);
}
static bool isLegalArrayNewInitializer(CXXNewExpr::InitializationStyle Style,
@@ -1621,8 +1618,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
TypeSourceInfo *AllocTypeInfo,
Expr *ArraySize,
SourceRange DirectInitRange,
- Expr *Initializer,
- bool TypeMayContainAuto) {
+ Expr *Initializer) {
SourceRange TypeRange = AllocTypeInfo->getTypeLoc().getSourceRange();
SourceLocation StartLoc = Range.getBegin();
@@ -1648,7 +1644,7 @@ Sema::BuildCXXNew(SourceRange Range, bool UseGlobal,
}
// C++11 [dcl.spec.auto]p6. Deduce the type which 'auto' stands in for.
- if (TypeMayContainAuto && AllocType->isUndeducedType()) {
+ if (AllocType->isUndeducedType()) {
if (initStyle == CXXNewExpr::NoInit || NumInits == 0)
return ExprError(Diag(StartLoc, diag::err_auto_new_requires_ctor_arg)
<< AllocType << TypeRange);
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaOpenMP.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaOpenMP.cpp
index edceb537df75..dcd19c8d817d 100644
--- a/contrib/llvm/tools/clang/lib/Sema/SemaOpenMP.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/SemaOpenMP.cpp
@@ -1089,7 +1089,7 @@ void Sema::EndOpenMPDSABlock(Stmt *CurDirective) {
auto *VDPrivate = buildVarDecl(
*this, DE->getExprLoc(), Type.getUnqualifiedType(),
VD->getName(), VD->hasAttrs() ? &VD->getAttrs() : nullptr);
- ActOnUninitializedDecl(VDPrivate, /*TypeMayContainAuto=*/false);
+ ActOnUninitializedDecl(VDPrivate);
if (VDPrivate->isInvalidDecl())
continue;
PrivateCopies.push_back(buildDeclRefExpr(
@@ -1701,7 +1701,8 @@ void Sema::ActOnOpenMPRegionStart(OpenMPDirectiveKind DKind, Scope *CurScope) {
case OMPD_teams_distribute_parallel_for:
case OMPD_target_teams_distribute:
case OMPD_target_teams_distribute_parallel_for:
- case OMPD_target_teams_distribute_parallel_for_simd: {
+ case OMPD_target_teams_distribute_parallel_for_simd:
+ case OMPD_target_teams_distribute_simd: {
QualType KmpInt32Ty = Context.getIntTypeForBitwidth(32, 1);
QualType KmpInt32PtrTy =
Context.getPointerType(KmpInt32Ty).withConst().withRestrict();
@@ -1761,8 +1762,7 @@ static OMPCapturedExprDecl *buildCaptureDecl(Sema &S, IdentifierInfo *Id,
if (!WithInit)
CED->addAttr(OMPCaptureNoInitAttr::CreateImplicit(C, SourceRange()));
S.CurContext->addHiddenDecl(CED);
- S.AddInitializerToDecl(CED, Init, /*DirectInit=*/false,
- /*TypeMayContainAuto=*/true);
+ S.AddInitializerToDecl(CED, Init, /*DirectInit=*/false);
return CED;
}
@@ -2446,6 +2446,11 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
AllowedNameModifiers.push_back(OMPD_target);
AllowedNameModifiers.push_back(OMPD_parallel);
break;
+ case OMPD_target_teams_distribute_simd:
+ Res = ActOnOpenMPTargetTeamsDistributeSimdDirective(
+ ClausesWithImplicit, AStmt, StartLoc, EndLoc, VarsWithInheritedDSA);
+ AllowedNameModifiers.push_back(OMPD_target);
+ break;
case OMPD_declare_target:
case OMPD_end_declare_target:
case OMPD_threadprivate:
@@ -3970,33 +3975,32 @@ CheckOpenMPLoop(OpenMPDirectiveKind DKind, Expr *CollapseLoopCountExpr,
// Lower bound variable, initialized with zero.
VarDecl *LBDecl = buildVarDecl(SemaRef, InitLoc, VType, ".omp.lb");
LB = buildDeclRefExpr(SemaRef, LBDecl, VType, InitLoc);
- SemaRef.AddInitializerToDecl(
- LBDecl, SemaRef.ActOnIntegerConstant(InitLoc, 0).get(),
- /*DirectInit*/ false, /*TypeMayContainAuto*/ false);
+ SemaRef.AddInitializerToDecl(LBDecl,
+ SemaRef.ActOnIntegerConstant(InitLoc, 0).get(),
+ /*DirectInit*/ false);
// Upper bound variable, initialized with last iteration number.
VarDecl *UBDecl = buildVarDecl(SemaRef, InitLoc, VType, ".omp.ub");
UB = buildDeclRefExpr(SemaRef, UBDecl, VType, InitLoc);
SemaRef.AddInitializerToDecl(UBDecl, LastIteration.get(),
- /*DirectInit*/ false,
- /*TypeMayContainAuto*/ false);
+ /*DirectInit*/ false);
// A 32-bit variable-flag where runtime returns 1 for the last iteration.
// This will be used to implement clause 'lastprivate'.
QualType Int32Ty = SemaRef.Context.getIntTypeForBitwidth(32, true);
VarDecl *ILDecl = buildVarDecl(SemaRef, InitLoc, Int32Ty, ".omp.is_last");
IL = buildDeclRefExpr(SemaRef, ILDecl, Int32Ty, InitLoc);
- SemaRef.AddInitializerToDecl(
- ILDecl, SemaRef.ActOnIntegerConstant(InitLoc, 0).get(),
- /*DirectInit*/ false, /*TypeMayContainAuto*/ false);
+ SemaRef.AddInitializerToDecl(ILDecl,
+ SemaRef.ActOnIntegerConstant(InitLoc, 0).get(),
+ /*DirectInit*/ false);
// Stride variable returned by runtime (we initialize it to 1 by default).
VarDecl *STDecl =
buildVarDecl(SemaRef, InitLoc, StrideVType, ".omp.stride");
ST = buildDeclRefExpr(SemaRef, STDecl, StrideVType, InitLoc);
- SemaRef.AddInitializerToDecl(
- STDecl, SemaRef.ActOnIntegerConstant(InitLoc, 1).get(),
- /*DirectInit*/ false, /*TypeMayContainAuto*/ false);
+ SemaRef.AddInitializerToDecl(STDecl,
+ SemaRef.ActOnIntegerConstant(InitLoc, 1).get(),
+ /*DirectInit*/ false);
// Build expression: UB = min(UB, LastIteration)
// It is necessary for CodeGen of directives with static scheduling.
@@ -6428,6 +6432,39 @@ StmtResult Sema::ActOnOpenMPTargetTeamsDistributeParallelForSimdDirective(
Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
}
+StmtResult Sema::ActOnOpenMPTargetTeamsDistributeSimdDirective(
+ ArrayRef<OMPClause *> Clauses, Stmt *AStmt, SourceLocation StartLoc,
+ SourceLocation EndLoc,
+ llvm::DenseMap<ValueDecl *, Expr *> &VarsWithImplicitDSA) {
+ if (!AStmt)
+ return StmtError();
+
+ auto *CS = cast<CapturedStmt>(AStmt);
+ // 1.2.2 OpenMP Language Terminology
+ // Structured block - An executable statement with a single entry at the
+ // top and a single exit at the bottom.
+ // The point of exit cannot be a branch out of the structured block.
+ // longjmp() and throw() must not violate the entry/exit criteria.
+ CS->getCapturedDecl()->setNothrow();
+
+ OMPLoopDirective::HelperExprs B;
+ // In presence of clause 'collapse' with number of loops, it will
+ // define the nested loops number.
+ auto NestedLoopCount = CheckOpenMPLoop(
+ OMPD_target_teams_distribute_simd, getCollapseNumberExpr(Clauses),
+ nullptr /*ordered not a clause on distribute*/, AStmt, *this, *DSAStack,
+ VarsWithImplicitDSA, B);
+ if (NestedLoopCount == 0)
+ return StmtError();
+
+ assert((CurContext->isDependentContext() || B.builtAll()) &&
+ "omp target teams distribute simd loop exprs were not built");
+
+ getCurFunction()->setHasBranchProtectedScope();
+ return OMPTargetTeamsDistributeSimdDirective::Create(
+ Context, StartLoc, EndLoc, NestedLoopCount, Clauses, AStmt, B);
+}
+
OMPClause *Sema::ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
SourceLocation StartLoc,
SourceLocation LParenLoc,
@@ -7448,10 +7485,13 @@ OMPClause *Sema::ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList,
// A list item cannot appear in both a map clause and a data-sharing
// attribute clause on the same construct
if (CurrDir == OMPD_target || CurrDir == OMPD_target_parallel ||
- CurrDir == OMPD_target_teams ||
+ CurrDir == OMPD_target_teams ||
CurrDir == OMPD_target_teams_distribute ||
CurrDir == OMPD_target_teams_distribute_parallel_for ||
- CurrDir == OMPD_target_teams_distribute_parallel_for_simd) {
+ CurrDir == OMPD_target_teams_distribute_parallel_for_simd ||
+ CurrDir == OMPD_target_teams_distribute_simd ||
+ CurrDir == OMPD_target_parallel_for_simd ||
+ CurrDir == OMPD_target_parallel_for) {
OpenMPClauseKind ConflictKind;
if (DSAStack->checkMappableExprComponentListsForDecl(
VD, /*CurrentRegionOnly=*/true,
@@ -7481,7 +7521,7 @@ OMPClause *Sema::ActOnOpenMPPrivateClause(ArrayRef<Expr *> VarList,
Type = Type.getUnqualifiedType();
auto VDPrivate = buildVarDecl(*this, ELoc, Type, D->getName(),
D->hasAttrs() ? &D->getAttrs() : nullptr);
- ActOnUninitializedDecl(VDPrivate, /*TypeMayContainAuto=*/false);
+ ActOnUninitializedDecl(VDPrivate);
if (VDPrivate->isInvalidDecl())
continue;
auto VDPrivateRefExpr = buildDeclRefExpr(
@@ -7709,10 +7749,13 @@ OMPClause *Sema::ActOnOpenMPFirstprivateClause(ArrayRef<Expr *> VarList,
// A list item cannot appear in both a map clause and a data-sharing
// attribute clause on the same construct
if (CurrDir == OMPD_target || CurrDir == OMPD_target_parallel ||
- CurrDir == OMPD_target_teams ||
+ CurrDir == OMPD_target_teams ||
CurrDir == OMPD_target_teams_distribute ||
CurrDir == OMPD_target_teams_distribute_parallel_for ||
- CurrDir == OMPD_target_teams_distribute_parallel_for_simd) {
+ CurrDir == OMPD_target_teams_distribute_parallel_for_simd ||
+ CurrDir == OMPD_target_teams_distribute_simd ||
+ CurrDir == OMPD_target_parallel_for_simd ||
+ CurrDir == OMPD_target_parallel_for) {
OpenMPClauseKind ConflictKind;
if (DSAStack->checkMappableExprComponentListsForDecl(
VD, /*CurrentRegionOnly=*/true,
@@ -7784,7 +7827,7 @@ OMPClause *Sema::ActOnOpenMPFirstprivateClause(ArrayRef<Expr *> VarList,
RefExpr->getExprLoc());
AddInitializerToDecl(VDPrivate,
DefaultLvalueConversion(VDInitRefExpr).get(),
- /*DirectInit=*/false, /*TypeMayContainAuto=*/false);
+ /*DirectInit=*/false);
}
if (VDPrivate->isInvalidDecl()) {
if (IsImplicitClause) {
@@ -8634,10 +8677,9 @@ OMPClause *Sema::ActOnOpenMPReductionClause(
}
}
if (Init && DeclareReductionRef.isUnset()) {
- AddInitializerToDecl(RHSVD, Init, /*DirectInit=*/false,
- /*TypeMayContainAuto=*/false);
+ AddInitializerToDecl(RHSVD, Init, /*DirectInit=*/false);
} else if (!Init)
- ActOnUninitializedDecl(RHSVD, /*TypeMayContainAuto=*/false);
+ ActOnUninitializedDecl(RHSVD);
if (RHSVD->isInvalidDecl())
continue;
if (!RHSVD->hasInit() && DeclareReductionRef.isUnset()) {
@@ -8886,7 +8928,7 @@ OMPClause *Sema::ActOnOpenMPLinearClause(
else
InitExpr = VD ? SimpleRefExpr : Ref;
AddInitializerToDecl(Init, DefaultLvalueConversion(InitExpr).get(),
- /*DirectInit=*/false, /*TypeMayContainAuto=*/false);
+ /*DirectInit=*/false);
auto InitRef = buildDeclRefExpr(*this, Init, Type, ELoc);
DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_linear, Ref);
@@ -10231,7 +10273,8 @@ checkMappableExpressionList(Sema &SemaRef, DSAStackTy *DSAS,
if ((DKind == OMPD_target || DKind == OMPD_target_teams ||
DKind == OMPD_target_teams_distribute ||
DKind == OMPD_target_teams_distribute_parallel_for ||
- DKind == OMPD_target_teams_distribute_parallel_for_simd) && VD) {
+ DKind == OMPD_target_teams_distribute_parallel_for_simd ||
+ DKind == OMPD_target_teams_distribute_simd) && VD) {
auto DVar = DSAS->getTopDSA(VD, false);
if (isOpenMPPrivate(DVar.CKind)) {
SemaRef.Diag(ELoc, diag::err_omp_variable_in_given_clause_and_dsa)
@@ -10963,7 +11006,7 @@ OMPClause *Sema::ActOnOpenMPUseDevicePtrClause(ArrayRef<Expr *> VarList,
RefExpr->getExprLoc());
AddInitializerToDecl(VDPrivate,
DefaultLvalueConversion(VDInitRefExpr).get(),
- /*DirectInit=*/false, /*TypeMayContainAuto=*/false);
+ /*DirectInit=*/false);
// If required, build a capture to implement the privatization initialized
// with the current list item value.
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaOverload.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaOverload.cpp
index 41f4fa746fc6..afdae4ed6d7d 100644
--- a/contrib/llvm/tools/clang/lib/Sema/SemaOverload.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/SemaOverload.cpp
@@ -6596,7 +6596,9 @@ Sema::AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl,
Candidate.Function = MethodTmpl->getTemplatedDecl();
Candidate.Viable = false;
Candidate.IsSurrogate = false;
- Candidate.IgnoreObjectArgument = false;
+ Candidate.IgnoreObjectArgument =
+ cast<CXXMethodDecl>(Candidate.Function)->isStatic() ||
+ ObjectType.isNull();
Candidate.ExplicitCallArguments = Args.size();
if (Result == TDK_NonDependentConversionFailure)
Candidate.FailureKind = ovl_fail_bad_conversion;
@@ -6658,7 +6660,11 @@ Sema::AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate,
Candidate.Function = FunctionTemplate->getTemplatedDecl();
Candidate.Viable = false;
Candidate.IsSurrogate = false;
- Candidate.IgnoreObjectArgument = false;
+ // Ignore the object argument if there is one, since we don't have an object
+ // type.
+ Candidate.IgnoreObjectArgument =
+ isa<CXXMethodDecl>(Candidate.Function) &&
+ !isa<CXXConstructorDecl>(Candidate.Function);
Candidate.ExplicitCallArguments = Args.size();
if (Result == TDK_NonDependentConversionFailure)
Candidate.FailureKind = ovl_fail_bad_conversion;
@@ -10490,56 +10496,42 @@ static void CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand,
// operation somehow.
bool SuppressUserConversions = false;
- const FunctionProtoType *Proto;
- unsigned ArgIdx = 0;
+ unsigned ConvIdx = 0;
+ ArrayRef<QualType> ParamTypes;
if (Cand->IsSurrogate) {
QualType ConvType
= Cand->Surrogate->getConversionType().getNonReferenceType();
if (const PointerType *ConvPtrType = ConvType->getAs<PointerType>())
ConvType = ConvPtrType->getPointeeType();
- Proto = ConvType->getAs<FunctionProtoType>();
- ArgIdx = 1;
+ ParamTypes = ConvType->getAs<FunctionProtoType>()->getParamTypes();
+ // Conversion 0 is 'this', which doesn't have a corresponding argument.
+ ConvIdx = 1;
} else if (Cand->Function) {
- Proto = Cand->Function->getType()->getAs<FunctionProtoType>();
+ ParamTypes =
+ Cand->Function->getType()->getAs<FunctionProtoType>()->getParamTypes();
if (isa<CXXMethodDecl>(Cand->Function) &&
- !isa<CXXConstructorDecl>(Cand->Function))
- ArgIdx = 1;
+ !isa<CXXConstructorDecl>(Cand->Function)) {
+ // Conversion 0 is 'this', which doesn't have a corresponding argument.
+ ConvIdx = 1;
+ }
} else {
- // Builtin binary operator with a bad first conversion.
+ // Builtin operator.
assert(ConvCount <= 3);
- for (unsigned ConvIdx = (Cand->IgnoreObjectArgument ? 1 : 0);
- ConvIdx != ConvCount; ++ConvIdx) {
- if (Cand->Conversions[ConvIdx].isInitialized())
- continue;
- if (Cand->BuiltinTypes.ParamTypes[ConvIdx]->isDependentType())
- Cand->Conversions[ConvIdx].setAsIdentityConversion(
- Args[ConvIdx]->getType());
- else
- Cand->Conversions[ConvIdx] = TryCopyInitialization(
- S, Args[ConvIdx], Cand->BuiltinTypes.ParamTypes[ConvIdx],
- SuppressUserConversions,
- /*InOverloadResolution*/ true,
- /*AllowObjCWritebackConversion=*/
- S.getLangOpts().ObjCAutoRefCount);
- // FIXME: If the conversion is bad, try to fix it.
- }
- return;
+ ParamTypes = Cand->BuiltinTypes.ParamTypes;
}
// Fill in the rest of the conversions.
- unsigned NumParams = Proto->getNumParams();
- for (unsigned ConvIdx = (Cand->IgnoreObjectArgument ? 1 : 0);
- ConvIdx != ConvCount; ++ConvIdx, ++ArgIdx) {
+ for (unsigned ArgIdx = 0; ConvIdx != ConvCount; ++ConvIdx, ++ArgIdx) {
if (Cand->Conversions[ConvIdx].isInitialized()) {
- // Found the bad conversion.
- } else if (ArgIdx < NumParams) {
- if (Proto->getParamType(ArgIdx)->isDependentType())
+ // We've already checked this conversion.
+ } else if (ArgIdx < ParamTypes.size()) {
+ if (ParamTypes[ArgIdx]->isDependentType())
Cand->Conversions[ConvIdx].setAsIdentityConversion(
Args[ArgIdx]->getType());
else {
Cand->Conversions[ConvIdx] =
- TryCopyInitialization(S, Args[ArgIdx], Proto->getParamType(ArgIdx),
+ TryCopyInitialization(S, Args[ArgIdx], ParamTypes[ArgIdx],
SuppressUserConversions,
/*InOverloadResolution=*/true,
/*AllowObjCWritebackConversion=*/
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaStmt.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaStmt.cpp
index 50f0a22ff02b..a8832e9a1c54 100644
--- a/contrib/llvm/tools/clang/lib/Sema/SemaStmt.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/SemaStmt.cpp
@@ -1881,8 +1881,7 @@ static bool FinishForRangeVarDecl(Sema &SemaRef, VarDecl *Decl, Expr *Init,
SemaRef.inferObjCARCLifetime(Decl))
Decl->setInvalidDecl();
- SemaRef.AddInitializerToDecl(Decl, Init, /*DirectInit=*/false,
- /*TypeMayContainAuto=*/false);
+ SemaRef.AddInitializerToDecl(Decl, Init, /*DirectInit=*/false);
SemaRef.FinalizeDeclaration(Decl);
SemaRef.CurContext->addHiddenDecl(Decl);
return false;
@@ -2005,8 +2004,7 @@ StmtResult Sema::ActOnCXXForRangeStmt(Scope *S, SourceLocation ForLoc,
// Claim the type doesn't contain auto: we've already done the checking.
DeclGroupPtrTy RangeGroup =
- BuildDeclaratorGroup(MutableArrayRef<Decl *>((Decl **)&RangeVar, 1),
- /*TypeMayContainAuto=*/ false);
+ BuildDeclaratorGroup(MutableArrayRef<Decl *>((Decl **)&RangeVar, 1));
StmtResult RangeDecl = ActOnDeclStmt(RangeGroup, RangeLoc, RangeLoc);
if (RangeDecl.isInvalid()) {
LoopVar->setInvalidDecl();
@@ -2408,8 +2406,7 @@ Sema::BuildCXXForRangeStmt(SourceLocation ForLoc, SourceLocation CoawaitLoc,
// Attach *__begin as initializer for VD. Don't touch it if we're just
// trying to determine whether this would be a valid range.
if (!LoopVar->isInvalidDecl() && Kind != BFRK_Check) {
- AddInitializerToDecl(LoopVar, DerefExpr.get(), /*DirectInit=*/false,
- /*TypeMayContainAuto=*/true);
+ AddInitializerToDecl(LoopVar, DerefExpr.get(), /*DirectInit=*/false);
if (LoopVar->isInvalidDecl())
NoteForRangeBeginEndFunction(*this, BeginExpr.get(), BEF_begin);
}
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaTemplate.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaTemplate.cpp
index 795e6025d96f..8ad5b5951ea3 100644
--- a/contrib/llvm/tools/clang/lib/Sema/SemaTemplate.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/SemaTemplate.cpp
@@ -1224,9 +1224,17 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
}
}
+ // If this is a templated friend in a dependent context we should not put it
+ // on the redecl chain. In some cases, the templated friend can be the most
+ // recent declaration tricking the template instantiator to make substitutions
+ // there.
+ // FIXME: Figure out how to combine with shouldLinkDependentDeclWithPrevious
+ bool ShouldAddRedecl
+ = !(TUK == TUK_Friend && CurContext->isDependentContext());
+
CXXRecordDecl *NewClass =
CXXRecordDecl::Create(Context, Kind, SemanticContext, KWLoc, NameLoc, Name,
- PrevClassTemplate?
+ PrevClassTemplate && ShouldAddRedecl ?
PrevClassTemplate->getTemplatedDecl() : nullptr,
/*DelayTypeCreation=*/true);
SetNestedNameSpecifier(NewClass, SS);
@@ -1245,7 +1253,11 @@ Sema::CheckClassTemplate(Scope *S, unsigned TagSpec, TagUseKind TUK,
ClassTemplateDecl *NewTemplate
= ClassTemplateDecl::Create(Context, SemanticContext, NameLoc,
DeclarationName(Name), TemplateParams,
- NewClass, PrevClassTemplate);
+ NewClass);
+
+ if (ShouldAddRedecl)
+ NewTemplate->setPreviousDecl(PrevClassTemplate);
+
NewClass->setDescribedClassTemplate(NewTemplate);
if (ModulePrivateLoc.isValid())
@@ -1653,6 +1665,7 @@ struct DependencyChecker : RecursiveASTVisitor<DependencyChecker> {
typedef RecursiveASTVisitor<DependencyChecker> super;
unsigned Depth;
+ bool FindLessThanDepth;
// Whether we're looking for a use of a template parameter that makes the
// overall construct type-dependent / a dependent type. This is strictly
@@ -1663,25 +1676,16 @@ struct DependencyChecker : RecursiveASTVisitor<DependencyChecker> {
bool Match;
SourceLocation MatchLoc;
- DependencyChecker(unsigned Depth, bool IgnoreNonTypeDependent)
- : Depth(Depth), IgnoreNonTypeDependent(IgnoreNonTypeDependent),
- Match(false) {}
+ DependencyChecker(unsigned Depth, bool IgnoreNonTypeDependent,
+ bool FindLessThanDepth = false)
+ : Depth(Depth), FindLessThanDepth(FindLessThanDepth),
+ IgnoreNonTypeDependent(IgnoreNonTypeDependent), Match(false) {}
DependencyChecker(TemplateParameterList *Params, bool IgnoreNonTypeDependent)
- : IgnoreNonTypeDependent(IgnoreNonTypeDependent), Match(false) {
- NamedDecl *ND = Params->getParam(0);
- if (TemplateTypeParmDecl *PD = dyn_cast<TemplateTypeParmDecl>(ND)) {
- Depth = PD->getDepth();
- } else if (NonTypeTemplateParmDecl *PD =
- dyn_cast<NonTypeTemplateParmDecl>(ND)) {
- Depth = PD->getDepth();
- } else {
- Depth = cast<TemplateTemplateParmDecl>(ND)->getDepth();
- }
- }
+ : DependencyChecker(Params->getDepth(), IgnoreNonTypeDependent) {}
bool Matches(unsigned ParmDepth, SourceLocation Loc = SourceLocation()) {
- if (ParmDepth >= Depth) {
+ if (FindLessThanDepth ^ (ParmDepth >= Depth)) {
Match = true;
MatchLoc = Loc;
return true;
@@ -2336,15 +2340,7 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
// A<T, T> have identical types when A is declared as:
//
// template<typename T, typename U = T> struct A;
- TemplateName CanonName = Context.getCanonicalTemplateName(Name);
- CanonType = Context.getTemplateSpecializationType(CanonName,
- Converted);
-
- // FIXME: CanonType is not actually the canonical type, and unfortunately
- // it is a TemplateSpecializationType that we will never use again.
- // In the future, we need to teach getTemplateSpecializationType to only
- // build the canonical type and return that to us.
- CanonType = Context.getCanonicalType(CanonType);
+ CanonType = Context.getCanonicalTemplateSpecializationType(Name, Converted);
// This might work out to be a current instantiation, in which
// case the canonical type needs to be the InjectedClassNameType.
@@ -3452,7 +3448,7 @@ SubstDefaultTemplateArgument(Sema &SemaRef,
SourceLocation TemplateLoc,
SourceLocation RAngleLoc,
TemplateTypeParmDecl *Param,
- SmallVectorImpl<TemplateArgument> &Converted) {
+ SmallVectorImpl<TemplateArgument> &Converted) {
TypeSourceInfo *ArgType = Param->getDefaultArgumentInfo();
// If the argument type is dependent, instantiate it now based
@@ -5838,6 +5834,15 @@ Sema::BuildExpressionFromIntegralTemplateArgument(const TemplateArgument &Arg,
return E;
}
+static bool isDependentOnOuter(NonTypeTemplateParmDecl *NTTP) {
+ if (NTTP->getDepth() == 0 || !NTTP->getType()->isDependentType())
+ return false;
+ DependencyChecker Checker(NTTP->getDepth(), /*IgnoreNonTypeDependent*/ false,
+ /*FindLessThanDepth*/ true);
+ Checker.TraverseType(NTTP->getType());
+ return Checker.Match;
+}
+
/// \brief Match two template parameters within template parameter lists.
static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, NamedDecl *Old,
bool Complain,
@@ -5894,11 +5899,10 @@ static bool MatchTemplateParameterKind(Sema &S, NamedDecl *New, NamedDecl *Old,
// If we are matching a template template argument to a template
// template parameter and one of the non-type template parameter types
- // is dependent, then we must wait until template instantiation time
- // to actually compare the arguments.
+ // is dependent on an outer template's parameter, then we must wait until
+ // template instantiation time to actually compare the arguments.
if (Kind == Sema::TPL_TemplateTemplateArgumentMatch &&
- (OldNTTP->getType()->isDependentType() ||
- NewNTTP->getType()->isDependentType()))
+ (isDependentOnOuter(OldNTTP) || isDependentOnOuter(NewNTTP)))
return true;
if (!S.Context.hasSameType(OldNTTP->getType(), NewNTTP->getType())) {
@@ -7785,6 +7789,7 @@ Sema::ActOnExplicitInstantiation(Scope *S,
Specialization->setTemplateKeywordLoc(TemplateLoc);
Specialization->setBraceRange(SourceRange());
+ bool PreviouslyDLLExported = Specialization->hasAttr<DLLExportAttr>();
if (Attr)
ProcessDeclAttributeList(S, Specialization, Attr);
@@ -7847,8 +7852,9 @@ Sema::ActOnExplicitInstantiation(Scope *S,
// Fix a TSK_ImplicitInstantiation followed by a
// TSK_ExplicitInstantiationDefinition
- if (Old_TSK == TSK_ImplicitInstantiation &&
- Specialization->hasAttr<DLLExportAttr>() &&
+ bool NewlyDLLExported =
+ !PreviouslyDLLExported && Specialization->hasAttr<DLLExportAttr>();
+ if (Old_TSK == TSK_ImplicitInstantiation && NewlyDLLExported &&
(Context.getTargetInfo().getCXXABI().isMicrosoft() ||
Context.getTargetInfo().getTriple().isWindowsItaniumEnvironment())) {
// In the MS ABI, an explicit instantiation definition can add a dll
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp
index ba4a5b7bc0d7..9f744a1dc1b2 100644
--- a/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2264,9 +2264,6 @@ bool Sema::InstantiateInClassInitializer(
if (auto *L = getASTMutationListener())
L->DefaultMemberInitializerInstantiated(Instantiation);
- // Exit the scope of this instantiation.
- SavedContext.pop();
-
// Return true if the in-class initializer is still missing.
return !Instantiation->getInClassInitializer();
}
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index d2a5e5cb5312..48d8b94af153 100644
--- a/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -1219,8 +1219,10 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {
ClassTemplateDecl *Inst
= ClassTemplateDecl::Create(SemaRef.Context, DC, D->getLocation(),
- D->getIdentifier(), InstParams, RecordInst,
- PrevClassTemplate);
+ D->getIdentifier(), InstParams, RecordInst);
+ assert(!(isFriend && Owner->isDependentContext()));
+ Inst->setPreviousDecl(PrevClassTemplate);
+
RecordInst->setDescribedClassTemplate(Inst);
if (isFriend) {
@@ -4085,7 +4087,6 @@ void Sema::InstantiateVariableInitializer(
}
if (!Init.isInvalid()) {
- bool TypeMayContainAuto = true;
Expr *InitExpr = Init.get();
if (Var->hasAttr<DLLImportAttr>() &&
@@ -4094,9 +4095,9 @@ void Sema::InstantiateVariableInitializer(
// Do not dynamically initialize dllimport variables.
} else if (InitExpr) {
bool DirectInit = OldVar->isDirectInit();
- AddInitializerToDecl(Var, InitExpr, DirectInit, TypeMayContainAuto);
+ AddInitializerToDecl(Var, InitExpr, DirectInit);
} else
- ActOnUninitializedDecl(Var, TypeMayContainAuto);
+ ActOnUninitializedDecl(Var);
} else {
// FIXME: Not too happy about invalidating the declaration
// because of a bogus initializer.
@@ -4119,7 +4120,7 @@ void Sema::InstantiateVariableInitializer(
if (Var->isCXXForRangeDecl())
return;
- ActOnUninitializedDecl(Var, false);
+ ActOnUninitializedDecl(Var);
}
}
diff --git a/contrib/llvm/tools/clang/lib/Sema/SemaType.cpp b/contrib/llvm/tools/clang/lib/Sema/SemaType.cpp
index ae9a3ee790e1..29b21426790e 100644
--- a/contrib/llvm/tools/clang/lib/Sema/SemaType.cpp
+++ b/contrib/llvm/tools/clang/lib/Sema/SemaType.cpp
@@ -5263,7 +5263,7 @@ namespace {
ParmVarDecl *Param = cast<ParmVarDecl>(FTI.Params[i].Param);
TL.setParam(tpi++, Param);
}
- // FIXME: exception specs
+ TL.setExceptionSpecRange(FTI.getExceptionSpecRange());
}
void VisitParenTypeLoc(ParenTypeLoc TL) {
assert(Chunk.Kind == DeclaratorChunk::Paren);
diff --git a/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h b/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h
index 66892936e573..c2aa3fef67c8 100644
--- a/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h
+++ b/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h
@@ -5023,6 +5023,7 @@ QualType TreeTransform<Derived>::TransformFunctionProtoType(
NewTL.setLocalRangeBegin(TL.getLocalRangeBegin());
NewTL.setLParenLoc(TL.getLParenLoc());
NewTL.setRParenLoc(TL.getRParenLoc());
+ NewTL.setExceptionSpecRange(TL.getExceptionSpecRange());
NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
NewTL.setParam(i, ParamDecls[i]);
@@ -7779,6 +7780,18 @@ StmtResult TreeTransform<Derived>::
return Res;
}
+template <typename Derived>
+StmtResult
+TreeTransform<Derived>::TransformOMPTargetTeamsDistributeSimdDirective(
+ OMPTargetTeamsDistributeSimdDirective *D) {
+ DeclarationNameInfo DirName;
+ getDerived().getSema().StartOpenMPDSABlock(
+ OMPD_target_teams_distribute_simd, DirName, nullptr, D->getLocStart());
+ auto Res = getDerived().TransformOMPExecutableDirective(D);
+ getDerived().getSema().EndOpenMPDSABlock(Res.get());
+ return Res;
+}
+
//===----------------------------------------------------------------------===//
// OpenMP clause transformation
diff --git a/contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp b/contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp
index 7f890051e641..53224e2b493d 100644
--- a/contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp
+++ b/contrib/llvm/tools/clang/lib/Serialization/ASTReader.cpp
@@ -5990,6 +5990,8 @@ void TypeLocReader::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
TL.setLocalRangeBegin(ReadSourceLocation());
TL.setLParenLoc(ReadSourceLocation());
TL.setRParenLoc(ReadSourceLocation());
+ TL.setExceptionSpecRange(SourceRange(Reader->ReadSourceLocation(*F, Record, Idx),
+ Reader->ReadSourceLocation(*F, Record, Idx)));
TL.setLocalRangeEnd(ReadSourceLocation());
for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) {
TL.setParam(i, Reader->ReadDeclAs<ParmVarDecl>(*F, Record, Idx));
diff --git a/contrib/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp b/contrib/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp
index 6e18b208a9ae..c6919193391b 100644
--- a/contrib/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/contrib/llvm/tools/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -748,6 +748,7 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
FD->IsExplicitlyDefaulted = Record.readInt();
FD->HasImplicitReturnZero = Record.readInt();
FD->IsConstexpr = Record.readInt();
+ FD->UsesSEHTry = Record.readInt();
FD->HasSkippedBody = Record.readInt();
FD->IsLateTemplateParsed = Record.readInt();
FD->setCachedLinkage(Linkage(Record.readInt()));
diff --git a/contrib/llvm/tools/clang/lib/Serialization/ASTReaderStmt.cpp b/contrib/llvm/tools/clang/lib/Serialization/ASTReaderStmt.cpp
index 19fac55664ae..686a69bbbcd2 100644
--- a/contrib/llvm/tools/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/contrib/llvm/tools/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -2865,6 +2865,11 @@ void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
VisitOMPLoopDirective(D);
}
+void ASTStmtReader::VisitOMPTargetTeamsDistributeSimdDirective(
+ OMPTargetTeamsDistributeSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
//===----------------------------------------------------------------------===//
// ASTReader Implementation
//===----------------------------------------------------------------------===//
@@ -3651,6 +3656,14 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
break;
}
+ case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
+ auto NumClauses = Record[ASTStmtReader::NumStmtFields];
+ auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPTargetTeamsDistributeSimdDirective::CreateEmpty(
+ Context, NumClauses, CollapsedNum, Empty);
+ break;
+ }
+
case EXPR_CXX_OPERATOR_CALL:
S = new (Context) CXXOperatorCallExpr(Context, Empty);
break;
diff --git a/contrib/llvm/tools/clang/lib/Serialization/ASTWriter.cpp b/contrib/llvm/tools/clang/lib/Serialization/ASTWriter.cpp
index 39e842db2baa..886523ea9431 100644
--- a/contrib/llvm/tools/clang/lib/Serialization/ASTWriter.cpp
+++ b/contrib/llvm/tools/clang/lib/Serialization/ASTWriter.cpp
@@ -629,6 +629,7 @@ void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
Record.AddSourceLocation(TL.getLocalRangeBegin());
Record.AddSourceLocation(TL.getLParenLoc());
Record.AddSourceLocation(TL.getRParenLoc());
+ Record.AddSourceRange(TL.getExceptionSpecRange());
Record.AddSourceLocation(TL.getLocalRangeEnd());
for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)
Record.AddDeclRef(TL.getParam(i));
diff --git a/contrib/llvm/tools/clang/lib/Serialization/ASTWriterDecl.cpp b/contrib/llvm/tools/clang/lib/Serialization/ASTWriterDecl.cpp
index 8e1480739a5f..d8466e9cbf3b 100644
--- a/contrib/llvm/tools/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/contrib/llvm/tools/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -529,6 +529,7 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
Record.push_back(D->IsExplicitlyDefaulted);
Record.push_back(D->HasImplicitReturnZero);
Record.push_back(D->IsConstexpr);
+ Record.push_back(D->UsesSEHTry);
Record.push_back(D->HasSkippedBody);
Record.push_back(D->IsLateTemplateParsed);
Record.push_back(D->getLinkageInternal());
@@ -2032,6 +2033,7 @@ void ASTWriter::WriteDeclAbbrevs() {
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ExplicitlyDefaulted
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // ImplicitReturnZero
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // Constexpr
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // UsesSEHTry
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // SkippedBody
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // LateParsed
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
diff --git a/contrib/llvm/tools/clang/lib/Serialization/ASTWriterStmt.cpp b/contrib/llvm/tools/clang/lib/Serialization/ASTWriterStmt.cpp
index 162b2bd25260..01fd98ceadb2 100644
--- a/contrib/llvm/tools/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/contrib/llvm/tools/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -2563,6 +2563,12 @@ void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForSimdDirective(
STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE;
}
+void ASTStmtWriter::VisitOMPTargetTeamsDistributeSimdDirective(
+ OMPTargetTeamsDistributeSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE;
+}
+
//===----------------------------------------------------------------------===//
// ASTWriter Implementation
//===----------------------------------------------------------------------===//
diff --git a/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 7e7e329dc4d7..d563f8e9eac0 100644
--- a/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -515,8 +515,9 @@ void ExprEngine::ProcessInitializer(const CFGInitializer Init,
Init = ASE->getBase()->IgnoreImplicit();
SVal LValue = State->getSVal(Init, stackFrame);
- if (Optional<Loc> LValueLoc = LValue.getAs<Loc>())
- InitVal = State->getSVal(*LValueLoc);
+ if (!Field->getType()->isReferenceType())
+ if (Optional<Loc> LValueLoc = LValue.getAs<Loc>())
+ InitVal = State->getSVal(*LValueLoc);
// If we fail to get the value for some reason, use a symbolic value.
if (InitVal.isUnknownOrUndef()) {
@@ -870,6 +871,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::OMPTargetTeamsDistributeDirectiveClass:
case Stmt::OMPTargetTeamsDistributeParallelForDirectiveClass:
case Stmt::OMPTargetTeamsDistributeParallelForSimdDirectiveClass:
+ case Stmt::OMPTargetTeamsDistributeSimdDirectiveClass:
llvm_unreachable("Stmt should not be in analyzer evaluation loop");
case Stmt::ObjCSubscriptRefExprClass:
diff --git a/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp b/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
index 10b0858b8488..ffaa0eda918a 100644
--- a/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ b/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -218,6 +218,18 @@ SValBuilder::getDerivedRegionValueSymbolVal(SymbolRef parentSymbol,
}
DefinedSVal SValBuilder::getMemberPointer(const DeclaratorDecl* DD) {
+ assert(!DD || isa<CXXMethodDecl>(DD) || isa<FieldDecl>(DD));
+
+ if (auto *MD = dyn_cast_or_null<CXXMethodDecl>(DD)) {
+ // Sema treats pointers to static member functions as have function pointer
+ // type, so return a function pointer for the method.
+ // We don't need to play a similar trick for static member fields
+ // because these are represented as plain VarDecls and not FieldDecls
+ // in the AST.
+ if (MD->isStatic())
+ return getFunctionPointer(MD);
+ }
+
return nonloc::PointerToMember(DD);
}
diff --git a/contrib/llvm/tools/lld/CMakeLists.txt b/contrib/llvm/tools/lld/CMakeLists.txt
index 23cef2e9fc67..48ac5e038cdb 100644
--- a/contrib/llvm/tools/lld/CMakeLists.txt
+++ b/contrib/llvm/tools/lld/CMakeLists.txt
@@ -12,6 +12,7 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
endif()
execute_process(COMMAND "${LLVM_CONFIG_PATH}" "--obj-root" "--includedir"
+ "--cmakedir"
RESULT_VARIABLE HAD_ERROR
OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT
OUTPUT_STRIP_TRAILING_WHITESPACE)
@@ -23,12 +24,12 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
list(GET LLVM_CONFIG_OUTPUT 0 OBJ_ROOT)
list(GET LLVM_CONFIG_OUTPUT 1 MAIN_INCLUDE_DIR)
+ list(GET LLVM_CONFIG_OUTPUT 2 LLVM_CMAKE_PATH)
set(LLVM_OBJ_ROOT ${OBJ_ROOT} CACHE PATH "path to LLVM build tree")
set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "path to llvm/include")
file(TO_CMAKE_PATH ${LLVM_OBJ_ROOT} LLVM_BINARY_DIR)
- set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
if(NOT EXISTS "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
message(FATAL_ERROR "LLVMConfig.cmake not found")
diff --git a/contrib/llvm/tools/lld/COFF/PDB.cpp b/contrib/llvm/tools/lld/COFF/PDB.cpp
index d5c52a69be69..923fc64c7734 100644
--- a/contrib/llvm/tools/lld/COFF/PDB.cpp
+++ b/contrib/llvm/tools/lld/COFF/PDB.cpp
@@ -14,8 +14,12 @@
#include "SymbolTable.h"
#include "Symbols.h"
#include "llvm/DebugInfo/CodeView/CVDebugRecord.h"
+#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
#include "llvm/DebugInfo/CodeView/SymbolDumper.h"
-#include "llvm/DebugInfo/CodeView/TypeDumper.h"
+#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
+#include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h"
+#include "llvm/DebugInfo/CodeView/TypeStreamMerger.h"
+#include "llvm/DebugInfo/CodeView/TypeTableBuilder.h"
#include "llvm/DebugInfo/MSF/ByteStream.h"
#include "llvm/DebugInfo/MSF/MSFBuilder.h"
#include "llvm/DebugInfo/MSF/MSFCommon.h"
@@ -61,44 +65,75 @@ static SectionChunk *findByName(std::vector<SectionChunk *> &Sections,
return nullptr;
}
-static ArrayRef<uint8_t> getDebugT(ObjectFile *File) {
- SectionChunk *Sec = findByName(File->getDebugChunks(), ".debug$T");
+static ArrayRef<uint8_t> getDebugSection(ObjectFile *File, StringRef SecName) {
+ SectionChunk *Sec = findByName(File->getDebugChunks(), SecName);
if (!Sec)
return {};
// First 4 bytes are section magic.
ArrayRef<uint8_t> Data = Sec->getContents();
if (Data.size() < 4)
- fatal(".debug$T too short");
+ fatal(SecName + " too short");
if (read32le(Data.data()) != COFF::DEBUG_SECTION_MAGIC)
- fatal(".debug$T has an invalid magic");
+ fatal(SecName + " has an invalid magic");
return Data.slice(4);
}
+// Merge .debug$T sections and returns it.
+static std::vector<uint8_t> mergeDebugT(SymbolTable *Symtab) {
+ ScopedPrinter W(outs());
+
+ // Visit all .debug$T sections to add them to Builder.
+ codeview::TypeTableBuilder Builder(BAlloc);
+ for (ObjectFile *File : Symtab->ObjectFiles) {
+ ArrayRef<uint8_t> Data = getDebugSection(File, ".debug$T");
+ if (Data.empty())
+ continue;
+
+ msf::ByteStream Stream(Data);
+ codeview::CVTypeArray Types;
+ msf::StreamReader Reader(Stream);
+ if (auto EC = Reader.readArray(Types, Reader.getLength()))
+ fatal(EC, "Reader::readArray failed");
+ if (!codeview::mergeTypeStreams(Builder, Types))
+ fatal("codeview::mergeTypeStreams failed");
+ }
+
+ // Construct section contents.
+ std::vector<uint8_t> V;
+ Builder.ForEachRecord([&](TypeIndex TI, ArrayRef<uint8_t> Rec) {
+ V.insert(V.end(), Rec.begin(), Rec.end());
+ });
+ return V;
+}
+
static void dumpDebugT(ScopedPrinter &W, ObjectFile *File) {
- ArrayRef<uint8_t> Data = getDebugT(File);
+ ListScope LS(W, "DebugT");
+ ArrayRef<uint8_t> Data = getDebugSection(File, ".debug$T");
if (Data.empty())
return;
- msf::ByteStream Stream(Data);
- CVTypeDumper TypeDumper(&W, false);
- if (auto EC = TypeDumper.dump(Data))
+ TypeDatabase TDB;
+ TypeDumpVisitor TDV(TDB, &W, false);
+ CVTypeDumper TypeDumper(TDB);
+ if (auto EC = TypeDumper.dump(Data, TDV))
fatal(EC, "CVTypeDumper::dump failed");
}
static void dumpDebugS(ScopedPrinter &W, ObjectFile *File) {
- SectionChunk *Sec = findByName(File->getDebugChunks(), ".debug$S");
- if (!Sec)
+ ListScope LS(W, "DebugS");
+ ArrayRef<uint8_t> Data = getDebugSection(File, ".debug$S");
+ if (Data.empty())
return;
- msf::ByteStream Stream(Sec->getContents());
+ msf::ByteStream Stream(Data);
CVSymbolArray Symbols;
msf::StreamReader Reader(Stream);
if (auto EC = Reader.readArray(Symbols, Reader.getLength()))
fatal(EC, "StreamReader.readArray<CVSymbolArray> failed");
- CVTypeDumper TypeDumper(&W, false);
- CVSymbolDumper SymbolDumper(W, TypeDumper, nullptr, false);
+ TypeDatabase TDB;
+ CVSymbolDumper SymbolDumper(W, TDB, nullptr, false);
if (auto EC = SymbolDumper.dump(Symbols))
fatal(EC, "CVSymbolDumper::dump failed");
}
@@ -113,21 +148,15 @@ static void dumpCodeView(SymbolTable *Symtab) {
}
}
-static void addTypeInfo(SymbolTable *Symtab,
- pdb::TpiStreamBuilder &TpiBuilder) {
- for (ObjectFile *File : Symtab->ObjectFiles) {
- ArrayRef<uint8_t> Data = getDebugT(File);
- if (Data.empty())
- continue;
-
- msf::ByteStream Stream(Data);
- codeview::CVTypeArray Records;
- msf::StreamReader Reader(Stream);
- if (auto EC = Reader.readArray(Records, Reader.getLength()))
- fatal(EC, "Reader.readArray failed");
- for (const codeview::CVType &Rec : Records)
- TpiBuilder.addTypeRecord(Rec);
- }
+static void addTypeInfo(pdb::TpiStreamBuilder &TpiBuilder,
+ ArrayRef<uint8_t> Data) {
+ msf::ByteStream Stream(Data);
+ codeview::CVTypeArray Records;
+ msf::StreamReader Reader(Stream);
+ if (auto EC = Reader.readArray(Records, Reader.getLength()))
+ fatal(EC, "Reader.readArray failed");
+ for (const codeview::CVType &Rec : Records)
+ TpiBuilder.addTypeRecord(Rec);
}
// Creates a PDB file.
@@ -162,8 +191,11 @@ void coff::createPDB(StringRef Path, SymbolTable *Symtab,
// Add an empty TPI stream.
auto &TpiBuilder = Builder.getTpiBuilder();
TpiBuilder.setVersionHeader(pdb::PdbTpiV80);
- if (Config->DebugPdb)
- addTypeInfo(Symtab, TpiBuilder);
+ std::vector<uint8_t> TpiData;
+ if (Config->DebugPdb) {
+ TpiData = mergeDebugT(Symtab);
+ addTypeInfo(TpiBuilder, TpiData);
+ }
// Add an empty IPI stream.
auto &IpiBuilder = Builder.getIpiBuilder();
diff --git a/contrib/llvm/tools/lld/ELF/Driver.cpp b/contrib/llvm/tools/lld/ELF/Driver.cpp
index c8ea821ec522..b4544d78f725 100644
--- a/contrib/llvm/tools/lld/ELF/Driver.cpp
+++ b/contrib/llvm/tools/lld/ELF/Driver.cpp
@@ -24,6 +24,7 @@
#include "lld/Driver/Driver.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/Object/Decompressor.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/TarWriter.h"
@@ -815,7 +816,7 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
[](InputSectionBase<ELFT> *S) {
if (!S->Live)
return;
- if (S->isCompressed())
+ if (Decompressor::isCompressedELFSection(S->Flags, S->Name))
S->uncompress();
if (auto *MS = dyn_cast<MergeInputSection<ELFT>>(S))
MS->splitIntoPieces();
diff --git a/contrib/llvm/tools/lld/ELF/Error.cpp b/contrib/llvm/tools/lld/ELF/Error.cpp
index 6e30f08143ed..d9b41f9c599e 100644
--- a/contrib/llvm/tools/lld/ELF/Error.cpp
+++ b/contrib/llvm/tools/lld/ELF/Error.cpp
@@ -103,4 +103,8 @@ void elf::fatal(std::error_code EC, const Twine &Prefix) {
fatal(Prefix + ": " + EC.message());
}
+void elf::fatal(Error &E, const Twine &Prefix) {
+ fatal(Prefix + ": " + llvm::toString(std::move(E)));
+}
+
} // namespace lld
diff --git a/contrib/llvm/tools/lld/ELF/Error.h b/contrib/llvm/tools/lld/ELF/Error.h
index 1ec683595cf4..f18cf456da6d 100644
--- a/contrib/llvm/tools/lld/ELF/Error.h
+++ b/contrib/llvm/tools/lld/ELF/Error.h
@@ -44,6 +44,7 @@ void error(std::error_code EC, const Twine &Prefix);
LLVM_ATTRIBUTE_NORETURN void exitLld(int Val);
LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg);
LLVM_ATTRIBUTE_NORETURN void fatal(std::error_code EC, const Twine &Prefix);
+LLVM_ATTRIBUTE_NORETURN void fatal(Error &E, const Twine &Prefix);
// check() functions are convenient functions to strip errors
// from error-or-value objects.
@@ -55,11 +56,7 @@ template <class T> T check(ErrorOr<T> E) {
template <class T> T check(Expected<T> E) {
if (!E)
- handleAllErrors(std::move(E.takeError()),
- [](llvm::ErrorInfoBase &EIB) -> Error {
- fatal(EIB.message());
- return Error::success();
- });
+ fatal(llvm::toString(E.takeError()));
return std::move(*E);
}
diff --git a/contrib/llvm/tools/lld/ELF/InputFiles.cpp b/contrib/llvm/tools/lld/ELF/InputFiles.cpp
index 1fddf40f5b22..f3afb1c34562 100644
--- a/contrib/llvm/tools/lld/ELF/InputFiles.cpp
+++ b/contrib/llvm/tools/lld/ELF/InputFiles.cpp
@@ -857,8 +857,8 @@ template <class ELFT> void BinaryFile::parse() {
StringRef EndName = Saver.save(Twine(Filename) + "_end");
StringRef SizeName = Saver.save(Twine(Filename) + "_size");
- auto *Section =
- make<InputSection<ELFT>>(SHF_ALLOC, SHT_PROGBITS, 8, Data, ".data");
+ auto *Section = make<InputSection<ELFT>>(SHF_ALLOC | SHF_WRITE, SHT_PROGBITS,
+ 8, Data, ".data");
Sections.push_back(Section);
elf::Symtab<ELFT>::X->addRegular(StartName, STV_DEFAULT, STT_OBJECT, 0, 0,
diff --git a/contrib/llvm/tools/lld/ELF/InputSection.cpp b/contrib/llvm/tools/lld/ELF/InputSection.cpp
index e87d92aa207c..358004248373 100644
--- a/contrib/llvm/tools/lld/ELF/InputSection.cpp
+++ b/contrib/llvm/tools/lld/ELF/InputSection.cpp
@@ -19,6 +19,7 @@
#include "SyntheticSections.h"
#include "Target.h"
#include "Thunks.h"
+#include "llvm/Object/Decompressor.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Endian.h"
#include <mutex>
@@ -35,7 +36,10 @@ using namespace lld::elf;
// Returns a string to construct an error message.
template <class ELFT>
std::string lld::toString(const InputSectionBase<ELFT> *Sec) {
- return (Sec->getFile()->getName() + ":(" + Sec->Name + ")").str();
+ // File can be absent if section is synthetic.
+ std::string FileName =
+ Sec->getFile() ? Sec->getFile()->getName() : "<internal>";
+ return (FileName + ":(" + Sec->Name + ")").str();
}
template <class ELFT>
@@ -102,11 +106,6 @@ template <class ELFT> size_t InputSectionBase<ELFT>::getSize() const {
return Data.size();
}
-// Returns a string for an error message.
-template <class SectionT> static std::string getName(SectionT *Sec) {
- return (Sec->getFile()->getName() + ":(" + Sec->Name + ")").str();
-}
-
template <class ELFT>
typename ELFT::uint InputSectionBase<ELFT>::getOffset(uintX_t Offset) const {
switch (kind()) {
@@ -128,71 +127,23 @@ typename ELFT::uint InputSectionBase<ELFT>::getOffset(uintX_t Offset) const {
llvm_unreachable("invalid section kind");
}
-template <class ELFT> bool InputSectionBase<ELFT>::isCompressed() const {
- return (Flags & SHF_COMPRESSED) || Name.startswith(".zdebug");
-}
-
-// Returns compressed data and its size when uncompressed.
-template <class ELFT>
-std::pair<ArrayRef<uint8_t>, uint64_t>
-InputSectionBase<ELFT>::getElfCompressedData(ArrayRef<uint8_t> Data) {
- // Compressed section with Elf_Chdr is the ELF standard.
- if (Data.size() < sizeof(Elf_Chdr))
- fatal(toString(this) + ": corrupted compressed section");
- auto *Hdr = reinterpret_cast<const Elf_Chdr *>(Data.data());
- if (Hdr->ch_type != ELFCOMPRESS_ZLIB)
- fatal(toString(this) + ": unsupported compression type");
- return {Data.slice(sizeof(*Hdr)), Hdr->ch_size};
-}
-
-// Returns compressed data and its size when uncompressed.
-template <class ELFT>
-std::pair<ArrayRef<uint8_t>, uint64_t>
-InputSectionBase<ELFT>::getRawCompressedData(ArrayRef<uint8_t> Data) {
- // Compressed sections without Elf_Chdr header contain this header
- // instead. This is a GNU extension.
- struct ZlibHeader {
- char Magic[4]; // Should be "ZLIB"
- char Size[8]; // Uncompressed size in big-endian
- };
-
- if (Data.size() < sizeof(ZlibHeader))
- fatal(toString(this) + ": corrupted compressed section");
- auto *Hdr = reinterpret_cast<const ZlibHeader *>(Data.data());
- if (memcmp(Hdr->Magic, "ZLIB", 4))
- fatal(toString(this) + ": broken ZLIB-compressed section");
- return {Data.slice(sizeof(*Hdr)), read64be(Hdr->Size)};
-}
-
// Uncompress section contents. Note that this function is called
// from parallel_for_each, so it must be thread-safe.
template <class ELFT> void InputSectionBase<ELFT>::uncompress() {
- if (!zlib::isAvailable())
- fatal(toString(this) +
- ": build lld with zlib to enable compressed sections support");
-
- // This section is compressed. Here we decompress it. Ideally, all
- // compressed sections have SHF_COMPRESSED bit and their contents
- // start with headers of Elf_Chdr type. However, sections whose
- // names start with ".zdebug_" don't have the bit and contains a raw
- // ZLIB-compressed data (which is a bad thing because section names
- // shouldn't be significant in ELF.) We need to be able to read both.
- ArrayRef<uint8_t> Buf; // Compressed data
- size_t Size; // Uncompressed size
- if (Flags & SHF_COMPRESSED)
- std::tie(Buf, Size) = getElfCompressedData(Data);
- else
- std::tie(Buf, Size) = getRawCompressedData(Data);
+ Decompressor Decompressor = check(Decompressor::create(
+ Name, toStringRef(Data), ELFT::TargetEndianness == llvm::support::little,
+ ELFT::Is64Bits));
- // Uncompress Buf.
+ size_t Size = Decompressor.getDecompressedSize();
char *OutputBuf;
{
static std::mutex Mu;
std::lock_guard<std::mutex> Lock(Mu);
OutputBuf = BAlloc.Allocate<char>(Size);
}
- if (zlib::uncompress(toStringRef(Buf), OutputBuf, Size) != zlib::StatusOK)
- fatal(toString(this) + ": error while uncompressing section");
+
+ if (Error E = Decompressor.decompress({OutputBuf, Size}))
+ fatal(E, toString(this));
Data = ArrayRef<uint8_t>((uint8_t *)OutputBuf, Size);
}
diff --git a/contrib/llvm/tools/lld/ELF/InputSection.h b/contrib/llvm/tools/lld/ELF/InputSection.h
index fc7a7fb60973..3f3a055dcc33 100644
--- a/contrib/llvm/tools/lld/ELF/InputSection.h
+++ b/contrib/llvm/tools/lld/ELF/InputSection.h
@@ -138,22 +138,12 @@ public:
// section.
uintX_t getOffset(uintX_t Offset) const;
- // ELF supports ZLIB-compressed section.
- // Returns true if the section is compressed.
- bool isCompressed() const;
void uncompress();
// Returns a source location string. Used to construct an error message.
std::string getLocation(uintX_t Offset);
void relocate(uint8_t *Buf, uint8_t *BufEnd);
-
-private:
- std::pair<ArrayRef<uint8_t>, uint64_t>
- getElfCompressedData(ArrayRef<uint8_t> Data);
-
- std::pair<ArrayRef<uint8_t>, uint64_t>
- getRawCompressedData(ArrayRef<uint8_t> Data);
};
// SectionPiece represents a piece of splittable section contents.
diff --git a/contrib/llvm/tools/lld/ELF/LinkerScript.cpp b/contrib/llvm/tools/lld/ELF/LinkerScript.cpp
index 59ef36c87de5..887ca12537ad 100644
--- a/contrib/llvm/tools/lld/ELF/LinkerScript.cpp
+++ b/contrib/llvm/tools/lld/ELF/LinkerScript.cpp
@@ -1014,6 +1014,7 @@ private:
void readAnonymousDeclaration();
void readVersionDeclaration(StringRef VerStr);
std::vector<SymbolVersion> readSymbols();
+ void readLocals();
ScriptConfiguration &Opt = *ScriptConfig;
bool IsUnderSysroot;
@@ -1861,17 +1862,22 @@ void ScriptParser::readAnonymousDeclaration() {
if (consume("global:") || peek() != "local:")
Config->VersionScriptGlobals = readSymbols();
- // Next, read local symbols.
- if (consume("local:")) {
- if (consume("*")) {
+ readLocals();
+ expect("}");
+ expect(";");
+}
+
+void ScriptParser::readLocals() {
+ if (!consume("local:"))
+ return;
+ std::vector<SymbolVersion> Locals = readSymbols();
+ for (SymbolVersion V : Locals) {
+ if (V.Name == "*") {
Config->DefaultSymbolVersion = VER_NDX_LOCAL;
- expect(";");
- } else {
- setError("local symbol list for anonymous version is not supported");
+ continue;
}
+ Config->VersionScriptLocals.push_back(V);
}
- expect("}");
- expect(";");
}
// Reads a list of symbols, e.g. "VerStr { global: foo; bar; local: *; };".
@@ -1885,16 +1891,7 @@ void ScriptParser::readVersionDeclaration(StringRef VerStr) {
if (consume("global:") || peek() != "local:")
Config->VersionDefinitions.back().Globals = readSymbols();
- // Read local symbols.
- if (consume("local:")) {
- if (consume("*")) {
- Config->DefaultSymbolVersion = VER_NDX_LOCAL;
- expect(";");
- } else {
- for (SymbolVersion V : readSymbols())
- Config->VersionScriptLocals.push_back(V);
- }
- }
+ readLocals();
expect("}");
// Each version may have a parent version. For example, "Ver2"
diff --git a/contrib/llvm/tools/lld/ELF/OutputSections.cpp b/contrib/llvm/tools/lld/ELF/OutputSections.cpp
index a9d951dcc745..7c708ce4ed67 100644
--- a/contrib/llvm/tools/lld/ELF/OutputSections.cpp
+++ b/contrib/llvm/tools/lld/ELF/OutputSections.cpp
@@ -636,7 +636,12 @@ OutputSectionFactory<ELFT>::create(const SectionKey &Key,
if (getIncompatibleFlags(Sec->Flags) != getIncompatibleFlags(C->Flags))
error("Section has flags incompatible with others with the same name " +
toString(C));
- if (Sec->Type != C->Type)
+ // Convert notbits to progbits if they are mixed. This happens is some
+ // linker scripts.
+ if (Sec->Type == SHT_NOBITS && C->Type == SHT_PROGBITS)
+ Sec->Type = SHT_PROGBITS;
+ if (Sec->Type != C->Type &&
+ !(Sec->Type == SHT_PROGBITS && C->Type == SHT_NOBITS))
error("Section has different type from others with the same name " +
toString(C));
Sec->Flags |= Flags;
diff --git a/contrib/llvm/tools/lld/ELF/OutputSections.h b/contrib/llvm/tools/lld/ELF/OutputSections.h
index 45e1a232e2a9..5c494bba977a 100644
--- a/contrib/llvm/tools/lld/ELF/OutputSections.h
+++ b/contrib/llvm/tools/lld/ELF/OutputSections.h
@@ -206,6 +206,7 @@ template <class ELFT> struct Out {
static uint8_t First;
static EhOutputSection<ELFT> *EhFrame;
static OutputSection<ELFT> *Bss;
+ static OutputSection<ELFT> *BssRelRo;
static OutputSectionBase *Opd;
static uint8_t *OpdBuf;
static PhdrEntry *TlsPhdr;
@@ -252,6 +253,7 @@ template <class ELFT> uint64_t getHeaderSize() {
template <class ELFT> uint8_t Out<ELFT>::First;
template <class ELFT> EhOutputSection<ELFT> *Out<ELFT>::EhFrame;
template <class ELFT> OutputSection<ELFT> *Out<ELFT>::Bss;
+template <class ELFT> OutputSection<ELFT> *Out<ELFT>::BssRelRo;
template <class ELFT> OutputSectionBase *Out<ELFT>::Opd;
template <class ELFT> uint8_t *Out<ELFT>::OpdBuf;
template <class ELFT> PhdrEntry *Out<ELFT>::TlsPhdr;
diff --git a/contrib/llvm/tools/lld/ELF/Relocations.cpp b/contrib/llvm/tools/lld/ELF/Relocations.cpp
index f7dcc5d24e93..cecd11e90790 100644
--- a/contrib/llvm/tools/lld/ELF/Relocations.cpp
+++ b/contrib/llvm/tools/lld/ELF/Relocations.cpp
@@ -399,7 +399,21 @@ template <class ELFT> static uint32_t getAlignment(SharedSymbol<ELFT> *SS) {
return 1 << TrailingZeros;
}
-// Reserve space in .bss for copy relocation.
+template <class ELFT> static bool isReadOnly(SharedSymbol<ELFT> *SS) {
+ typedef typename ELFT::uint uintX_t;
+ typedef typename ELFT::Phdr Elf_Phdr;
+
+ // Determine if the symbol is read-only by scanning the DSO's program headers.
+ uintX_t Value = SS->Sym.st_value;
+ for (const Elf_Phdr &Phdr : check(SS->file()->getObj().program_headers()))
+ if ((Phdr.p_type == ELF::PT_LOAD || Phdr.p_type == ELF::PT_GNU_RELRO) &&
+ !(Phdr.p_flags & ELF::PF_W) && Value >= Phdr.p_vaddr &&
+ Value < Phdr.p_vaddr + Phdr.p_memsz)
+ return true;
+ return false;
+}
+
+// Reserve space in .bss or .bss.rel.ro for copy relocation.
template <class ELFT> static void addCopyRelSymbol(SharedSymbol<ELFT> *SS) {
typedef typename ELFT::uint uintX_t;
typedef typename ELFT::Sym Elf_Sym;
@@ -409,10 +423,16 @@ template <class ELFT> static void addCopyRelSymbol(SharedSymbol<ELFT> *SS) {
if (SymSize == 0)
fatal("cannot create a copy relocation for symbol " + toString(*SS));
+ // See if this symbol is in a read-only segment. If so, preserve the symbol's
+ // memory protection by reserving space in the .bss.rel.ro section.
+ bool IsReadOnly = isReadOnly(SS);
+ OutputSection<ELFT> *CopySec =
+ IsReadOnly ? Out<ELFT>::BssRelRo : Out<ELFT>::Bss;
+
uintX_t Alignment = getAlignment(SS);
- uintX_t Off = alignTo(Out<ELFT>::Bss->Size, Alignment);
- Out<ELFT>::Bss->Size = Off + SymSize;
- Out<ELFT>::Bss->updateAlignment(Alignment);
+ uintX_t Off = alignTo(CopySec->Size, Alignment);
+ CopySec->Size = Off + SymSize;
+ CopySec->updateAlignment(Alignment);
uintX_t Shndx = SS->Sym.st_shndx;
uintX_t Value = SS->Sym.st_value;
// Look through the DSO's dynamic symbol table for aliases and create a
@@ -425,12 +445,12 @@ template <class ELFT> static void addCopyRelSymbol(SharedSymbol<ELFT> *SS) {
Symtab<ELFT>::X->find(check(S.getName(SS->file()->getStringTable()))));
if (!Alias)
continue;
- Alias->OffsetInBss = Off;
+ Alias->CopyIsInBssRelRo = IsReadOnly;
+ Alias->CopyOffset = Off;
Alias->NeedsCopyOrPltAddr = true;
Alias->symbol()->IsUsedInRegularObj = true;
}
- In<ELFT>::RelaDyn->addReloc(
- {Target->CopyRel, Out<ELFT>::Bss, SS->OffsetInBss, false, SS, 0});
+ In<ELFT>::RelaDyn->addReloc({Target->CopyRel, CopySec, Off, false, SS, 0});
}
template <class ELFT>
diff --git a/contrib/llvm/tools/lld/ELF/SymbolTable.cpp b/contrib/llvm/tools/lld/ELF/SymbolTable.cpp
index f08fa6229c1a..6afe3dde9bab 100644
--- a/contrib/llvm/tools/lld/ELF/SymbolTable.cpp
+++ b/contrib/llvm/tools/lld/ELF/SymbolTable.cpp
@@ -605,19 +605,16 @@ SymbolTable<ELFT>::findAllByVersion(SymbolVersion Ver) {
// If there's only one anonymous version definition in a version
// script file, the script does not actually define any symbol version,
-// but just specifies symbols visibilities. We assume that the script was
-// in the form of { global: foo; bar; local *; }. So, local is default.
-// In this function, we make specified symbols global.
+// but just specifies symbols visibilities.
template <class ELFT> void SymbolTable<ELFT>::handleAnonymousVersion() {
- for (SymbolVersion &Ver : Config->VersionScriptGlobals) {
- if (Ver.HasWildcard) {
- for (SymbolBody *B : findAllByVersion(Ver))
- B->symbol()->VersionId = VER_NDX_GLOBAL;
- continue;
- }
- for (SymbolBody *B : findByVersion(Ver))
- B->symbol()->VersionId = VER_NDX_GLOBAL;
- }
+ for (SymbolVersion &Ver : Config->VersionScriptGlobals)
+ assignExactVersion(Ver, VER_NDX_GLOBAL, "global");
+ for (SymbolVersion &Ver : Config->VersionScriptGlobals)
+ assignWildcardVersion(Ver, VER_NDX_GLOBAL);
+ for (SymbolVersion &Ver : Config->VersionScriptLocals)
+ assignExactVersion(Ver, VER_NDX_LOCAL, "local");
+ for (SymbolVersion &Ver : Config->VersionScriptLocals)
+ assignWildcardVersion(Ver, VER_NDX_LOCAL);
}
// Set symbol versions to symbols. This function handles patterns
@@ -673,10 +670,7 @@ template <class ELFT> void SymbolTable<ELFT>::scanVersionScript() {
Sym->body()->parseSymbolVersion();
// Handle edge cases first.
- if (!Config->VersionScriptGlobals.empty()) {
- handleAnonymousVersion();
- return;
- }
+ handleAnonymousVersion();
if (Config->VersionDefinitions.empty())
return;
@@ -687,8 +681,6 @@ template <class ELFT> void SymbolTable<ELFT>::scanVersionScript() {
// First, we assign versions to exact matching symbols,
// i.e. version definitions not containing any glob meta-characters.
- for (SymbolVersion &Ver : Config->VersionScriptLocals)
- assignExactVersion(Ver, VER_NDX_LOCAL, "local");
for (VersionDefinition &V : Config->VersionDefinitions)
for (SymbolVersion &Ver : V.Globals)
assignExactVersion(Ver, V.Id, V.Name);
@@ -697,8 +689,6 @@ template <class ELFT> void SymbolTable<ELFT>::scanVersionScript() {
// i.e. version definitions containing glob meta-characters.
// Note that because the last match takes precedence over previous matches,
// we iterate over the definitions in the reverse order.
- for (SymbolVersion &Ver : Config->VersionScriptLocals)
- assignWildcardVersion(Ver, VER_NDX_LOCAL);
for (VersionDefinition &V : llvm::reverse(Config->VersionDefinitions))
for (SymbolVersion &Ver : V.Globals)
assignWildcardVersion(Ver, V.Id);
diff --git a/contrib/llvm/tools/lld/ELF/Symbols.cpp b/contrib/llvm/tools/lld/ELF/Symbols.cpp
index f3edafaf4b78..289bc18487a8 100644
--- a/contrib/llvm/tools/lld/ELF/Symbols.cpp
+++ b/contrib/llvm/tools/lld/ELF/Symbols.cpp
@@ -81,7 +81,7 @@ static typename ELFT::uint getSymVA(const SymbolBody &Body,
return 0;
if (SS.isFunc())
return Body.getPltVA<ELFT>();
- return Out<ELFT>::Bss->Addr + SS.OffsetInBss;
+ return SS.getBssSectionForCopy()->Addr + SS.CopyOffset;
}
case SymbolBody::UndefinedKind:
return 0;
@@ -97,7 +97,8 @@ SymbolBody::SymbolBody(Kind K, StringRefZ Name, bool IsLocal, uint8_t StOther,
uint8_t Type)
: SymbolKind(K), NeedsCopyOrPltAddr(false), IsLocal(IsLocal),
IsInGlobalMipsGot(false), Is32BitMipsGot(false), IsInIplt(false),
- IsInIgot(false), Type(Type), StOther(StOther), Name(Name) {}
+ IsInIgot(false), CopyIsInBssRelRo(false), Type(Type), StOther(StOther),
+ Name(Name) {}
// Returns true if a symbol can be replaced at load-time by a symbol
// with the same name defined in other ELF executable or DSO.
@@ -245,6 +246,12 @@ Undefined<ELFT>::Undefined(StringRefZ Name, bool IsLocal, uint8_t StOther,
this->File = File;
}
+template <typename ELFT>
+OutputSection<ELFT> *SharedSymbol<ELFT>::getBssSectionForCopy() const {
+ assert(needsCopy());
+ return CopyIsInBssRelRo ? Out<ELFT>::BssRelRo : Out<ELFT>::Bss;
+}
+
DefinedCommon::DefinedCommon(StringRef Name, uint64_t Size, uint64_t Alignment,
uint8_t StOther, uint8_t Type, InputFile *File)
: Defined(SymbolBody::DefinedCommonKind, Name, /*IsLocal=*/false, StOther,
@@ -287,10 +294,22 @@ InputFile *LazyObject::fetch() {
return createObjectFile(MBRef);
}
-bool Symbol::includeInDynsym() const {
+uint8_t Symbol::computeBinding() const {
+ if (Config->Relocatable)
+ return Binding;
if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED)
+ return STB_LOCAL;
+ if (VersionId == VER_NDX_LOCAL && !body()->isUndefined())
+ return STB_LOCAL;
+ if (Config->NoGnuUnique && Binding == STB_GNU_UNIQUE)
+ return STB_GLOBAL;
+ return Binding;
+}
+
+bool Symbol::includeInDynsym() const {
+ if (computeBinding() == STB_LOCAL)
return false;
- return (ExportDynamic && VersionId != VER_NDX_LOCAL) || body()->isShared() ||
+ return ExportDynamic || body()->isShared() ||
(body()->isUndefined() && Config->Shared);
}
@@ -366,6 +385,11 @@ template class elf::Undefined<ELF32BE>;
template class elf::Undefined<ELF64LE>;
template class elf::Undefined<ELF64BE>;
+template class elf::SharedSymbol<ELF32LE>;
+template class elf::SharedSymbol<ELF32BE>;
+template class elf::SharedSymbol<ELF64LE>;
+template class elf::SharedSymbol<ELF64BE>;
+
template class elf::DefinedRegular<ELF32LE>;
template class elf::DefinedRegular<ELF32BE>;
template class elf::DefinedRegular<ELF64LE>;
diff --git a/contrib/llvm/tools/lld/ELF/Symbols.h b/contrib/llvm/tools/lld/ELF/Symbols.h
index 38889571679c..af85dc2b121d 100644
--- a/contrib/llvm/tools/lld/ELF/Symbols.h
+++ b/contrib/llvm/tools/lld/ELF/Symbols.h
@@ -123,6 +123,11 @@ public:
// True if this symbol is in the Igot sub-section of the .got.plt or .got.
unsigned IsInIgot : 1;
+ // True if this is a shared symbol in a read-only segment which requires a
+ // copy relocation. This causes space for the symbol to be allocated in the
+ // .bss.rel.ro section.
+ unsigned CopyIsInBssRelRo : 1;
+
// The following fields have the same meaning as the ELF symbol attributes.
uint8_t Type; // symbol type
uint8_t StOther; // st_other field value
@@ -282,13 +287,15 @@ public:
// This field is a pointer to the symbol's version definition.
const Elf_Verdef *Verdef;
- // OffsetInBss is significant only when needsCopy() is true.
- uintX_t OffsetInBss = 0;
+ // CopyOffset is significant only when needsCopy() is true.
+ uintX_t CopyOffset = 0;
// If non-null the symbol has a Thunk that may be used as an alternative
// destination for callers of this Symbol.
Thunk<ELFT> *ThunkData = nullptr;
bool needsCopy() const { return this->NeedsCopyOrPltAddr && !this->isFunc(); }
+
+ OutputSection<ELFT> *getBssSectionForCopy() const;
};
// This class represents a symbol defined in an archive file. It is
@@ -413,6 +420,7 @@ struct Symbol {
unsigned InVersionScript : 1;
bool includeInDynsym() const;
+ uint8_t computeBinding() const;
bool isWeak() const { return Binding == llvm::ELF::STB_WEAK; }
// This field is used to store the Symbol's SymbolBody. This instantiation of
diff --git a/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp b/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp
index 3c8a439ba308..5486b38eec10 100644
--- a/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp
+++ b/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp
@@ -1060,18 +1060,6 @@ static bool sortMipsSymbols(const SymbolBody *L, const SymbolBody *R) {
return L->GotIndex < R->GotIndex;
}
-static uint8_t getSymbolBinding(SymbolBody *Body) {
- Symbol *S = Body->symbol();
- if (Config->Relocatable)
- return S->Binding;
- uint8_t Visibility = S->Visibility;
- if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED)
- return STB_LOCAL;
- if (Config->NoGnuUnique && S->Binding == STB_GNU_UNIQUE)
- return STB_GLOBAL;
- return S->Binding;
-}
-
template <class ELFT> void SymbolTableSection<ELFT>::finalize() {
this->OutSec->Link = this->Link = StrTabSec.OutSec->SectionIndex;
this->OutSec->Info = this->Info = NumLocals + 1;
@@ -1085,11 +1073,12 @@ template <class ELFT> void SymbolTableSection<ELFT>::finalize() {
}
if (!StrTabSec.isDynamic()) {
- std::stable_sort(Symbols.begin(), Symbols.end(),
- [](const SymbolTableEntry &L, const SymbolTableEntry &R) {
- return getSymbolBinding(L.Symbol) == STB_LOCAL &&
- getSymbolBinding(R.Symbol) != STB_LOCAL;
- });
+ std::stable_sort(
+ Symbols.begin(), Symbols.end(),
+ [](const SymbolTableEntry &L, const SymbolTableEntry &R) {
+ return L.Symbol->symbol()->computeBinding() == STB_LOCAL &&
+ R.Symbol->symbol()->computeBinding() != STB_LOCAL;
+ });
return;
}
if (In<ELFT>::GnuHashTab)
@@ -1159,7 +1148,7 @@ void SymbolTableSection<ELFT>::writeGlobalSymbols(uint8_t *Buf) {
uint8_t Type = Body->Type;
uintX_t Size = Body->getSize<ELFT>();
- ESym->setBindingAndType(getSymbolBinding(Body), Type);
+ ESym->setBindingAndType(Body->symbol()->computeBinding(), Type);
ESym->st_size = Size;
ESym->st_name = StrOff;
ESym->setVisibility(Body->symbol()->Visibility);
@@ -1201,10 +1190,12 @@ SymbolTableSection<ELFT>::getOutputSection(SymbolBody *Sym) {
}
case SymbolBody::DefinedCommonKind:
return In<ELFT>::Common->OutSec;
- case SymbolBody::SharedKind:
- if (cast<SharedSymbol<ELFT>>(Sym)->needsCopy())
- return Out<ELFT>::Bss;
+ case SymbolBody::SharedKind: {
+ auto &SS = cast<SharedSymbol<ELFT>>(*Sym);
+ if (SS.needsCopy())
+ return SS.getBssSectionForCopy();
break;
+ }
case SymbolBody::UndefinedKind:
case SymbolBody::LazyArchiveKind:
case SymbolBody::LazyObjectKind:
diff --git a/contrib/llvm/tools/lld/ELF/Target.cpp b/contrib/llvm/tools/lld/ELF/Target.cpp
index cb2b178fa849..55fcf1734d1f 100644
--- a/contrib/llvm/tools/lld/ELF/Target.cpp
+++ b/contrib/llvm/tools/lld/ELF/Target.cpp
@@ -356,7 +356,9 @@ X86TargetInfo::X86TargetInfo() {
RelExpr X86TargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const {
switch (Type) {
- default:
+ case R_386_16:
+ case R_386_32:
+ case R_386_TLS_LDO_32:
return R_ABS;
case R_386_TLS_GD:
return R_TLSGD;
@@ -381,6 +383,12 @@ RelExpr X86TargetInfo::getRelExpr(uint32_t Type, const SymbolBody &S) const {
return R_TLS;
case R_386_TLS_LE_32:
return R_NEG_TLS;
+ case R_386_NONE:
+ return R_HINT;
+ default:
+ error("do not know how to handle relocation '" + toString(Type) + "' (" +
+ Twine(Type) + ")");
+ return R_HINT;
}
}
@@ -623,7 +631,11 @@ template <class ELFT>
RelExpr X86_64TargetInfo<ELFT>::getRelExpr(uint32_t Type,
const SymbolBody &S) const {
switch (Type) {
- default:
+ case R_X86_64_32:
+ case R_X86_64_32S:
+ case R_X86_64_64:
+ case R_X86_64_DTPOFF32:
+ case R_X86_64_DTPOFF64:
return R_ABS;
case R_X86_64_TPOFF32:
return R_TLS;
@@ -649,6 +661,10 @@ RelExpr X86_64TargetInfo<ELFT>::getRelExpr(uint32_t Type,
return R_GOT_PC;
case R_X86_64_NONE:
return R_HINT;
+ default:
+ error("do not know how to handle relocation '" + toString(Type) + "' (" +
+ Twine(Type) + ")");
+ return R_HINT;
}
}
@@ -870,7 +886,7 @@ void X86_64TargetInfo<ELFT>::relocateOne(uint8_t *Loc, uint32_t Type,
write64le(Loc, Val);
break;
default:
- error(getErrorLocation(Loc) + "unrecognized reloc " + Twine(Type));
+ llvm_unreachable("unexpected relocation");
}
}
diff --git a/contrib/llvm/tools/lld/ELF/Writer.cpp b/contrib/llvm/tools/lld/ELF/Writer.cpp
index 154de8cf6d18..bddc42e1acf9 100644
--- a/contrib/llvm/tools/lld/ELF/Writer.cpp
+++ b/contrib/llvm/tools/lld/ELF/Writer.cpp
@@ -250,6 +250,8 @@ template <class ELFT> void Writer<ELFT>::createSyntheticSections() {
// Create singleton output sections.
Out<ELFT>::Bss =
make<OutputSection<ELFT>>(".bss", SHT_NOBITS, SHF_ALLOC | SHF_WRITE);
+ Out<ELFT>::BssRelRo = make<OutputSection<ELFT>>(".bss.rel.ro", SHT_NOBITS,
+ SHF_ALLOC | SHF_WRITE);
In<ELFT>::DynStrTab = make<StringTableSection<ELFT>>(".dynstr", true);
In<ELFT>::Dynamic = make<DynamicSection<ELFT>>();
Out<ELFT>::EhFrame = make<EhOutputSection<ELFT>>();
@@ -498,6 +500,8 @@ template <class ELFT> bool elf::isRelroSection(const OutputSectionBase *Sec) {
return true;
if (In<ELFT>::MipsGot && Sec == In<ELFT>::MipsGot->OutSec)
return true;
+ if (Sec == Out<ELFT>::BssRelRo)
+ return true;
StringRef S = Sec->getName();
return S == ".data.rel.ro" || S == ".ctors" || S == ".dtors" || S == ".jcr" ||
S == ".eh_frame" || S == ".openbsd.randomdata";
@@ -557,30 +561,38 @@ static bool compareSectionsNonScript(const OutputSectionBase *A,
// If we got here we know that both A and B are in the same PT_LOAD.
- // The TLS initialization block needs to be a single contiguous block in a R/W
- // PT_LOAD, so stick TLS sections directly before R/W sections. The TLS NOBITS
- // sections are placed here as they don't take up virtual address space in the
- // PT_LOAD.
bool AIsTls = A->Flags & SHF_TLS;
bool BIsTls = B->Flags & SHF_TLS;
- if (AIsTls != BIsTls)
- return AIsTls;
-
- // The next requirement we have is to put nobits sections last. The
- // reason is that the only thing the dynamic linker will see about
- // them is a p_memsz that is larger than p_filesz. Seeing that it
- // zeros the end of the PT_LOAD, so that has to correspond to the
- // nobits sections.
bool AIsNoBits = A->Type == SHT_NOBITS;
bool BIsNoBits = B->Type == SHT_NOBITS;
- if (AIsNoBits != BIsNoBits)
- return BIsNoBits;
- // We place RelRo section before plain r/w ones.
+ // The first requirement we have is to put (non-TLS) nobits sections last. The
+ // reason is that the only thing the dynamic linker will see about them is a
+ // p_memsz that is larger than p_filesz. Seeing that it zeros the end of the
+ // PT_LOAD, so that has to correspond to the nobits sections.
+ bool AIsNonTlsNoBits = AIsNoBits && !AIsTls;
+ bool BIsNonTlsNoBits = BIsNoBits && !BIsTls;
+ if (AIsNonTlsNoBits != BIsNonTlsNoBits)
+ return BIsNonTlsNoBits;
+
+ // We place nobits RelRo sections before plain r/w ones, and non-nobits RelRo
+ // sections after r/w ones, so that the RelRo sections are contiguous.
bool AIsRelRo = isRelroSection<ELFT>(A);
bool BIsRelRo = isRelroSection<ELFT>(B);
if (AIsRelRo != BIsRelRo)
- return AIsRelRo;
+ return AIsNonTlsNoBits ? AIsRelRo : BIsRelRo;
+
+ // The TLS initialization block needs to be a single contiguous block in a R/W
+ // PT_LOAD, so stick TLS sections directly before the other RelRo R/W
+ // sections. The TLS NOBITS sections are placed here as they don't take up
+ // virtual address space in the PT_LOAD.
+ if (AIsTls != BIsTls)
+ return AIsTls;
+
+ // Within the TLS initialization block, the non-nobits sections need to appear
+ // first.
+ if (AIsNoBits != BIsNoBits)
+ return BIsNoBits;
// Some architectures have additional ordering restrictions for sections
// within the same PT_LOAD.
@@ -1071,6 +1083,8 @@ template <class ELFT> void Writer<ELFT>::finalizeSections() {
template <class ELFT> void Writer<ELFT>::addPredefinedSections() {
if (Out<ELFT>::Bss->Size > 0)
OutputSections.push_back(Out<ELFT>::Bss);
+ if (Out<ELFT>::BssRelRo->Size > 0)
+ OutputSections.push_back(Out<ELFT>::BssRelRo);
auto OS = dyn_cast_or_null<OutputSection<ELFT>>(findSection(".ARM.exidx"));
if (OS && !OS->Sections.empty() && !Config->Relocatable)
@@ -1272,8 +1286,9 @@ void Writer<ELFT>::addPtArmExid(std::vector<PhdrEntry> &Phdrs) {
Phdrs.push_back(ARMExidx);
}
-// The first section of each PT_LOAD and the first section after PT_GNU_RELRO
-// have to be page aligned so that the dynamic linker can set the permissions.
+// The first section of each PT_LOAD, the first section in PT_GNU_RELRO and the
+// first section after PT_GNU_RELRO have to be page aligned so that the dynamic
+// linker can set the permissions.
template <class ELFT> void Writer<ELFT>::fixSectionAlignments() {
for (const PhdrEntry &P : Phdrs)
if (P.p_type == PT_LOAD && P.First)
@@ -1282,6 +1297,8 @@ template <class ELFT> void Writer<ELFT>::fixSectionAlignments() {
for (const PhdrEntry &P : Phdrs) {
if (P.p_type != PT_GNU_RELRO)
continue;
+ if (P.First)
+ P.First->PageAlign = true;
// Find the first section after PT_GNU_RELRO. If it is in a PT_LOAD we
// have to align it to a page.
auto End = OutputSections.end();
@@ -1635,10 +1652,12 @@ static void unlinkAsync(StringRef Path) {
// Path as a new file. If we do that in a different thread, the new
// thread can remove the new file.
SmallString<128> TempPath;
- if (auto EC = sys::fs::createUniqueFile(Path + "tmp%%%%%%%%", TempPath))
- fatal(EC, "createUniqueFile failed");
- if (auto EC = sys::fs::rename(Path, TempPath))
- fatal(EC, "rename failed");
+ if (sys::fs::createUniqueFile(Path + "tmp%%%%%%%%", TempPath))
+ return;
+ if (sys::fs::rename(Path, TempPath)) {
+ sys::fs::remove(TempPath);
+ return;
+ }
// Remove TempPath in background.
std::thread([=] { ::remove(TempPath.str().str().c_str()); }).detach();
diff --git a/contrib/llvm/tools/lldb/include/lldb/Core/Error.h b/contrib/llvm/tools/lldb/include/lldb/Core/Error.h
index f33464816a16..8131580991ad 100644
--- a/contrib/llvm/tools/lldb/include/lldb/Core/Error.h
+++ b/contrib/llvm/tools/lldb/include/lldb/Core/Error.h
@@ -12,6 +12,7 @@
#if defined(__cplusplus)
#include "llvm/Support/DataTypes.h"
+#include "llvm/Support/FormatVariadic.h"
#include <cstdarg>
#include <cstdio>
@@ -300,5 +301,15 @@ protected:
} // namespace lldb_private
+namespace llvm {
+template <> struct format_provider<lldb_private::Error> {
+ static void format(const lldb_private::Error &error, llvm::raw_ostream &OS,
+ llvm::StringRef Options) {
+ llvm::format_provider<llvm::StringRef>::format(error.AsCString(), OS,
+ Options);
+ }
+};
+}
+
#endif // #if defined(__cplusplus)
#endif // #ifndef __DCError_h__
diff --git a/contrib/llvm/tools/lldb/include/lldb/Symbol/Type.h b/contrib/llvm/tools/lldb/include/lldb/Symbol/Type.h
index 13c95e71ffeb..b2a65fabf8f9 100644
--- a/contrib/llvm/tools/lldb/include/lldb/Symbol/Type.h
+++ b/contrib/llvm/tools/lldb/include/lldb/Symbol/Type.h
@@ -201,8 +201,9 @@ public:
// From a fully qualified typename, split the type into the type basename
// and the remaining type scope (namespaces/classes).
- static bool GetTypeScopeAndBasename(const char *&name_cstr,
- std::string &scope, std::string &basename,
+ static bool GetTypeScopeAndBasename(const llvm::StringRef& name,
+ llvm::StringRef &scope,
+ llvm::StringRef &basename,
lldb::TypeClass &type_class);
void SetEncodingType(Type *encoding_type) { m_encoding_type = encoding_type; }
diff --git a/contrib/llvm/tools/lldb/source/Core/Module.cpp b/contrib/llvm/tools/lldb/source/Core/Module.cpp
index 220773b5ad40..28f140b41e1e 100644
--- a/contrib/llvm/tools/lldb/source/Core/Module.cpp
+++ b/contrib/llvm/tools/lldb/source/Core/Module.cpp
@@ -995,8 +995,8 @@ size_t Module::FindTypes(
TypeList &types) {
size_t num_matches = 0;
const char *type_name_cstr = name.GetCString();
- std::string type_scope;
- std::string type_basename;
+ llvm::StringRef type_scope;
+ llvm::StringRef type_basename;
const bool append = true;
TypeClass type_class = eTypeClassAny;
TypeMap typesmap;
@@ -1006,13 +1006,9 @@ size_t Module::FindTypes(
// from the root namespace and implies and exact match. The typenames we
// get back from clang do not start with "::" so we need to strip this off
// in order to get the qualified names to match
+ exact_match = type_scope.consume_front("::");
- if (type_scope.size() >= 2 && type_scope[0] == ':' &&
- type_scope[1] == ':') {
- type_scope.erase(0, 2);
- exact_match = true;
- }
- ConstString type_basename_const_str(type_basename.c_str());
+ ConstString type_basename_const_str(type_basename);
if (FindTypes_Impl(sc, type_basename_const_str, nullptr, append,
max_matches, searched_symbol_files, typesmap)) {
typesmap.RemoveMismatchedTypes(type_scope, type_basename, type_class,
diff --git a/contrib/llvm/tools/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp b/contrib/llvm/tools/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index f8539379f7da..f60587ed2fff 100644
--- a/contrib/llvm/tools/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/contrib/llvm/tools/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -346,8 +346,7 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body,
ExprResult address_of_expr =
m_sema->CreateBuiltinUnaryOp(SourceLocation(), UO_AddrOf, last_expr);
if (address_of_expr.get())
- m_sema->AddInitializerToDecl(result_decl, address_of_expr.get(), true,
- false);
+ m_sema->AddInitializerToDecl(result_decl, address_of_expr.get(), true);
else
return false;
} else {
@@ -359,7 +358,7 @@ bool ASTResultSynthesizer::SynthesizeBodyResult(CompoundStmt *Body,
if (!result_decl)
return false;
- m_sema->AddInitializerToDecl(result_decl, last_expr, true, false);
+ m_sema->AddInitializerToDecl(result_decl, last_expr, true);
}
DC->addDecl(result_decl);
diff --git a/contrib/llvm/tools/lldb/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp b/contrib/llvm/tools/lldb/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
index 3010724306e4..d8a46e5d4550 100644
--- a/contrib/llvm/tools/lldb/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
+++ b/contrib/llvm/tools/lldb/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
@@ -206,7 +206,8 @@ CreateStackTrace(ValueObjectSP o,
StructuredData::Array *trace = new StructuredData::Array();
ValueObjectSP trace_value_object =
o->GetValueForExpressionPath(trace_item_name.c_str());
- for (int j = 0; j < 8; j++) {
+ size_t count = trace_value_object->GetNumChildren();
+ for (size_t j = 0; j < count; j++) {
addr_t trace_addr =
trace_value_object->GetChildAtIndex(j, true)->GetValueAsUnsigned(0);
if (trace_addr == 0)
diff --git a/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp b/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp
index 36ca37366d7f..c0d974530f90 100644
--- a/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp
+++ b/contrib/llvm/tools/lldb/source/Symbol/ClangASTContext.cpp
@@ -1528,8 +1528,7 @@ ClassTemplateDecl *ClangASTContext::CreateClassTemplateDecl(
*ast,
decl_ctx, // What decl context do we use here? TU? The actual decl
// context?
- SourceLocation(), decl_name, template_param_list, template_cxx_decl,
- nullptr);
+ SourceLocation(), decl_name, template_param_list, template_cxx_decl);
if (class_template_decl) {
if (access_type != eAccessNone)
diff --git a/contrib/llvm/tools/lldb/source/Symbol/Type.cpp b/contrib/llvm/tools/lldb/source/Symbol/Type.cpp
index 2df193fa45e5..80d08bf742fc 100644
--- a/contrib/llvm/tools/lldb/source/Symbol/Type.cpp
+++ b/contrib/llvm/tools/lldb/source/Symbol/Type.cpp
@@ -620,50 +620,59 @@ ConstString Type::GetQualifiedName() {
return GetForwardCompilerType().GetConstTypeName();
}
-bool Type::GetTypeScopeAndBasename(const char *&name_cstr, std::string &scope,
- std::string &basename,
+bool Type::GetTypeScopeAndBasename(const llvm::StringRef& name,
+ llvm::StringRef &scope,
+ llvm::StringRef &basename,
TypeClass &type_class) {
- // Protect against null c string.
-
type_class = eTypeClassAny;
- if (name_cstr && name_cstr[0]) {
- llvm::StringRef name_strref(name_cstr);
- if (name_strref.startswith("struct ")) {
- name_cstr += 7;
- type_class = eTypeClassStruct;
- } else if (name_strref.startswith("class ")) {
- name_cstr += 6;
- type_class = eTypeClassClass;
- } else if (name_strref.startswith("union ")) {
- name_cstr += 6;
- type_class = eTypeClassUnion;
- } else if (name_strref.startswith("enum ")) {
- name_cstr += 5;
- type_class = eTypeClassEnumeration;
- } else if (name_strref.startswith("typedef ")) {
- name_cstr += 8;
- type_class = eTypeClassTypedef;
- }
- const char *basename_cstr = name_cstr;
- const char *namespace_separator = ::strstr(basename_cstr, "::");
- if (namespace_separator) {
- const char *template_arg_char = ::strchr(basename_cstr, '<');
- while (namespace_separator != nullptr) {
- if (template_arg_char &&
- namespace_separator > template_arg_char) // but namespace'd template
- // arguments are still good
- // to go
- break;
- basename_cstr = namespace_separator + 2;
- namespace_separator = strstr(basename_cstr, "::");
- }
- if (basename_cstr > name_cstr) {
- scope.assign(name_cstr, basename_cstr - name_cstr);
- basename.assign(basename_cstr);
- return true;
+ if (name.empty())
+ return false;
+
+ basename = name;
+ if (basename.consume_front("struct "))
+ type_class = eTypeClassStruct;
+ else if (basename.consume_front("class "))
+ type_class = eTypeClassClass;
+ else if (basename.consume_front("union "))
+ type_class = eTypeClassUnion;
+ else if (basename.consume_front("enum "))
+ type_class = eTypeClassEnumeration;
+ else if (basename.consume_front("typedef "))
+ type_class = eTypeClassTypedef;
+
+ size_t namespace_separator = basename.find("::");
+ if (namespace_separator == llvm::StringRef::npos)
+ return false;
+
+ size_t template_begin = basename.find('<');
+ while (namespace_separator != llvm::StringRef::npos) {
+ if (template_begin != llvm::StringRef::npos &&
+ namespace_separator > template_begin) {
+ size_t template_depth = 1;
+ llvm::StringRef template_arg =
+ basename.drop_front(template_begin + 1);
+ while (template_depth > 0 && !template_arg.empty()) {
+ if (template_arg.front() == '<')
+ template_depth++;
+ else if (template_arg.front() == '>')
+ template_depth--;
+ template_arg = template_arg.drop_front(1);
}
+ if (template_depth != 0)
+ return false; // We have an invalid type name. Bail out.
+ if (template_arg.empty())
+ break; // The template ends at the end of the full name.
+ basename = template_arg;
+ } else {
+ basename = basename.drop_front(namespace_separator + 2);
}
+ template_begin = basename.find('<');
+ namespace_separator = basename.find("::");
+ }
+ if (basename.size() < name.size()) {
+ scope = name.take_front(name.size() - basename.size());
+ return true;
}
return false;
}
diff --git a/contrib/llvm/tools/lldb/source/Symbol/TypeList.cpp b/contrib/llvm/tools/lldb/source/Symbol/TypeList.cpp
index 4d32afcb0516..4fcaff3daf90 100644
--- a/contrib/llvm/tools/lldb/source/Symbol/TypeList.cpp
+++ b/contrib/llvm/tools/lldb/source/Symbol/TypeList.cpp
@@ -108,13 +108,13 @@ void TypeList::Dump(Stream *s, bool show_context) {
void TypeList::RemoveMismatchedTypes(const char *qualified_typename,
bool exact_match) {
- std::string type_scope;
- std::string type_basename;
+ llvm::StringRef type_scope;
+ llvm::StringRef type_basename;
TypeClass type_class = eTypeClassAny;
if (!Type::GetTypeScopeAndBasename(qualified_typename, type_scope,
type_basename, type_class)) {
type_basename = qualified_typename;
- type_scope.clear();
+ type_scope = "";
}
return RemoveMismatchedTypes(type_scope, type_basename, type_class,
exact_match);
@@ -145,8 +145,8 @@ void TypeList::RemoveMismatchedTypes(const std::string &type_scope,
ConstString match_type_name_const_str(the_type->GetQualifiedName());
if (match_type_name_const_str) {
const char *match_type_name = match_type_name_const_str.GetCString();
- std::string match_type_scope;
- std::string match_type_basename;
+ llvm::StringRef match_type_scope;
+ llvm::StringRef match_type_basename;
if (Type::GetTypeScopeAndBasename(match_type_name, match_type_scope,
match_type_basename,
match_type_class)) {
diff --git a/contrib/llvm/tools/lldb/source/Symbol/TypeMap.cpp b/contrib/llvm/tools/lldb/source/Symbol/TypeMap.cpp
index 21eb611e7b86..40c6558d5825 100644
--- a/contrib/llvm/tools/lldb/source/Symbol/TypeMap.cpp
+++ b/contrib/llvm/tools/lldb/source/Symbol/TypeMap.cpp
@@ -152,13 +152,13 @@ void TypeMap::Dump(Stream *s, bool show_context) {
void TypeMap::RemoveMismatchedTypes(const char *qualified_typename,
bool exact_match) {
- std::string type_scope;
- std::string type_basename;
+ llvm::StringRef type_scope;
+ llvm::StringRef type_basename;
TypeClass type_class = eTypeClassAny;
if (!Type::GetTypeScopeAndBasename(qualified_typename, type_scope,
type_basename, type_class)) {
type_basename = qualified_typename;
- type_scope.clear();
+ type_scope = "";
}
return RemoveMismatchedTypes(type_scope, type_basename, type_class,
exact_match);
@@ -189,8 +189,8 @@ void TypeMap::RemoveMismatchedTypes(const std::string &type_scope,
ConstString match_type_name_const_str(the_type->GetQualifiedName());
if (match_type_name_const_str) {
const char *match_type_name = match_type_name_const_str.GetCString();
- std::string match_type_scope;
- std::string match_type_basename;
+ llvm::StringRef match_type_scope;
+ llvm::StringRef match_type_basename;
if (Type::GetTypeScopeAndBasename(match_type_name, match_type_scope,
match_type_basename,
match_type_class)) {
diff --git a/contrib/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp b/contrib/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
index 98c67ec9ef3b..629ba40b113c 100644
--- a/contrib/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
+++ b/contrib/llvm/tools/llvm-pdbdump/LLVMOutputStyle.cpp
@@ -10,9 +10,15 @@
#include "LLVMOutputStyle.h"
#include "llvm-pdbdump.h"
+#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
+#include "llvm/DebugInfo/CodeView/CVTypeVisitor.h"
#include "llvm/DebugInfo/CodeView/EnumTables.h"
#include "llvm/DebugInfo/CodeView/ModuleSubstreamVisitor.h"
#include "llvm/DebugInfo/CodeView/SymbolDumper.h"
+#include "llvm/DebugInfo/CodeView/TypeDatabaseVisitor.h"
+#include "llvm/DebugInfo/CodeView/TypeDeserializer.h"
+#include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h"
+#include "llvm/DebugInfo/CodeView/TypeVisitorCallbackPipeline.h"
#include "llvm/DebugInfo/MSF/MappedBlockStream.h"
#include "llvm/DebugInfo/MSF/StreamReader.h"
#include "llvm/DebugInfo/PDB/PDBExtras.h"
@@ -83,8 +89,7 @@ static void printSectionOffset(llvm::raw_ostream &OS,
OS << Off.Off << ", " << Off.Isect;
}
-LLVMOutputStyle::LLVMOutputStyle(PDBFile &File)
- : File(File), P(outs()), Dumper(&P, false) {}
+LLVMOutputStyle::LLVMOutputStyle(PDBFile &File) : File(File), P(outs()) {}
Error LLVMOutputStyle::dump() {
if (auto EC = dumpFileHeaders())
@@ -519,6 +524,7 @@ Error LLVMOutputStyle::dumpTpiStream(uint32_t StreamIdx) {
if (!Tpi)
return Tpi.takeError();
+ CVTypeDumper Dumper(TypeDB);
if (DumpRecords || DumpRecordBytes) {
DictScope D(P, Label);
@@ -532,7 +538,8 @@ Error LLVMOutputStyle::dumpTpiStream(uint32_t StreamIdx) {
DictScope DD(P, "");
if (DumpRecords) {
- if (auto EC = Dumper.dump(Type))
+ TypeDumpVisitor TDV(TypeDB, &P, false);
+ if (auto EC = Dumper.dump(Type, TDV))
return EC;
}
@@ -545,19 +552,23 @@ Error LLVMOutputStyle::dumpTpiStream(uint32_t StreamIdx) {
"TPI stream contained corrupt record");
} else if (opts::raw::DumpModuleSyms) {
// Even if the user doesn't want to dump type records, we still need to
- // iterate them in order to build the list of types so that we can print
- // them when dumping module symbols. So when they want to dump symbols
- // but not types, use a null output stream.
- ScopedPrinter *OldP = Dumper.getPrinter();
- Dumper.setPrinter(nullptr);
+ // iterate them in order to build the type database. So when they want to
+ // dump symbols but not types, don't stick a dumper on the end, just build
+ // the type database.
+ TypeDatabaseVisitor DBV(TypeDB);
+ TypeDeserializer Deserializer;
+ TypeVisitorCallbackPipeline Pipeline;
+ Pipeline.addCallbackToPipeline(Deserializer);
+ Pipeline.addCallbackToPipeline(DBV);
+
+ CVTypeVisitor Visitor(Pipeline);
bool HadError = false;
- for (auto &Type : Tpi->types(&HadError)) {
- if (auto EC = Dumper.dump(Type))
+ for (auto Type : Tpi->types(&HadError)) {
+ if (auto EC = Visitor.visitTypeRecord(Type))
return EC;
}
- Dumper.setPrinter(OldP);
dumpTpiHash(P, *Tpi);
if (HadError)
return make_error<RawError>(raw_error_code::corrupt_file,
@@ -640,7 +651,7 @@ Error LLVMOutputStyle::dumpDbiStream() {
if (ShouldDumpSymbols) {
ListScope SS(P, "Symbols");
- codeview::CVSymbolDumper SD(P, Dumper, nullptr, false);
+ codeview::CVSymbolDumper SD(P, TypeDB, nullptr, false);
bool HadError = false;
for (auto S : ModS.symbols(&HadError)) {
DictScope LL(P, "");
@@ -865,7 +876,7 @@ Error LLVMOutputStyle::dumpPublicsStream() {
P.printList("Section Offsets", Publics->getSectionOffsets(),
printSectionOffset);
ListScope L(P, "Symbols");
- codeview::CVSymbolDumper SD(P, Dumper, nullptr, false);
+ codeview::CVSymbolDumper SD(P, TypeDB, nullptr, false);
bool HadError = false;
for (auto S : Publics->getSymbols(&HadError)) {
DictScope DD(P, "");
diff --git a/contrib/llvm/tools/llvm-pdbdump/LLVMOutputStyle.h b/contrib/llvm/tools/llvm-pdbdump/LLVMOutputStyle.h
index 72a3fd4aba5c..816d591f08f8 100644
--- a/contrib/llvm/tools/llvm-pdbdump/LLVMOutputStyle.h
+++ b/contrib/llvm/tools/llvm-pdbdump/LLVMOutputStyle.h
@@ -12,7 +12,7 @@
#include "OutputStyle.h"
-#include "llvm/DebugInfo/CodeView/TypeDumper.h"
+#include "llvm/DebugInfo/CodeView/TypeDatabase.h"
#include "llvm/Support/ScopedPrinter.h"
namespace llvm {
@@ -49,7 +49,7 @@ private:
PDBFile &File;
ScopedPrinter P;
- codeview::CVTypeDumper Dumper;
+ codeview::TypeDatabase TypeDB;
std::vector<std::string> StreamPurposes;
};
}
diff --git a/contrib/llvm/tools/llvm-pdbdump/BuiltinDumper.cpp b/contrib/llvm/tools/llvm-pdbdump/PrettyBuiltinDumper.cpp
index 2ce1a7839110..f866132aa886 100644
--- a/contrib/llvm/tools/llvm-pdbdump/BuiltinDumper.cpp
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyBuiltinDumper.cpp
@@ -1,4 +1,4 @@
-//===- BuiltinDumper.cpp ---------------------------------------- *- C++ *-===//
+//===- PrettyBuiltinDumper.cpp ---------------------------------- *- C++ *-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "BuiltinDumper.h"
+#include "PrettyBuiltinDumper.h"
#include "LinePrinter.h"
#include "llvm-pdbdump.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/BuiltinDumper.h b/contrib/llvm/tools/llvm-pdbdump/PrettyBuiltinDumper.h
index 7a2f1438669c..fb6b0b172e6e 100644
--- a/contrib/llvm/tools/llvm-pdbdump/BuiltinDumper.h
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyBuiltinDumper.h
@@ -1,4 +1,4 @@
-//===- BuiltinDumper.h ---------------------------------------- *- C++ --*-===//
+//===- PrettyBuiltinDumper.h ---------------------------------- *- C++ --*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_BUILTINDUMPER_H
-#define LLVM_TOOLS_LLVMPDBDUMP_BUILTINDUMPER_H
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYBUILTINDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_PRETTYBUILTINDUMPER_H
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/ClassDefinitionDumper.cpp b/contrib/llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.cpp
index 553bc0b267c2..b0c534f7c5b1 100644
--- a/contrib/llvm/tools/llvm-pdbdump/ClassDefinitionDumper.cpp
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.cpp
@@ -1,4 +1,4 @@
-//===- ClassDefinitionDumper.cpp --------------------------------*- C++ -*-===//
+//===- PrettyClassDefinitionDumper.cpp --------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,13 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "ClassDefinitionDumper.h"
-#include "EnumDumper.h"
-#include "FunctionDumper.h"
+#include "PrettyClassDefinitionDumper.h"
+
#include "LinePrinter.h"
+#include "PrettyEnumDumper.h"
+#include "PrettyFunctionDumper.h"
+#include "PrettyTypedefDumper.h"
+#include "PrettyVariableDumper.h"
#include "llvm-pdbdump.h"
-#include "TypedefDumper.h"
-#include "VariableDumper.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
#include "llvm/DebugInfo/PDB/PDBExtras.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/ClassDefinitionDumper.h b/contrib/llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.h
index 304e11dcb6c9..0831f47557ed 100644
--- a/contrib/llvm/tools/llvm-pdbdump/ClassDefinitionDumper.h
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyClassDefinitionDumper.h
@@ -1,4 +1,4 @@
-//===- ClassDefinitionDumper.h - --------------------------------*- C++ -*-===//
+//===- PrettyClassDefinitionDumper.h ----------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,12 +7,12 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_CLASSDEFINITIONDUMPER_H
-#define LLVM_TOOLS_LLVMPDBDUMP_CLASSDEFINITIONDUMPER_H
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYCLASSDEFINITIONDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_PRETTYCLASSDEFINITIONDUMPER_H
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
#include <list>
#include <memory>
diff --git a/contrib/llvm/tools/llvm-pdbdump/CompilandDumper.cpp b/contrib/llvm/tools/llvm-pdbdump/PrettyCompilandDumper.cpp
index 05141818660e..6257313e3e1a 100644
--- a/contrib/llvm/tools/llvm-pdbdump/CompilandDumper.cpp
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyCompilandDumper.cpp
@@ -1,4 +1,4 @@
-//===- CompilandDumper.cpp - llvm-pdbdump compiland symbol dumper *- C++ *-===//
+//===- PrettyCompilandDumper.cpp - llvm-pdbdump compiland dumper -*- C++ *-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "CompilandDumper.h"
+#include "PrettyCompilandDumper.h"
+
#include "LinePrinter.h"
+#include "PrettyFunctionDumper.h"
#include "llvm-pdbdump.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
@@ -30,8 +32,6 @@
#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
-#include "FunctionDumper.h"
-
#include <utility>
using namespace llvm;
diff --git a/contrib/llvm/tools/llvm-pdbdump/CompilandDumper.h b/contrib/llvm/tools/llvm-pdbdump/PrettyCompilandDumper.h
index 462aaeb2611f..2127e7d1f529 100644
--- a/contrib/llvm/tools/llvm-pdbdump/CompilandDumper.h
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyCompilandDumper.h
@@ -1,4 +1,4 @@
-//===- CompilandDumper.h - llvm-pdbdump compiland symbol dumper *- C++ --*-===//
+//===- PrettyCompilandDumper.h - llvm-pdbdump compiland dumper -*- C++ --*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_COMPILANDDUMPER_H
-#define LLVM_TOOLS_LLVMPDBDUMP_COMPILANDDUMPER_H
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYCOMPILANDDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_PRETTYCOMPILANDDUMPER_H
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/EnumDumper.cpp b/contrib/llvm/tools/llvm-pdbdump/PrettyEnumDumper.cpp
index 43b6018ffedf..965ca1b9f989 100644
--- a/contrib/llvm/tools/llvm-pdbdump/EnumDumper.cpp
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyEnumDumper.cpp
@@ -1,4 +1,4 @@
-//===- EnumDumper.cpp -------------------------------------------*- C++ -*-===//
+//===- PrettyEnumDumper.cpp -------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,10 +7,10 @@
//
//===----------------------------------------------------------------------===//
-#include "EnumDumper.h"
+#include "PrettyEnumDumper.h"
-#include "BuiltinDumper.h"
#include "LinePrinter.h"
+#include "PrettyBuiltinDumper.h"
#include "llvm-pdbdump.h"
#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/EnumDumper.h b/contrib/llvm/tools/llvm-pdbdump/PrettyEnumDumper.h
index 0a34e1f89ada..c6e65a6d1772 100644
--- a/contrib/llvm/tools/llvm-pdbdump/EnumDumper.h
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyEnumDumper.h
@@ -1,4 +1,4 @@
-//===- EnumDumper.h - -------------------------------------------*- C++ -*-===//
+//===- PrettyEnumDumper.h ---------------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_ENUMDUMPER_H
-#define LLVM_TOOLS_LLVMPDBDUMP_ENUMDUMPER_H
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYENUMDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_PRETTYENUMDUMPER_H
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/ExternalSymbolDumper.cpp b/contrib/llvm/tools/llvm-pdbdump/PrettyExternalSymbolDumper.cpp
index 508a2405772e..fc40d90cee96 100644
--- a/contrib/llvm/tools/llvm-pdbdump/ExternalSymbolDumper.cpp
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyExternalSymbolDumper.cpp
@@ -1,4 +1,4 @@
-//===- ExternalSymbolDumper.cpp -------------------------------- *- C++ *-===//
+//===- PrettyExternalSymbolDumper.cpp -------------------------- *- C++ *-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-#include "ExternalSymbolDumper.h"
+#include "PrettyExternalSymbolDumper.h"
#include "LinePrinter.h"
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/ExternalSymbolDumper.h b/contrib/llvm/tools/llvm-pdbdump/PrettyExternalSymbolDumper.h
index b44b8a6fe98a..6a009862ddd4 100644
--- a/contrib/llvm/tools/llvm-pdbdump/ExternalSymbolDumper.h
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyExternalSymbolDumper.h
@@ -1,4 +1,4 @@
-//===- ExternalSymbolDumper.h --------------------------------- *- C++ --*-===//
+//===- PrettyExternalSymbolDumper.h --------------------------- *- C++ --*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_EXTERNALSYMBOLDUMPER_H
-#define LLVM_TOOLS_LLVMPDBDUMP_EXTERNALSYMBOLDUMPER_H
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYEXTERNALSYMBOLDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_PRETTYEXTERNALSYMBOLDUMPER_H
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/FunctionDumper.cpp b/contrib/llvm/tools/llvm-pdbdump/PrettyFunctionDumper.cpp
index 29ba15d521f0..2f6ca894fadf 100644
--- a/contrib/llvm/tools/llvm-pdbdump/FunctionDumper.cpp
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyFunctionDumper.cpp
@@ -1,4 +1,4 @@
-//===- FunctionDumper.cpp ------------------------------------ *- C++ *-===//
+//===- PrettyFunctionDumper.cpp --------------------------------- *- C++ *-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,9 +7,9 @@
//
//===----------------------------------------------------------------------===//
-#include "FunctionDumper.h"
-#include "BuiltinDumper.h"
+#include "PrettyFunctionDumper.h"
#include "LinePrinter.h"
+#include "PrettyBuiltinDumper.h"
#include "llvm-pdbdump.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/FunctionDumper.h b/contrib/llvm/tools/llvm-pdbdump/PrettyFunctionDumper.h
index c71fafa18ed3..1a6f5430ec5a 100644
--- a/contrib/llvm/tools/llvm-pdbdump/FunctionDumper.h
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyFunctionDumper.h
@@ -1,4 +1,4 @@
-//===- FunctionDumper.h --------------------------------------- *- C++ --*-===//
+//===- PrettyFunctionDumper.h --------------------------------- *- C++ --*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_FUNCTIONDUMPER_H
-#define LLVM_TOOLS_LLVMPDBDUMP_FUNCTIONDUMPER_H
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYFUNCTIONDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_PRETTYFUNCTIONDUMPER_H
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/TypeDumper.cpp b/contrib/llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp
index a49d64045553..4f70c8047337 100644
--- a/contrib/llvm/tools/llvm-pdbdump/TypeDumper.cpp
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyTypeDumper.cpp
@@ -1,4 +1,4 @@
-//===- TypeDumper.cpp - PDBSymDumper implementation for types *----- C++ *-===//
+//===- PrettyTypeDumper.cpp - PDBSymDumper type dumper *------------ C++ *-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,14 +7,14 @@
//
//===----------------------------------------------------------------------===//
-#include "TypeDumper.h"
+#include "PrettyTypeDumper.h"
-#include "BuiltinDumper.h"
-#include "ClassDefinitionDumper.h"
-#include "EnumDumper.h"
#include "LinePrinter.h"
+#include "PrettyBuiltinDumper.h"
+#include "PrettyClassDefinitionDumper.h"
+#include "PrettyEnumDumper.h"
+#include "PrettyTypedefDumper.h"
#include "llvm-pdbdump.h"
-#include "TypedefDumper.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/TypeDumper.h b/contrib/llvm/tools/llvm-pdbdump/PrettyTypeDumper.h
index 76a477964f1f..f9d8304c3208 100644
--- a/contrib/llvm/tools/llvm-pdbdump/TypeDumper.h
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyTypeDumper.h
@@ -1,4 +1,4 @@
-//===- TypeDumper.h - PDBSymDumper implementation for types *- C++ ------*-===//
+//===- PrettyTypeDumper.h - PDBSymDumper implementation for types *- C++ *-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_TYPEDUMPER_H
-#define LLVM_TOOLS_LLVMPDBDUMP_TYPEDUMPER_H
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYTYPEDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_PRETTYTYPEDUMPER_H
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/TypedefDumper.cpp b/contrib/llvm/tools/llvm-pdbdump/PrettyTypedefDumper.cpp
index b1e017613ce1..c458755cb780 100644
--- a/contrib/llvm/tools/llvm-pdbdump/TypedefDumper.cpp
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyTypedefDumper.cpp
@@ -1,4 +1,4 @@
-//===- TypedefDumper.cpp - PDBSymDumper impl for typedefs -------- * C++ *-===//
+//===- PrettyTypedefDumper.cpp - PDBSymDumper impl for typedefs -- * C++ *-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,11 +7,11 @@
//
//===----------------------------------------------------------------------===//
-#include "TypedefDumper.h"
+#include "PrettyTypedefDumper.h"
-#include "BuiltinDumper.h"
-#include "FunctionDumper.h"
#include "LinePrinter.h"
+#include "PrettyBuiltinDumper.h"
+#include "PrettyFunctionDumper.h"
#include "llvm-pdbdump.h"
#include "llvm/DebugInfo/PDB/IPDBSession.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/TypedefDumper.h b/contrib/llvm/tools/llvm-pdbdump/PrettyTypedefDumper.h
index c22b58a7e41e..34c139601301 100644
--- a/contrib/llvm/tools/llvm-pdbdump/TypedefDumper.h
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyTypedefDumper.h
@@ -1,4 +1,4 @@
-//===- TypedefDumper.h - llvm-pdbdump typedef dumper ---------*- C++ ----*-===//
+//===- PrettyTypedefDumper.h - llvm-pdbdump typedef dumper ---*- C++ ----*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_TYPEDEFDUMPER_H
-#define LLVM_TOOLS_LLVMPDBDUMP_TYPEDEFDUMPER_H
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYTYPEDEFDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_PRETTYTYPEDEFDUMPER_H
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/VariableDumper.cpp b/contrib/llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp
index 284d7e9b731f..e1469186ad8b 100644
--- a/contrib/llvm/tools/llvm-pdbdump/VariableDumper.cpp
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyVariableDumper.cpp
@@ -1,4 +1,4 @@
-//===- VariableDumper.cpp - -------------------------------------*- C++ -*-===//
+//===- PrettyVariableDumper.cpp ---------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,21 +7,21 @@
//
//===----------------------------------------------------------------------===//
-#include "VariableDumper.h"
+#include "PrettyVariableDumper.h"
-#include "BuiltinDumper.h"
#include "LinePrinter.h"
+#include "PrettyBuiltinDumper.h"
+#include "PrettyFunctionDumper.h"
#include "llvm-pdbdump.h"
-#include "FunctionDumper.h"
#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeArray.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeFunctionSig.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypePointer.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeTypedef.h"
-#include "llvm/DebugInfo/PDB/PDBSymbolTypeEnum.h"
#include "llvm/DebugInfo/PDB/PDBSymbolTypeUDT.h"
#include "llvm/Support/Format.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/VariableDumper.h b/contrib/llvm/tools/llvm-pdbdump/PrettyVariableDumper.h
index 4f00358878c9..a122bb86058c 100644
--- a/contrib/llvm/tools/llvm-pdbdump/VariableDumper.h
+++ b/contrib/llvm/tools/llvm-pdbdump/PrettyVariableDumper.h
@@ -1,4 +1,4 @@
-//===- VariableDumper.h - PDBSymDumper implementation for types -*- C++ -*-===//
+//===- PrettyVariableDumper.h - PDBSymDumper variable dumper ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -7,8 +7,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_TOOLS_LLVMPDBDUMP_VARIABLEDUMPER_H
-#define LLVM_TOOLS_LLVMPDBDUMP_VARIABLEDUMPER_H
+#ifndef LLVM_TOOLS_LLVMPDBDUMP_PRETTYVARIABLEDUMPER_H
+#define LLVM_TOOLS_LLVMPDBDUMP_PRETTYVARIABLEDUMPER_H
#include "llvm/DebugInfo/PDB/PDBSymDumper.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/YAMLOutputStyle.h b/contrib/llvm/tools/llvm-pdbdump/YAMLOutputStyle.h
index 540dee4121e6..3cd603a95b6a 100644
--- a/contrib/llvm/tools/llvm-pdbdump/YAMLOutputStyle.h
+++ b/contrib/llvm/tools/llvm-pdbdump/YAMLOutputStyle.h
@@ -13,7 +13,7 @@
#include "OutputStyle.h"
#include "PdbYaml.h"
-#include "llvm/DebugInfo/CodeView/TypeDumper.h"
+#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/YAMLTraits.h"
diff --git a/contrib/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp b/contrib/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
index b356a28d2189..d3495e524abc 100644
--- a/contrib/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
+++ b/contrib/llvm/tools/llvm-pdbdump/llvm-pdbdump.cpp
@@ -14,14 +14,14 @@
//===----------------------------------------------------------------------===//
#include "llvm-pdbdump.h"
-#include "CompilandDumper.h"
-#include "ExternalSymbolDumper.h"
-#include "FunctionDumper.h"
#include "LLVMOutputStyle.h"
#include "LinePrinter.h"
#include "OutputStyle.h"
-#include "TypeDumper.h"
-#include "VariableDumper.h"
+#include "PrettyCompilandDumper.h"
+#include "PrettyExternalSymbolDumper.h"
+#include "PrettyFunctionDumper.h"
+#include "PrettyTypeDumper.h"
+#include "PrettyVariableDumper.h"
#include "YAMLOutputStyle.h"
#include "llvm/ADT/ArrayRef.h"
diff --git a/contrib/llvm/tools/llvm-readobj/COFFDumper.cpp b/contrib/llvm/tools/llvm-readobj/COFFDumper.cpp
index 0ca186519cd2..c83655fe4d22 100644
--- a/contrib/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/contrib/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -22,6 +22,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/DebugInfo/CodeView/CVTypeDumper.h"
#include "llvm/DebugInfo/CodeView/CodeView.h"
#include "llvm/DebugInfo/CodeView/Line.h"
#include "llvm/DebugInfo/CodeView/RecordSerialization.h"
@@ -29,7 +30,7 @@
#include "llvm/DebugInfo/CodeView/SymbolDumpDelegate.h"
#include "llvm/DebugInfo/CodeView/SymbolDumper.h"
#include "llvm/DebugInfo/CodeView/SymbolRecord.h"
-#include "llvm/DebugInfo/CodeView/TypeDumper.h"
+#include "llvm/DebugInfo/CodeView/TypeDumpVisitor.h"
#include "llvm/DebugInfo/CodeView/TypeIndex.h"
#include "llvm/DebugInfo/CodeView/TypeRecord.h"
#include "llvm/DebugInfo/CodeView/TypeStreamMerger.h"
@@ -64,8 +65,7 @@ class COFFDumper : public ObjDumper {
public:
friend class COFFObjectDumpDelegate;
COFFDumper(const llvm::object::COFFObjectFile *Obj, ScopedPrinter &Writer)
- : ObjDumper(Writer), Obj(Obj),
- CVTD(&Writer, opts::CodeViewSubsectionBytes) {}
+ : ObjDumper(Writer), Obj(Obj), Writer(Writer) {}
void printFileHeaders() override;
void printSections() override;
@@ -99,7 +99,7 @@ private:
void printFileNameForOffset(StringRef Label, uint32_t FileOffset);
void printTypeIndex(StringRef FieldName, TypeIndex TI) {
// Forward to CVTypeDumper for simplicity.
- CVTD.printTypeIndex(FieldName, TI);
+ CVTypeDumper::printTypeIndex(Writer, FieldName, TI, TypeDB);
}
void printCodeViewSymbolsSubsection(StringRef Subsection,
@@ -142,7 +142,8 @@ private:
StringRef CVFileChecksumTable;
StringRef CVStringTable;
- CVTypeDumper CVTD;
+ ScopedPrinter &Writer;
+ TypeDatabase TypeDB;
};
class COFFObjectDumpDelegate : public SymbolDumpDelegate {
@@ -962,7 +963,8 @@ void COFFDumper::printCodeViewSymbolsSubsection(StringRef Subsection,
auto CODD = llvm::make_unique<COFFObjectDumpDelegate>(*this, Section, Obj,
SectionContents);
- CVSymbolDumper CVSD(W, CVTD, std::move(CODD), opts::CodeViewSubsectionBytes);
+ CVSymbolDumper CVSD(W, TypeDB, std::move(CODD),
+ opts::CodeViewSubsectionBytes);
ByteStream Stream(BinaryData);
CVSymbolArray Symbols;
StreamReader Reader(Stream);
@@ -1106,7 +1108,9 @@ void COFFDumper::printCodeViewTypeSection(StringRef SectionName,
if (Magic != COFF::DEBUG_SECTION_MAGIC)
return error(object_error::parse_failed);
- if (auto EC = CVTD.dump({Data.bytes_begin(), Data.bytes_end()})) {
+ CVTypeDumper CVTD(TypeDB);
+ TypeDumpVisitor TDV(TypeDB, &W, opts::CodeViewSubsectionBytes);
+ if (auto EC = CVTD.dump({Data.bytes_begin(), Data.bytes_end()}, TDV)) {
W.flush();
error(llvm::errorToErrorCode(std::move(EC)));
}
@@ -1552,8 +1556,12 @@ void llvm::dumpCodeViewMergedTypes(ScopedPrinter &Writer,
CVTypes.ForEachRecord([&](TypeIndex TI, ArrayRef<uint8_t> Record) {
Buf.append(Record.begin(), Record.end());
});
- CVTypeDumper CVTD(&Writer, opts::CodeViewSubsectionBytes);
- if (auto EC = CVTD.dump({Buf.str().bytes_begin(), Buf.str().bytes_end()})) {
+
+ TypeDatabase TypeDB;
+ CVTypeDumper CVTD(TypeDB);
+ TypeDumpVisitor TDV(TypeDB, &Writer, opts::CodeViewSubsectionBytes);
+ if (auto EC =
+ CVTD.dump({Buf.str().bytes_begin(), Buf.str().bytes_end()}, TDV)) {
Writer.flush();
error(llvm::errorToErrorCode(std::move(EC)));
}
diff --git a/contrib/llvm/tools/llvm-xray/func-id-helper.cc b/contrib/llvm/tools/llvm-xray/func-id-helper.cc
new file mode 100644
index 000000000000..3234010695b2
--- /dev/null
+++ b/contrib/llvm/tools/llvm-xray/func-id-helper.cc
@@ -0,0 +1,60 @@
+//===- xray-fc-account.cc - XRay Function Call Accounting Tool ------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Implementation of the helper tools dealing with XRay-generated function ids.
+//
+//===----------------------------------------------------------------------===//
+
+#include "func-id-helper.h"
+#include "llvm/Support/Path.h"
+#include <sstream>
+
+using namespace llvm;
+using namespace xray;
+
+std::string FuncIdConversionHelper::SymbolOrNumber(int32_t FuncId) const {
+ std::ostringstream F;
+ auto It = FunctionAddresses.find(FuncId);
+ if (It == FunctionAddresses.end()) {
+ F << "#" << FuncId;
+ return F.str();
+ }
+
+ if (auto ResOrErr = Symbolizer.symbolizeCode(BinaryInstrMap, It->second)) {
+ auto &DI = *ResOrErr;
+ if (DI.FunctionName == "<invalid>")
+ F << "@(" << std::hex << It->second << ")";
+ else
+ F << DI.FunctionName;
+ } else
+ handleAllErrors(ResOrErr.takeError(), [&](const ErrorInfoBase &) {
+ F << "@(" << std::hex << It->second << ")";
+ });
+
+ return F.str();
+}
+
+std::string FuncIdConversionHelper::FileLineAndColumn(int32_t FuncId) const {
+ auto It = FunctionAddresses.find(FuncId);
+ if (It == FunctionAddresses.end())
+ return "(unknown)";
+
+ std::ostringstream F;
+ auto ResOrErr = Symbolizer.symbolizeCode(BinaryInstrMap, It->second);
+ if (!ResOrErr) {
+ consumeError(ResOrErr.takeError());
+ return "(unknown)";
+ }
+
+ auto &DI = *ResOrErr;
+ F << sys::path::filename(DI.FileName).str() << ":" << DI.Line << ":"
+ << DI.Column;
+
+ return F.str();
+}
diff --git a/contrib/llvm/tools/llvm-xray/func-id-helper.h b/contrib/llvm/tools/llvm-xray/func-id-helper.h
new file mode 100644
index 000000000000..7348a7100b05
--- /dev/null
+++ b/contrib/llvm/tools/llvm-xray/func-id-helper.h
@@ -0,0 +1,49 @@
+//===- func-id-helper.h - XRay Function ID Conversion Helpers -------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Defines helper tools dealing with XRay-generated function ids.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H
+#define LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H
+
+#include "llvm/DebugInfo/Symbolize/Symbolize.h"
+#include <unordered_map>
+
+namespace llvm {
+namespace xray {
+
+// This class consolidates common operations related to Function IDs.
+class FuncIdConversionHelper {
+public:
+ using FunctionAddressMap = std::unordered_map<int32_t, uint64_t>;
+
+private:
+ std::string BinaryInstrMap;
+ symbolize::LLVMSymbolizer &Symbolizer;
+ const FunctionAddressMap &FunctionAddresses;
+
+public:
+ FuncIdConversionHelper(std::string BinaryInstrMap,
+ symbolize::LLVMSymbolizer &Symbolizer,
+ const FunctionAddressMap &FunctionAddresses)
+ : BinaryInstrMap(std::move(BinaryInstrMap)), Symbolizer(Symbolizer),
+ FunctionAddresses(FunctionAddresses) {}
+
+ // Returns the symbol or a string representation of the function id.
+ std::string SymbolOrNumber(int32_t FuncId) const;
+
+ // Returns the file and column from debug info for the given function id.
+ std::string FileLineAndColumn(int32_t FuncId) const;
+};
+
+} // namespace xray
+} // namespace llvm
+
+#endif // LLVM_TOOLS_LLVM_XRAY_FUNC_ID_HELPER_H
diff --git a/contrib/llvm/tools/llvm-xray/xray-account.cc b/contrib/llvm/tools/llvm-xray/xray-account.cc
new file mode 100644
index 000000000000..671a5a073eec
--- /dev/null
+++ b/contrib/llvm/tools/llvm-xray/xray-account.cc
@@ -0,0 +1,485 @@
+//===- xray-account.h - XRay Function Call Accounting ---------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements basic function call accounting from an XRay trace.
+//
+//===----------------------------------------------------------------------===//
+
+#include <algorithm>
+#include <cassert>
+#include <numeric>
+#include <system_error>
+#include <utility>
+
+#include "xray-account.h"
+#include "xray-extract.h"
+#include "xray-registry.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/XRay/Trace.h"
+
+using namespace llvm;
+using namespace llvm::xray;
+
+static cl::SubCommand Account("account", "Function call accounting");
+static cl::opt<std::string> AccountInput(cl::Positional,
+ cl::desc("<xray log file>"),
+ cl::Required, cl::sub(Account));
+static cl::opt<bool>
+ AccountKeepGoing("keep-going", cl::desc("Keep going on errors encountered"),
+ cl::sub(Account), cl::init(false));
+static cl::alias AccountKeepGoing2("k", cl::aliasopt(AccountKeepGoing),
+ cl::desc("Alias for -keep_going"),
+ cl::sub(Account));
+static cl::opt<bool> AccountDeduceSiblingCalls(
+ "deduce-sibling-calls",
+ cl::desc("Deduce sibling calls when unrolling function call stacks"),
+ cl::sub(Account), cl::init(false));
+static cl::alias
+ AccountDeduceSiblingCalls2("d", cl::aliasopt(AccountDeduceSiblingCalls),
+ cl::desc("Alias for -deduce_sibling_calls"),
+ cl::sub(Account));
+static cl::opt<std::string>
+ AccountOutput("output", cl::value_desc("output file"), cl::init("-"),
+ cl::desc("output file; use '-' for stdout"),
+ cl::sub(Account));
+static cl::alias AccountOutput2("o", cl::aliasopt(AccountOutput),
+ cl::desc("Alias for -output"),
+ cl::sub(Account));
+enum class AccountOutputFormats { TEXT, CSV };
+static cl::opt<AccountOutputFormats>
+ AccountOutputFormat("format", cl::desc("output format"),
+ cl::values(clEnumValN(AccountOutputFormats::TEXT,
+ "text", "report stats in text"),
+ clEnumValN(AccountOutputFormats::CSV, "csv",
+ "report stats in csv")),
+ cl::sub(Account));
+static cl::alias AccountOutputFormat2("f", cl::desc("Alias of -format"),
+ cl::aliasopt(AccountOutputFormat),
+ cl::sub(Account));
+
+enum class SortField {
+ FUNCID,
+ COUNT,
+ MIN,
+ MED,
+ PCT90,
+ PCT99,
+ MAX,
+ SUM,
+ FUNC,
+};
+
+static cl::opt<SortField> AccountSortOutput(
+ "sort", cl::desc("sort output by this field"), cl::value_desc("field"),
+ cl::sub(Account), cl::init(SortField::FUNCID),
+ cl::values(clEnumValN(SortField::FUNCID, "funcid", "function id"),
+ clEnumValN(SortField::COUNT, "count", "funciton call counts"),
+ clEnumValN(SortField::MIN, "min", "minimum function durations"),
+ clEnumValN(SortField::MED, "med", "median function durations"),
+ clEnumValN(SortField::PCT90, "90p", "90th percentile durations"),
+ clEnumValN(SortField::PCT99, "99p", "99th percentile durations"),
+ clEnumValN(SortField::MAX, "max", "maximum function durations"),
+ clEnumValN(SortField::SUM, "sum", "sum of call durations"),
+ clEnumValN(SortField::FUNC, "func", "function names")));
+static cl::alias AccountSortOutput2("s", cl::aliasopt(AccountSortOutput),
+ cl::desc("Alias for -sort"),
+ cl::sub(Account));
+
+enum class SortDirection {
+ ASCENDING,
+ DESCENDING,
+};
+static cl::opt<SortDirection> AccountSortOrder(
+ "sortorder", cl::desc("sort ordering"), cl::init(SortDirection::ASCENDING),
+ cl::values(clEnumValN(SortDirection::ASCENDING, "asc", "ascending"),
+ clEnumValN(SortDirection::DESCENDING, "dsc", "descending")),
+ cl::sub(Account));
+static cl::alias AccountSortOrder2("r", cl::aliasopt(AccountSortOrder),
+ cl::desc("Alias for -sortorder"),
+ cl::sub(Account));
+
+static cl::opt<int> AccountTop("top", cl::desc("only show the top N results"),
+ cl::value_desc("N"), cl::sub(Account),
+ cl::init(-1));
+static cl::alias AccountTop2("p", cl::desc("Alias for -top"),
+ cl::aliasopt(AccountTop), cl::sub(Account));
+
+static cl::opt<std::string>
+ AccountInstrMap("instr_map",
+ cl::desc("binary with the instrumentation map, or "
+ "a separate instrumentation map"),
+ cl::value_desc("binary with xray_instr_map"),
+ cl::sub(Account), cl::init(""));
+static cl::alias AccountInstrMap2("m", cl::aliasopt(AccountInstrMap),
+ cl::desc("Alias for -instr_map"),
+ cl::sub(Account));
+static cl::opt<InstrumentationMapExtractor::InputFormats> InstrMapFormat(
+ "instr-map-format", cl::desc("format of instrumentation map"),
+ cl::values(clEnumValN(InstrumentationMapExtractor::InputFormats::ELF, "elf",
+ "instrumentation map in an ELF header"),
+ clEnumValN(InstrumentationMapExtractor::InputFormats::YAML,
+ "yaml", "instrumentation map in YAML")),
+ cl::sub(Account), cl::init(InstrumentationMapExtractor::InputFormats::ELF));
+static cl::alias InstrMapFormat2("t", cl::aliasopt(InstrMapFormat),
+ cl::desc("Alias for -instr-map-format"),
+ cl::sub(Account));
+
+namespace {
+
+template <class T, class U> void setMinMax(std::pair<T, T> &MM, U &&V) {
+ if (MM.first == 0 || MM.second == 0)
+ MM = std::make_pair(std::forward<U>(V), std::forward<U>(V));
+ else
+ MM = std::make_pair(std::min(MM.first, V), std::max(MM.second, V));
+}
+
+template <class T> T diff(T L, T R) { return std::max(L, R) - std::min(L, R); }
+
+} // namespace
+
+bool LatencyAccountant::accountRecord(const XRayRecord &Record) {
+ setMinMax(PerThreadMinMaxTSC[Record.TId], Record.TSC);
+ setMinMax(PerCPUMinMaxTSC[Record.CPU], Record.TSC);
+
+ if (CurrentMaxTSC == 0)
+ CurrentMaxTSC = Record.TSC;
+
+ if (Record.TSC < CurrentMaxTSC)
+ return false;
+
+ auto &ThreadStack = PerThreadFunctionStack[Record.TId];
+ switch (Record.Type) {
+ case RecordTypes::ENTER: {
+ // Function Enter
+ ThreadStack.emplace_back(Record.FuncId, Record.TSC);
+ break;
+ }
+ case RecordTypes::EXIT: {
+ // Function Exit
+ if (ThreadStack.back().first == Record.FuncId) {
+ const auto &Top = ThreadStack.back();
+ recordLatency(Top.first, diff(Top.second, Record.TSC));
+ ThreadStack.pop_back();
+ break;
+ }
+
+ if (!DeduceSiblingCalls)
+ return false;
+
+ // Look for the parent up the stack.
+ auto Parent =
+ std::find_if(ThreadStack.rbegin(), ThreadStack.rend(),
+ [&](const std::pair<const int32_t, uint64_t> &E) {
+ return E.first == Record.FuncId;
+ });
+ if (Parent == ThreadStack.rend())
+ return false;
+
+ // Account time for this apparently sibling call exit up the stack.
+ // Considering the following case:
+ //
+ // f()
+ // g()
+ // h()
+ //
+ // We might only ever see the following entries:
+ //
+ // -> f()
+ // -> g()
+ // -> h()
+ // <- h()
+ // <- f()
+ //
+ // Now we don't see the exit to g() because some older version of the XRay
+ // runtime wasn't instrumenting tail exits. If we don't deduce tail calls,
+ // we may potentially never account time for g() -- and this code would have
+ // already bailed out, because `<- f()` doesn't match the current "top" of
+ // stack where we're waiting for the exit to `g()` instead. This is not
+ // ideal and brittle -- so instead we provide a potentially inaccurate
+ // accounting of g() instead, computing it from the exit of f().
+ //
+ // While it might be better that we account the time between `-> g()` and
+ // `-> h()` as the proper accounting of time for g() here, this introduces
+ // complexity to do correctly (need to backtrack, etc.).
+ //
+ // FIXME: Potentially implement the more complex deduction algorithm?
+ auto I = std::next(Parent).base();
+ for (auto &E : make_range(I, ThreadStack.end())) {
+ recordLatency(E.first, diff(E.second, Record.TSC));
+ }
+ ThreadStack.erase(I, ThreadStack.end());
+ break;
+ }
+ }
+
+ return true;
+}
+
+namespace {
+
+// We consolidate the data into a struct which we can output in various forms.
+struct ResultRow {
+ uint64_t Count;
+ double Min;
+ double Median;
+ double Pct90;
+ double Pct99;
+ double Max;
+ double Sum;
+ std::string DebugInfo;
+ std::string Function;
+};
+
+ResultRow getStats(std::vector<uint64_t> &Timings) {
+ assert(!Timings.empty());
+ ResultRow R;
+ R.Sum = std::accumulate(Timings.begin(), Timings.end(), 0.0);
+ auto MinMax = std::minmax_element(Timings.begin(), Timings.end());
+ R.Min = *MinMax.first;
+ R.Max = *MinMax.second;
+ auto MedianOff = Timings.size() / 2;
+ std::nth_element(Timings.begin(), Timings.begin() + MedianOff, Timings.end());
+ R.Median = Timings[MedianOff];
+ auto Pct90Off = std::floor(Timings.size() * 0.9);
+ std::nth_element(Timings.begin(), Timings.begin() + Pct90Off, Timings.end());
+ R.Pct90 = Timings[Pct90Off];
+ auto Pct99Off = std::floor(Timings.size() * 0.99);
+ std::nth_element(Timings.begin(), Timings.begin() + Pct90Off, Timings.end());
+ R.Pct99 = Timings[Pct99Off];
+ R.Count = Timings.size();
+ return R;
+}
+
+} // namespace
+
+template <class F>
+void LatencyAccountant::exportStats(const XRayFileHeader &Header, F Fn) const {
+ using TupleType = std::tuple<int32_t, uint64_t, ResultRow>;
+ std::vector<TupleType> Results;
+ Results.reserve(FunctionLatencies.size());
+ for (auto FT : FunctionLatencies) {
+ const auto &FuncId = FT.first;
+ auto &Timings = FT.second;
+ Results.emplace_back(FuncId, Timings.size(), getStats(Timings));
+ auto &Row = std::get<2>(Results.back());
+ if (Header.CycleFrequency) {
+ double CycleFrequency = Header.CycleFrequency;
+ Row.Min /= CycleFrequency;
+ Row.Median /= CycleFrequency;
+ Row.Pct90 /= CycleFrequency;
+ Row.Pct99 /= CycleFrequency;
+ Row.Max /= CycleFrequency;
+ Row.Sum /= CycleFrequency;
+ }
+
+ Row.Function = FuncIdHelper.SymbolOrNumber(FuncId);
+ Row.DebugInfo = FuncIdHelper.FileLineAndColumn(FuncId);
+ }
+
+ // Sort the data according to user-provided flags.
+ switch (AccountSortOutput) {
+ case SortField::FUNCID:
+ std::sort(Results.begin(), Results.end(),
+ [](const TupleType &L, const TupleType &R) {
+ if (AccountSortOrder == SortDirection::ASCENDING)
+ return std::get<0>(L) < std::get<0>(R);
+ if (AccountSortOrder == SortDirection::DESCENDING)
+ return std::get<0>(L) > std::get<0>(R);
+ llvm_unreachable("Unknown sort direction");
+ });
+ break;
+ case SortField::COUNT:
+ std::sort(Results.begin(), Results.end(),
+ [](const TupleType &L, const TupleType &R) {
+ if (AccountSortOrder == SortDirection::ASCENDING)
+ return std::get<1>(L) < std::get<1>(R);
+ if (AccountSortOrder == SortDirection::DESCENDING)
+ return std::get<1>(L) > std::get<1>(R);
+ llvm_unreachable("Unknown sort direction");
+ });
+ break;
+ default:
+ // Here we need to look into the ResultRow for the rest of the data that
+ // we want to sort by.
+ std::sort(Results.begin(), Results.end(),
+ [&](const TupleType &L, const TupleType &R) {
+ auto &LR = std::get<2>(L);
+ auto &RR = std::get<2>(R);
+ switch (AccountSortOutput) {
+ case SortField::COUNT:
+ if (AccountSortOrder == SortDirection::ASCENDING)
+ return LR.Count < RR.Count;
+ if (AccountSortOrder == SortDirection::DESCENDING)
+ return LR.Count > RR.Count;
+ llvm_unreachable("Unknown sort direction");
+ case SortField::MIN:
+ if (AccountSortOrder == SortDirection::ASCENDING)
+ return LR.Min < RR.Min;
+ if (AccountSortOrder == SortDirection::DESCENDING)
+ return LR.Min > RR.Min;
+ llvm_unreachable("Unknown sort direction");
+ case SortField::MED:
+ if (AccountSortOrder == SortDirection::ASCENDING)
+ return LR.Median < RR.Median;
+ if (AccountSortOrder == SortDirection::DESCENDING)
+ return LR.Median > RR.Median;
+ llvm_unreachable("Unknown sort direction");
+ case SortField::PCT90:
+ if (AccountSortOrder == SortDirection::ASCENDING)
+ return LR.Pct90 < RR.Pct90;
+ if (AccountSortOrder == SortDirection::DESCENDING)
+ return LR.Pct90 > RR.Pct90;
+ llvm_unreachable("Unknown sort direction");
+ case SortField::PCT99:
+ if (AccountSortOrder == SortDirection::ASCENDING)
+ return LR.Pct99 < RR.Pct99;
+ if (AccountSortOrder == SortDirection::DESCENDING)
+ return LR.Pct99 > RR.Pct99;
+ llvm_unreachable("Unknown sort direction");
+ case SortField::MAX:
+ if (AccountSortOrder == SortDirection::ASCENDING)
+ return LR.Max < RR.Max;
+ if (AccountSortOrder == SortDirection::DESCENDING)
+ return LR.Max > RR.Max;
+ llvm_unreachable("Unknown sort direction");
+ case SortField::SUM:
+ if (AccountSortOrder == SortDirection::ASCENDING)
+ return LR.Sum < RR.Sum;
+ if (AccountSortOrder == SortDirection::DESCENDING)
+ return LR.Sum > RR.Sum;
+ llvm_unreachable("Unknown sort direction");
+ default:
+ llvm_unreachable("Unsupported sort order");
+ }
+ });
+ break;
+ }
+
+ if (AccountTop > 0)
+ Results.erase(Results.begin() + AccountTop.getValue(), Results.end());
+
+ for (const auto &R : Results)
+ Fn(std::get<0>(R), std::get<1>(R), std::get<2>(R));
+}
+
+void LatencyAccountant::exportStatsAsText(raw_ostream &OS,
+ const XRayFileHeader &Header) const {
+ OS << "Functions with latencies: " << FunctionLatencies.size() << "\n";
+
+ // We spend some effort to make the text output more readable, so we do the
+ // following formatting decisions for each of the fields:
+ //
+ // - funcid: 32-bit, but we can determine the largest number and be
+ // between
+ // a minimum of 5 characters, up to 9 characters, right aligned.
+ // - count: 64-bit, but we can determine the largest number and be
+ // between
+ // a minimum of 5 characters, up to 9 characters, right aligned.
+ // - min, median, 90pct, 99pct, max: double precision, but we want to keep
+ // the values in seconds, with microsecond precision (0.000'001), so we
+ // have at most 6 significant digits, with the whole number part to be
+ // at
+ // least 1 character. For readability we'll right-align, with full 9
+ // characters each.
+ // - debug info, function name: we format this as a concatenation of the
+ // debug info and the function name.
+ //
+ static constexpr char StatsHeaderFormat[] =
+ "{0,+9} {1,+10} [{2,+9}, {3,+9}, {4,+9}, {5,+9}, {6,+9}] {7,+9}";
+ static constexpr char StatsFormat[] =
+ R"({0,+9} {1,+10} [{2,+9:f6}, {3,+9:f6}, {4,+9:f6}, {5,+9:f6}, {6,+9:f6}] {7,+9:f6})";
+ OS << llvm::formatv(StatsHeaderFormat, "funcid", "count", "min", "med", "90p",
+ "99p", "max", "sum")
+ << llvm::formatv(" {0,-12}\n", "function");
+ exportStats(Header, [&](int32_t FuncId, size_t Count, const ResultRow &Row) {
+ OS << llvm::formatv(StatsFormat, FuncId, Count, Row.Min, Row.Median,
+ Row.Pct90, Row.Pct99, Row.Max, Row.Sum)
+ << " " << Row.DebugInfo << ": " << Row.Function << "\n";
+ });
+}
+
+void LatencyAccountant::exportStatsAsCSV(raw_ostream &OS,
+ const XRayFileHeader &Header) const {
+ OS << "funcid,count,min,median,90%ile,99%ile,max,sum,debug,function\n";
+ exportStats(Header, [&](int32_t FuncId, size_t Count, const ResultRow &Row) {
+ OS << FuncId << ',' << Count << ',' << Row.Min << ',' << Row.Median << ','
+ << Row.Pct90 << ',' << Row.Pct99 << ',' << Row.Max << "," << Row.Sum
+ << ",\"" << Row.DebugInfo << "\",\"" << Row.Function << "\"\n";
+ });
+}
+
+using namespace llvm::xray;
+
+static CommandRegistration Unused(&Account, []() -> Error {
+ int Fd;
+ auto EC = sys::fs::openFileForRead(AccountInput, Fd);
+ if (EC)
+ return make_error<StringError>(
+ Twine("Cannot open file '") + AccountInput + "'", EC);
+
+ Error Err = Error::success();
+ xray::InstrumentationMapExtractor Extractor(AccountInstrMap, InstrMapFormat,
+ Err);
+ if (auto E = handleErrors(
+ std::move(Err), [&](std::unique_ptr<StringError> SE) -> Error {
+ if (SE->convertToErrorCode() == std::errc::no_such_file_or_directory)
+ return Error::success();
+ return Error(std::move(SE));
+ }))
+ return E;
+
+ raw_fd_ostream OS(AccountOutput, EC, sys::fs::OpenFlags::F_Text);
+ if (EC)
+ return make_error<StringError>(
+ Twine("Cannot open file '") + AccountOutput + "' for writing.", EC);
+
+ const auto &FunctionAddresses = Extractor.getFunctionAddresses();
+ symbolize::LLVMSymbolizer::Options Opts(
+ symbolize::FunctionNameKind::LinkageName, true, true, false, "");
+ symbolize::LLVMSymbolizer Symbolizer(Opts);
+ llvm::xray::FuncIdConversionHelper FuncIdHelper(AccountInstrMap, Symbolizer,
+ FunctionAddresses);
+ xray::LatencyAccountant FCA(FuncIdHelper, AccountDeduceSiblingCalls);
+ if (auto TraceOrErr = loadTraceFile(AccountInput)) {
+ auto &T = *TraceOrErr;
+ for (const auto &Record : T) {
+ if (FCA.accountRecord(Record))
+ continue;
+ for (const auto &ThreadStack : FCA.getPerThreadFunctionStack()) {
+ errs() << "Thread ID: " << ThreadStack.first << "\n";
+ auto Level = ThreadStack.second.size();
+ for (const auto &Entry : llvm::reverse(ThreadStack.second))
+ errs() << "#" << Level-- << "\t"
+ << FuncIdHelper.SymbolOrNumber(Entry.first) << '\n';
+ }
+ if (!AccountKeepGoing)
+ return make_error<StringError>(
+ Twine("Failed accounting function calls in file '") + AccountInput +
+ "'.",
+ std::make_error_code(std::errc::executable_format_error));
+ }
+ switch (AccountOutputFormat) {
+ case AccountOutputFormats::TEXT:
+ FCA.exportStatsAsText(OS, T.getFileHeader());
+ break;
+ case AccountOutputFormats::CSV:
+ FCA.exportStatsAsCSV(OS, T.getFileHeader());
+ break;
+ }
+ } else {
+ return joinErrors(
+ make_error<StringError>(
+ Twine("Failed loading input file '") + AccountInput + "'",
+ std::make_error_code(std::errc::executable_format_error)),
+ TraceOrErr.takeError());
+ }
+
+ return Error::success();
+});
diff --git a/contrib/llvm/tools/llvm-xray/xray-account.h b/contrib/llvm/tools/llvm-xray/xray-account.h
new file mode 100644
index 000000000000..cc9ba897e537
--- /dev/null
+++ b/contrib/llvm/tools/llvm-xray/xray-account.h
@@ -0,0 +1,109 @@
+//===- xray-account.h - XRay Function Call Accounting ---------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the interface for performing some basic function call
+// accounting from an XRay trace.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_TOOLS_LLVM_XRAY_XRAY_ACCOUNT_H
+#define LLVM_TOOLS_LLVM_XRAY_XRAY_ACCOUNT_H
+
+#include <map>
+#include <utility>
+#include <vector>
+
+#include "func-id-helper.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/XRay/XRayRecord.h"
+
+namespace llvm {
+namespace xray {
+
+class LatencyAccountant {
+public:
+ typedef std::map<int32_t, std::vector<uint64_t>> FunctionLatencyMap;
+ typedef std::map<llvm::sys::ProcessInfo::ProcessId,
+ std::pair<uint64_t, uint64_t>>
+ PerThreadMinMaxTSCMap;
+ typedef std::map<uint8_t, std::pair<uint64_t, uint64_t>> PerCPUMinMaxTSCMap;
+ typedef std::vector<std::pair<int32_t, uint64_t>> FunctionStack;
+ typedef std::map<llvm::sys::ProcessInfo::ProcessId, FunctionStack>
+ PerThreadFunctionStackMap;
+
+private:
+ PerThreadFunctionStackMap PerThreadFunctionStack;
+ FunctionLatencyMap FunctionLatencies;
+ PerThreadMinMaxTSCMap PerThreadMinMaxTSC;
+ PerCPUMinMaxTSCMap PerCPUMinMaxTSC;
+ FuncIdConversionHelper &FuncIdHelper;
+
+ bool DeduceSiblingCalls = false;
+ uint64_t CurrentMaxTSC = 0;
+
+ void recordLatency(int32_t FuncId, uint64_t Latency) {
+ FunctionLatencies[FuncId].push_back(Latency);
+ }
+
+public:
+ explicit LatencyAccountant(FuncIdConversionHelper &FuncIdHelper,
+ bool DeduceSiblingCalls)
+ : FuncIdHelper(FuncIdHelper), DeduceSiblingCalls(DeduceSiblingCalls) {}
+
+ const FunctionLatencyMap &getFunctionLatencies() const {
+ return FunctionLatencies;
+ }
+
+ const PerThreadMinMaxTSCMap &getPerThreadMinMaxTSC() const {
+ return PerThreadMinMaxTSC;
+ }
+
+ const PerCPUMinMaxTSCMap &getPerCPUMinMaxTSC() const {
+ return PerCPUMinMaxTSC;
+ }
+
+ /// Returns false in case we fail to account the provided record. This happens
+ /// in the following cases:
+ ///
+ /// - An exit record does not match any entry records for the same function.
+ /// If we've been set to deduce sibling calls, we try walking up the stack
+ /// and recording times for the higher level functions.
+ /// - A record has a TSC that's before the latest TSC that has been
+ /// recorded. We still record the TSC for the min-max.
+ ///
+ bool accountRecord(const XRayRecord &Record);
+
+ const FunctionStack *
+ getThreadFunctionStack(llvm::sys::ProcessInfo::ProcessId TId) const {
+ auto I = PerThreadFunctionStack.find(TId);
+ if (I == PerThreadFunctionStack.end())
+ return nullptr;
+ return &I->second;
+ }
+
+ const PerThreadFunctionStackMap &getPerThreadFunctionStack() const {
+ return PerThreadFunctionStack;
+ }
+
+ // Output Functions
+ // ================
+
+ void exportStatsAsText(raw_ostream &OS, const XRayFileHeader &Header) const;
+ void exportStatsAsCSV(raw_ostream &OS, const XRayFileHeader &Header) const;
+
+private:
+ // Internal helper to implement common parts of the exportStatsAs...
+ // functions.
+ template <class F> void exportStats(const XRayFileHeader &Header, F fn) const;
+};
+
+} // namespace xray
+} // namespace llvm
+
+#endif // LLVM_TOOLS_LLVM_XRAY_XRAY_ACCOUNT_H
diff --git a/contrib/llvm/tools/llvm-xray/xray-converter.cc b/contrib/llvm/tools/llvm-xray/xray-converter.cc
new file mode 100644
index 000000000000..31275e2902f2
--- /dev/null
+++ b/contrib/llvm/tools/llvm-xray/xray-converter.cc
@@ -0,0 +1,202 @@
+//===- xray-converter.cc - XRay Trace Conversion --------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Implements the trace conversion functions.
+//
+//===----------------------------------------------------------------------===//
+#include "xray-converter.h"
+
+#include "xray-extract.h"
+#include "xray-registry.h"
+#include "llvm/DebugInfo/Symbolize/Symbolize.h"
+#include "llvm/Support/EndianStream.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/YAMLTraits.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/XRay/Trace.h"
+#include "llvm/XRay/YAMLXRayRecord.h"
+
+using namespace llvm;
+using namespace xray;
+
+// llvm-xray convert
+// ----------------------------------------------------------------------------
+static cl::SubCommand Convert("convert", "Trace Format Conversion");
+static cl::opt<std::string> ConvertInput(cl::Positional,
+ cl::desc("<xray log file>"),
+ cl::Required, cl::sub(Convert));
+enum class ConvertFormats { BINARY, YAML };
+static cl::opt<ConvertFormats> ConvertOutputFormat(
+ "output-format", cl::desc("output format"),
+ cl::values(clEnumValN(ConvertFormats::BINARY, "raw", "output in binary"),
+ clEnumValN(ConvertFormats::YAML, "yaml", "output in yaml")),
+ cl::sub(Convert));
+static cl::alias ConvertOutputFormat2("f", cl::aliasopt(ConvertOutputFormat),
+ cl::desc("Alias for -output-format"),
+ cl::sub(Convert));
+static cl::opt<std::string>
+ ConvertOutput("output", cl::value_desc("output file"), cl::init("-"),
+ cl::desc("output file; use '-' for stdout"),
+ cl::sub(Convert));
+static cl::alias ConvertOutput2("o", cl::aliasopt(ConvertOutput),
+ cl::desc("Alias for -output"),
+ cl::sub(Convert));
+
+static cl::opt<bool>
+ ConvertSymbolize("symbolize",
+ cl::desc("symbolize function ids from the input log"),
+ cl::init(false), cl::sub(Convert));
+static cl::alias ConvertSymbolize2("y", cl::aliasopt(ConvertSymbolize),
+ cl::desc("Alias for -symbolize"),
+ cl::sub(Convert));
+
+static cl::opt<std::string>
+ ConvertInstrMap("instr_map",
+ cl::desc("binary with the instrumentation map, or "
+ "a separate instrumentation map"),
+ cl::value_desc("binary with xray_instr_map"),
+ cl::sub(Convert), cl::init(""));
+static cl::alias ConvertInstrMap2("m", cl::aliasopt(ConvertInstrMap),
+ cl::desc("Alias for -instr_map"),
+ cl::sub(Convert));
+static cl::opt<bool> ConvertSortInput(
+ "sort",
+ cl::desc("determines whether to sort input log records by timestamp"),
+ cl::sub(Convert), cl::init(true));
+static cl::alias ConvertSortInput2("s", cl::aliasopt(ConvertSortInput),
+ cl::desc("Alias for -sort"),
+ cl::sub(Convert));
+static cl::opt<InstrumentationMapExtractor::InputFormats> InstrMapFormat(
+ "instr-map-format", cl::desc("format of instrumentation map"),
+ cl::values(clEnumValN(InstrumentationMapExtractor::InputFormats::ELF, "elf",
+ "instrumentation map in an ELF header"),
+ clEnumValN(InstrumentationMapExtractor::InputFormats::YAML,
+ "yaml", "instrumentation map in YAML")),
+ cl::sub(Convert), cl::init(InstrumentationMapExtractor::InputFormats::ELF));
+static cl::alias InstrMapFormat2("t", cl::aliasopt(InstrMapFormat),
+ cl::desc("Alias for -instr-map-format"),
+ cl::sub(Convert));
+
+using llvm::yaml::IO;
+using llvm::yaml::Output;
+
+void TraceConverter::exportAsYAML(const Trace &Records, raw_ostream &OS) {
+ YAMLXRayTrace Trace;
+ const auto &FH = Records.getFileHeader();
+ Trace.Header = {FH.Version, FH.Type, FH.ConstantTSC, FH.NonstopTSC,
+ FH.CycleFrequency};
+ Trace.Records.reserve(Records.size());
+ for (const auto &R : Records) {
+ Trace.Records.push_back({R.RecordType, R.CPU, R.Type, R.FuncId,
+ Symbolize ? FuncIdHelper.SymbolOrNumber(R.FuncId)
+ : std::to_string(R.FuncId),
+ R.TSC, R.TId});
+ }
+ Output Out(OS);
+ Out << Trace;
+}
+
+void TraceConverter::exportAsRAWv1(const Trace &Records, raw_ostream &OS) {
+ // First write out the file header, in the correct endian-appropriate format
+ // (XRay assumes currently little endian).
+ support::endian::Writer<support::endianness::little> Writer(OS);
+ const auto &FH = Records.getFileHeader();
+ Writer.write(FH.Version);
+ Writer.write(FH.Type);
+ uint32_t Bitfield{0};
+ if (FH.ConstantTSC)
+ Bitfield |= 1uL;
+ if (FH.NonstopTSC)
+ Bitfield |= 1uL << 1;
+ Writer.write(Bitfield);
+ Writer.write(FH.CycleFrequency);
+
+ // There's 16 bytes of padding at the end of the file header.
+ static constexpr uint32_t Padding4B = 0;
+ Writer.write(Padding4B);
+ Writer.write(Padding4B);
+ Writer.write(Padding4B);
+ Writer.write(Padding4B);
+
+ // Then write out the rest of the records, still in an endian-appropriate
+ // format.
+ for (const auto &R : Records) {
+ Writer.write(R.RecordType);
+ Writer.write(R.CPU);
+ switch (R.Type) {
+ case RecordTypes::ENTER:
+ Writer.write(uint8_t{0});
+ break;
+ case RecordTypes::EXIT:
+ Writer.write(uint8_t{1});
+ break;
+ }
+ Writer.write(R.FuncId);
+ Writer.write(R.TSC);
+ Writer.write(R.TId);
+ Writer.write(Padding4B);
+ Writer.write(Padding4B);
+ Writer.write(Padding4B);
+ }
+}
+
+namespace llvm {
+namespace xray {
+
+static CommandRegistration Unused(&Convert, []() -> Error {
+ // FIXME: Support conversion to BINARY when upgrading XRay trace versions.
+ int Fd;
+ auto EC = sys::fs::openFileForRead(ConvertInput, Fd);
+ if (EC)
+ return make_error<StringError>(
+ Twine("Cannot open file '") + ConvertInput + "'", EC);
+
+ Error Err = Error::success();
+ xray::InstrumentationMapExtractor Extractor(ConvertInstrMap, InstrMapFormat,
+ Err);
+ handleAllErrors(std::move(Err),
+ [&](const ErrorInfoBase &E) { E.log(errs()); });
+
+ const auto &FunctionAddresses = Extractor.getFunctionAddresses();
+ symbolize::LLVMSymbolizer::Options Opts(
+ symbolize::FunctionNameKind::LinkageName, true, true, false, "");
+ symbolize::LLVMSymbolizer Symbolizer(Opts);
+ llvm::xray::FuncIdConversionHelper FuncIdHelper(ConvertInstrMap, Symbolizer,
+ FunctionAddresses);
+ llvm::xray::TraceConverter TC(FuncIdHelper, ConvertSymbolize);
+ raw_fd_ostream OS(ConvertOutput, EC,
+ ConvertOutputFormat == ConvertFormats::BINARY
+ ? sys::fs::OpenFlags::F_None
+ : sys::fs::OpenFlags::F_Text);
+ if (EC)
+ return make_error<StringError>(
+ Twine("Cannot open file '") + ConvertOutput + "' for writing.", EC);
+
+ if (auto TraceOrErr = loadTraceFile(ConvertInput, ConvertSortInput)) {
+ auto &T = *TraceOrErr;
+ switch (ConvertOutputFormat) {
+ case ConvertFormats::YAML:
+ TC.exportAsYAML(T, OS);
+ break;
+ case ConvertFormats::BINARY:
+ TC.exportAsRAWv1(T, OS);
+ break;
+ }
+ } else {
+ return joinErrors(
+ make_error<StringError>(
+ Twine("Failed loading input file '") + ConvertInput + "'.",
+ std::make_error_code(std::errc::executable_format_error)),
+ TraceOrErr.takeError());
+ }
+ return Error::success();
+});
+
+} // namespace xray
+} // namespace llvm
diff --git a/contrib/llvm/tools/llvm-xray/xray-converter.h b/contrib/llvm/tools/llvm-xray/xray-converter.h
new file mode 100644
index 000000000000..fa0d5e132f14
--- /dev/null
+++ b/contrib/llvm/tools/llvm-xray/xray-converter.h
@@ -0,0 +1,39 @@
+//===- xray-converter.h - XRay Trace Conversion ---------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Defines the TraceConverter class for turning binary traces into
+// human-readable text and vice versa.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_TOOLS_LLVM_XRAY_XRAY_CONVERTER_H
+#define LLVM_TOOLS_LLVM_XRAY_XRAY_CONVERTER_H
+
+#include "func-id-helper.h"
+#include "llvm/XRay/XRayRecord.h"
+#include "llvm/XRay/Trace.h"
+
+namespace llvm {
+namespace xray {
+
+class TraceConverter {
+ FuncIdConversionHelper &FuncIdHelper;
+ bool Symbolize;
+
+public:
+ TraceConverter(FuncIdConversionHelper &FuncIdHelper, bool Symbolize = false)
+ : FuncIdHelper(FuncIdHelper), Symbolize(Symbolize) {}
+
+ void exportAsYAML(const Trace &Records, raw_ostream &OS);
+ void exportAsRAWv1(const Trace &Records, raw_ostream &OS);
+};
+
+} // namespace xray
+} // namespace llvm
+
+#endif // LLVM_TOOLS_LLVM_XRAY_XRAY_CONVERTER_H
diff --git a/contrib/llvm/tools/llvm-xray/xray-extract.cc b/contrib/llvm/tools/llvm-xray/xray-extract.cc
index e51b64c8ad6e..49ecd7421137 100644
--- a/contrib/llvm/tools/llvm-xray/xray-extract.cc
+++ b/contrib/llvm/tools/llvm-xray/xray-extract.cc
@@ -162,8 +162,7 @@ llvm::Error LoadBinaryInstrELF(
"'.",
std::make_error_code(std::errc::executable_format_error));
}
- auto AlwaysInstrument = Extractor.getU8(&OffsetPtr);
- Entry.AlwaysInstrument = AlwaysInstrument != 0;
+ Entry.AlwaysInstrument = Extractor.getU8(&OffsetPtr) != 0;
// We replicate the function id generation scheme implemented in the runtime
// here. Ideally we should be able to break it out, or output this map from
@@ -185,30 +184,82 @@ llvm::Error LoadBinaryInstrELF(
return llvm::Error::success();
}
+Error LoadYAMLInstrMap(
+ StringRef Filename, std::deque<SledEntry> &Sleds,
+ InstrumentationMapExtractor::FunctionAddressMap &InstrMap,
+ InstrumentationMapExtractor::FunctionAddressReverseMap &FunctionIds) {
+ int Fd;
+ if (auto EC = sys::fs::openFileForRead(Filename, Fd))
+ return make_error<StringError>(
+ Twine("Failed opening file '") + Filename + "' for reading.", EC);
+
+ uint64_t FileSize;
+ if (auto EC = sys::fs::file_size(Filename, FileSize))
+ return make_error<StringError>(
+ Twine("Failed getting size of file '") + Filename + "'.", EC);
+
+ std::error_code EC;
+ sys::fs::mapped_file_region MappedFile(
+ Fd, sys::fs::mapped_file_region::mapmode::readonly, FileSize, 0, EC);
+ if (EC)
+ return make_error<StringError>(
+ Twine("Failed memory-mapping file '") + Filename + "'.", EC);
+
+ std::vector<YAMLXRaySledEntry> YAMLSleds;
+ Input In(StringRef(MappedFile.data(), MappedFile.size()));
+ In >> YAMLSleds;
+ if (In.error())
+ return make_error<StringError>(
+ Twine("Failed loading YAML document from '") + Filename + "'.",
+ In.error());
+
+ for (const auto &Y : YAMLSleds) {
+ InstrMap[Y.FuncId] = Y.Function;
+ FunctionIds[Y.Function] = Y.FuncId;
+ Sleds.push_back(
+ SledEntry{Y.Address, Y.Function, Y.Kind, Y.AlwaysInstrument});
+ }
+ return Error::success();
+}
+
} // namespace
InstrumentationMapExtractor::InstrumentationMapExtractor(std::string Filename,
InputFormats Format,
Error &EC) {
ErrorAsOutParameter ErrAsOutputParam(&EC);
+ if (Filename.empty()) {
+ EC = Error::success();
+ return;
+ }
switch (Format) {
case InputFormats::ELF: {
EC = handleErrors(
LoadBinaryInstrELF(Filename, Sleds, FunctionAddresses, FunctionIds),
- [](std::unique_ptr<ErrorInfoBase> E) {
+ [&](std::unique_ptr<ErrorInfoBase> E) {
return joinErrors(
make_error<StringError>(
Twine("Cannot extract instrumentation map from '") +
- ExtractInput + "'.",
+ Filename + "'.",
std::make_error_code(std::errc::executable_format_error)),
std::move(E));
});
break;
}
- default:
- llvm_unreachable("Input format type not supported yet.");
+ case InputFormats::YAML: {
+ EC = handleErrors(
+ LoadYAMLInstrMap(Filename, Sleds, FunctionAddresses, FunctionIds),
+ [&](std::unique_ptr<ErrorInfoBase> E) {
+ return joinErrors(
+ make_error<StringError>(
+ Twine("Cannot load YAML instrumentation map from '") +
+ Filename + "'.",
+ std::make_error_code(std::errc::executable_format_error)),
+ std::move(E));
+ });
break;
}
+ }
}
void InstrumentationMapExtractor::exportAsYAML(raw_ostream &OS) {
diff --git a/contrib/llvm/tools/llvm-xray/xray-record-yaml.h b/contrib/llvm/tools/llvm-xray/xray-record-yaml.h
new file mode 100644
index 000000000000..abce8ff60a94
--- /dev/null
+++ b/contrib/llvm/tools/llvm-xray/xray-record-yaml.h
@@ -0,0 +1,102 @@
+//===- xray-record-yaml.h - XRay Record YAML Support Definitions ----------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// Types and traits specialisations for YAML I/O of XRay log entries.
+//
+//===----------------------------------------------------------------------===//
+#ifndef LLVM_TOOLS_LLVM_XRAY_XRAY_RECORD_YAML_H
+#define LLVM_TOOLS_LLVM_XRAY_XRAY_RECORD_YAML_H
+
+#include <type_traits>
+
+#include "xray-record.h"
+#include "llvm/Support/YAMLTraits.h"
+
+namespace llvm {
+namespace xray {
+
+struct YAMLXRayFileHeader {
+ uint16_t Version;
+ uint16_t Type;
+ bool ConstantTSC;
+ bool NonstopTSC;
+ uint64_t CycleFrequency;
+};
+
+struct YAMLXRayRecord {
+ uint16_t RecordType;
+ uint8_t CPU;
+ RecordTypes Type;
+ int32_t FuncId;
+ std::string Function;
+ uint64_t TSC;
+ uint32_t TId;
+};
+
+struct YAMLXRayTrace {
+ YAMLXRayFileHeader Header;
+ std::vector<YAMLXRayRecord> Records;
+};
+
+using XRayRecordStorage =
+ std::aligned_storage<sizeof(XRayRecord), alignof(XRayRecord)>::type;
+
+} // namespace xray
+
+namespace yaml {
+
+// YAML Traits
+// -----------
+template <> struct ScalarEnumerationTraits<xray::RecordTypes> {
+ static void enumeration(IO &IO, xray::RecordTypes &Type) {
+ IO.enumCase(Type, "function-enter", xray::RecordTypes::ENTER);
+ IO.enumCase(Type, "function-exit", xray::RecordTypes::EXIT);
+ }
+};
+
+template <> struct MappingTraits<xray::YAMLXRayFileHeader> {
+ static void mapping(IO &IO, xray::YAMLXRayFileHeader &Header) {
+ IO.mapRequired("version", Header.Version);
+ IO.mapRequired("type", Header.Type);
+ IO.mapRequired("constant-tsc", Header.ConstantTSC);
+ IO.mapRequired("nonstop-tsc", Header.NonstopTSC);
+ IO.mapRequired("cycle-frequency", Header.CycleFrequency);
+ }
+};
+
+template <> struct MappingTraits<xray::YAMLXRayRecord> {
+ static void mapping(IO &IO, xray::YAMLXRayRecord &Record) {
+ // FIXME: Make this type actually be descriptive
+ IO.mapRequired("type", Record.RecordType);
+ IO.mapRequired("func-id", Record.FuncId);
+ IO.mapOptional("function", Record.Function);
+ IO.mapRequired("cpu", Record.CPU);
+ IO.mapRequired("thread", Record.TId);
+ IO.mapRequired("kind", Record.Type);
+ IO.mapRequired("tsc", Record.TSC);
+ }
+
+ static constexpr bool flow = true;
+};
+
+template <> struct MappingTraits<xray::YAMLXRayTrace> {
+ static void mapping(IO &IO, xray::YAMLXRayTrace &Trace) {
+ // A trace file contains two parts, the header and the list of all the
+ // trace records.
+ IO.mapRequired("header", Trace.Header);
+ IO.mapRequired("records", Trace.Records);
+ }
+};
+
+} // namespace yaml
+} // namespace llvm
+
+LLVM_YAML_IS_SEQUENCE_VECTOR(xray::YAMLXRayRecord)
+
+#endif // LLVM_TOOLS_LLVM_XRAY_XRAY_RECORD_YAML_H
diff --git a/contrib/llvm/tools/opt/NewPMDriver.cpp b/contrib/llvm/tools/opt/NewPMDriver.cpp
index acdf2639b3c7..df467da690e7 100644
--- a/contrib/llvm/tools/opt/NewPMDriver.cpp
+++ b/contrib/llvm/tools/opt/NewPMDriver.cpp
@@ -17,7 +17,6 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/CGSCCPassManager.h"
-#include "llvm/Analysis/LoopPassManager.h"
#include "llvm/Bitcode/BitcodeWriterPass.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/IRPrintingPasses.h"
@@ -30,6 +29,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Target/TargetMachine.h"
+#include "llvm/Transforms/Scalar/LoopPassManager.h"
using namespace llvm;
using namespace opt_tool;