Skip to content

Commit 9a177c2

Browse files
Merge branch 'main' into users/mingmingl-llvm/prepatch
2 parents 3d70a00 + e8f721e commit 9a177c2

File tree

130 files changed

+2797
-2597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+2797
-2597
lines changed

.ci/metrics/metrics.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
GITHUB_JOB_TO_TRACK = {
4141
"github_llvm_premerge_checks": {
4242
"Build and Test Linux": "premerge_linux",
43+
"Build and Test Linux AArch64": "premerge_linux_aarch64",
4344
"Build and Test Windows": "premerge_windows",
4445
},
4546
"github_libcxx_premerge_checks": {

clang/docs/OpenMPSupport.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ implementation.
505505
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
506506
| pure directives in DO CONCURRENT | | :none:`unclaimed` | |
507507
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
508-
| Optional argument for all clauses | :none:`unclaimed` | :none:`unclaimed` | |
508+
| Optional argument for all clauses | :none:`partial` | :none:`In Progress` | Parse/Sema (nowait): https://github.com/llvm/llvm-project/pull/159628 |
509509
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
510510
| Function references for locator list items | :none:`unclaimed` | :none:`unclaimed` | |
511511
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,8 @@ OpenMP Support
641641
- Added support for ``defaultmap`` directive implicit-behavior ``private``.
642642
- Added parsing and semantic analysis support for ``groupprivate`` directive.
643643
- Added support for 'omp fuse' directive.
644+
- Updated parsing and semantic analysis support for ``nowait`` clause to accept
645+
optional argument in OpenMP >= 60.
644646

645647
Improvements
646648
^^^^^^^^^^^^

clang/docs/UsersManual.rst

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,6 +2780,25 @@ usual build cycle when using sample profilers for optimization:
27802780
/clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^
27812781
code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf
27822782
2783+
[OPTIONAL] Pseudo instrumentation can be used as the anchor for accurate
2784+
profile mapping with the ``-fpseudo-probe-for-profiling`` option.
2785+
2786+
On Linux:
2787+
2788+
.. code-block:: console
2789+
2790+
$ clang++ -O2 -gline-tables-only \
2791+
-fpseudo-probe-for-profiling -funique-internal-linkage-names \
2792+
code.cc -o code
2793+
2794+
On Windows:
2795+
2796+
.. code-block:: winbatch
2797+
2798+
> clang-cl /O2 -gdwarf -gline-tables-only ^
2799+
-fpseudo-probe-for-profiling /clang:-funique-internal-linkage-names ^
2800+
code.cc /Fe:code -fuse-ld=lld /link /debug:dwarf
2801+
27832802
.. note::
27842803

27852804
:ref:`-funique-internal-linkage-names <funique_internal_linkage_names>`
@@ -2881,6 +2900,25 @@ usual build cycle when using sample profilers for optimization:
28812900
/clang:-fdebug-info-for-profiling /clang:-funique-internal-linkage-names ^
28822901
-fprofile-sample-use=code.prof code.cc /Fe:code
28832902
2903+
[OPTIONAL] Pseudo instrumentation can be used as the anchor for accurate
2904+
profile mapping with the ``-fpseudo-probe-for-profiling`` option.
2905+
2906+
On Linux:
2907+
2908+
.. code-block:: console
2909+
2910+
$ clang++ -O2 \
2911+
-fpseudo-probe-for-profiling -funique-internal-linkage-names \
2912+
-fprofile-sample-use=code.prof code.cc -o code
2913+
2914+
On Windows:
2915+
2916+
.. code-block:: winbatch
2917+
2918+
> clang-cl /O2 ^
2919+
-fpseudo-probe-for-profiling /clang:-funique-internal-linkage-names ^
2920+
-fprofile-sample-use=code.prof code.cc /Fe:code
2921+
28842922
[OPTIONAL] Sampling-based profiles can have inaccuracies or missing block/
28852923
edge counters. The profile inference algorithm (profi) can be used to infer
28862924
missing blocks and edge counts, and improve the quality of profile data.

clang/include/clang/AST/OpenACCClause.h

Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,7 +1277,7 @@ class OpenACCCreateClause final
12771277
};
12781278

12791279
// A structure to stand in for the recipe on a reduction. RecipeDecl is the
1280-
// 'main' declaration used for initializaiton, which is fixed.
1280+
// 'main' declaration used for initializaiton, which is fixed.
12811281
struct OpenACCReductionRecipe {
12821282
VarDecl *AllocaDecl;
12831283

@@ -1297,36 +1297,93 @@ struct OpenACCReductionRecipe {
12971297
// -For a struct without the operator, this will be 1 element per field, which
12981298
// should be the combiner for that element.
12991299
// -For an array of any of the above, it will be the above for the element.
1300-
llvm::SmallVector<CombinerRecipe, 1> CombinerRecipes;
1300+
// Note: These are necessarily stored in either Trailing Storage (when in the
1301+
// AST), or in a separate collection when being semantically analyzed.
1302+
llvm::ArrayRef<CombinerRecipe> CombinerRecipes;
13011303

13021304
OpenACCReductionRecipe(VarDecl *A, llvm::ArrayRef<CombinerRecipe> Combiners)
13031305
: AllocaDecl(A), CombinerRecipes(Combiners) {}
13041306

13051307
bool isSet() const { return AllocaDecl; }
1306-
static OpenACCReductionRecipe Empty() {
1307-
return OpenACCReductionRecipe(/*AllocaDecl=*/nullptr, {});
1308+
};
1309+
1310+
// A version of the above that is used for semantic analysis, at a time before
1311+
// the OpenACCReductionClause node has been created. This one has storage for
1312+
// the CombinerRecipe, since Trailing storage for it doesn't exist yet.
1313+
struct OpenACCReductionRecipeWithStorage : OpenACCReductionRecipe {
1314+
private:
1315+
llvm::SmallVector<CombinerRecipe, 1> CombinerRecipeStorage;
1316+
1317+
public:
1318+
OpenACCReductionRecipeWithStorage(VarDecl *A,
1319+
llvm::ArrayRef<CombinerRecipe> Combiners)
1320+
: OpenACCReductionRecipe(A, {}), CombinerRecipeStorage(Combiners) {
1321+
CombinerRecipes = CombinerRecipeStorage;
1322+
}
1323+
1324+
OpenACCReductionRecipeWithStorage(
1325+
const OpenACCReductionRecipeWithStorage &Other)
1326+
: OpenACCReductionRecipe(Other),
1327+
CombinerRecipeStorage(Other.CombinerRecipeStorage) {
1328+
CombinerRecipes = CombinerRecipeStorage;
1329+
}
1330+
1331+
OpenACCReductionRecipeWithStorage(OpenACCReductionRecipeWithStorage &&Other)
1332+
: OpenACCReductionRecipe(std::move(Other)),
1333+
CombinerRecipeStorage(std::move(Other.CombinerRecipeStorage)) {
1334+
CombinerRecipes = CombinerRecipeStorage;
1335+
}
1336+
1337+
// There is no real problem implementing these, we just have to make sure the
1338+
// array-ref this inherits from stays in sync. But as we don't need it at the
1339+
// moment, make sure we don't accidentially call these.
1340+
OpenACCReductionRecipeWithStorage &
1341+
operator=(OpenACCReductionRecipeWithStorage &&) = delete;
1342+
OpenACCReductionRecipeWithStorage &
1343+
operator=(const OpenACCReductionRecipeWithStorage &) = delete;
1344+
1345+
static OpenACCReductionRecipeWithStorage Empty() {
1346+
return OpenACCReductionRecipeWithStorage(/*AllocaDecl=*/nullptr, {});
13081347
}
13091348
};
13101349

13111350
class OpenACCReductionClause final
13121351
: public OpenACCClauseWithVarList,
13131352
private llvm::TrailingObjects<OpenACCReductionClause, Expr *,
1314-
OpenACCReductionRecipe> {
1353+
OpenACCReductionRecipe,
1354+
OpenACCReductionRecipe::CombinerRecipe> {
13151355
friend TrailingObjects;
13161356
OpenACCReductionOperator Op;
13171357

13181358
OpenACCReductionClause(SourceLocation BeginLoc, SourceLocation LParenLoc,
13191359
OpenACCReductionOperator Operator,
13201360
ArrayRef<Expr *> VarList,
1321-
ArrayRef<OpenACCReductionRecipe> Recipes,
1361+
ArrayRef<OpenACCReductionRecipeWithStorage> Recipes,
13221362
SourceLocation EndLoc)
13231363
: OpenACCClauseWithVarList(OpenACCClauseKind::Reduction, BeginLoc,
13241364
LParenLoc, EndLoc),
13251365
Op(Operator) {
1326-
assert(VarList.size() == Recipes.size());
1366+
assert(VarList.size() == Recipes.size());
13271367
setExprs(getTrailingObjects<Expr *>(VarList.size()), VarList);
1328-
llvm::uninitialized_copy(Recipes, getTrailingObjects<
1329-
OpenACCReductionRecipe > ());
1368+
1369+
// Since we're using trailing storage on this node to store the 'combiner'
1370+
// recipes of the Reduction Recipes (which have a 1:M relationship), we need
1371+
// to ensure we get the ArrayRef of each of our combiner 'correct'.
1372+
OpenACCReductionRecipe::CombinerRecipe *CurCombinerLoc =
1373+
getTrailingObjects<OpenACCReductionRecipe::CombinerRecipe>();
1374+
for (const auto &[Idx, R] : llvm::enumerate(Recipes)) {
1375+
1376+
// ArrayRef to the 'correct' data location in trailing storage.
1377+
llvm::MutableArrayRef<OpenACCReductionRecipe::CombinerRecipe>
1378+
NewCombiners{CurCombinerLoc, R.CombinerRecipes.size()};
1379+
CurCombinerLoc += R.CombinerRecipes.size();
1380+
1381+
llvm::uninitialized_copy(R.CombinerRecipes, NewCombiners.begin());
1382+
1383+
// Placement new into the correct location in trailng storage.
1384+
new (&getTrailingObjects<OpenACCReductionRecipe>()[Idx])
1385+
OpenACCReductionRecipe(R.AllocaDecl, NewCombiners);
1386+
}
13301387
}
13311388

13321389
public:
@@ -1347,13 +1404,17 @@ class OpenACCReductionClause final
13471404
static OpenACCReductionClause *
13481405
Create(const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc,
13491406
OpenACCReductionOperator Operator, ArrayRef<Expr *> VarList,
1350-
ArrayRef<OpenACCReductionRecipe> Recipes, SourceLocation EndLoc);
1407+
ArrayRef<OpenACCReductionRecipeWithStorage> Recipes,
1408+
SourceLocation EndLoc);
13511409

13521410
OpenACCReductionOperator getReductionOp() const { return Op; }
13531411

13541412
size_t numTrailingObjects(OverloadToken<Expr *>) const {
13551413
return getExprs().size();
13561414
}
1415+
size_t numTrailingObjects(OverloadToken<OpenACCReductionRecipe>) const {
1416+
return getExprs().size();
1417+
}
13571418
};
13581419

13591420
class OpenACCLinkClause final

clang/include/clang/AST/OpenMPClause.h

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,18 +2291,68 @@ class OMPOrderedClause final
22912291
/// This represents 'nowait' clause in the '#pragma omp ...' directive.
22922292
///
22932293
/// \code
2294-
/// #pragma omp for nowait
2294+
/// #pragma omp for nowait (cond)
22952295
/// \endcode
2296-
/// In this example directive '#pragma omp for' has 'nowait' clause.
2297-
class OMPNowaitClause final : public OMPNoChildClause<llvm::omp::OMPC_nowait> {
2296+
/// In this example directive '#pragma omp for' has simple 'nowait' clause with
2297+
/// condition 'cond'.
2298+
class OMPNowaitClause final : public OMPClause {
2299+
friend class OMPClauseReader;
2300+
2301+
/// Location of '('.
2302+
SourceLocation LParenLoc;
2303+
2304+
/// Condition of the 'nowait' clause.
2305+
Stmt *Condition = nullptr;
2306+
2307+
/// Set condition.
2308+
void setCondition(Expr *Cond) { Condition = Cond; }
2309+
22982310
public:
2299-
/// Build 'nowait' clause.
2311+
/// Build 'nowait' clause with condition \a Cond.
23002312
///
2313+
/// \param Cond Condition of the clause.
23012314
/// \param StartLoc Starting location of the clause.
2315+
/// \param LParenLoc Location of '('.
23022316
/// \param EndLoc Ending location of the clause.
2303-
OMPNowaitClause(SourceLocation StartLoc = SourceLocation(),
2304-
SourceLocation EndLoc = SourceLocation())
2305-
: OMPNoChildClause(StartLoc, EndLoc) {}
2317+
OMPNowaitClause(Expr *Cond, SourceLocation StartLoc, SourceLocation LParenLoc,
2318+
SourceLocation EndLoc)
2319+
: OMPClause(llvm::omp::OMPC_nowait, StartLoc, EndLoc),
2320+
LParenLoc(LParenLoc), Condition(Cond) {}
2321+
2322+
/// Build an empty clause.
2323+
OMPNowaitClause()
2324+
: OMPClause(llvm::omp::OMPC_nowait, SourceLocation(), SourceLocation()) {}
2325+
2326+
/// Sets the location of '('.
2327+
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
2328+
2329+
/// Returns the location of '('.
2330+
SourceLocation getLParenLoc() const { return LParenLoc; }
2331+
2332+
/// Returns condition.
2333+
Expr *getCondition() const { return cast_or_null<Expr>(Condition); }
2334+
2335+
child_range children() {
2336+
if (Condition)
2337+
return child_range(&Condition, &Condition + 1);
2338+
return child_range(child_iterator(), child_iterator());
2339+
}
2340+
2341+
const_child_range children() const {
2342+
if (Condition)
2343+
return const_child_range(&Condition, &Condition + 1);
2344+
return const_child_range(const_child_iterator(), const_child_iterator());
2345+
}
2346+
2347+
child_range used_children();
2348+
const_child_range used_children() const {
2349+
auto Children = const_cast<OMPNowaitClause *>(this)->used_children();
2350+
return const_child_range(Children.begin(), Children.end());
2351+
}
2352+
2353+
static bool classof(const OMPClause *T) {
2354+
return T->getClauseKind() == llvm::omp::OMPC_nowait;
2355+
}
23062356
};
23072357

23082358
/// This represents 'untied' clause in the '#pragma omp ...' directive.

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3594,7 +3594,8 @@ bool RecursiveASTVisitor<Derived>::VisitOMPOrderedClause(OMPOrderedClause *C) {
35943594
}
35953595

35963596
template <typename Derived>
3597-
bool RecursiveASTVisitor<Derived>::VisitOMPNowaitClause(OMPNowaitClause *) {
3597+
bool RecursiveASTVisitor<Derived>::VisitOMPNowaitClause(OMPNowaitClause *C) {
3598+
TRY_TO(TraverseStmt(C->getCondition()));
35983599
return true;
35993600
}
36003601

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ def MissingFieldInitializers : DiagGroup<"missing-field-initializers",
631631
def ModuleLock : DiagGroup<"module-lock">;
632632
def ModuleBuild : DiagGroup<"module-build">;
633633
def ModuleImport : DiagGroup<"module-import">;
634+
def ModuleValidation : DiagGroup<"module-validation">;
634635
def ModuleConflict : DiagGroup<"module-conflict">;
635636
def ModuleFileExtension : DiagGroup<"module-file-extension">;
636637
def ModuleIncludeDirectiveTranslation : DiagGroup<"module-include-translation">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13665,6 +13665,11 @@ def warn_acc_var_referenced_lacks_op
1366513665
"reference has no effect">,
1366613666
InGroup<DiagGroup<"openacc-var-lacks-operation">>,
1366713667
DefaultError;
13668+
def err_acc_reduction_recipe_no_op
13669+
: Error<"variable of type %0 referenced in OpenACC 'reduction' clause does "
13670+
"not have a valid operation available">;
13671+
def note_acc_reduction_recipe_noop_field
13672+
: Note<"while forming combiner for compound type %0">;
1366813673

1366913674
// AMDGCN builtins diagnostics
1367013675
def err_amdgcn_load_lds_size_invalid_value : Error<"invalid size value">;

clang/include/clang/Basic/DiagnosticSerializationKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ def remark_module_import : Remark<
8686
"importing module '%0'%select{| into '%3'}2 from '%1'">,
8787
ShowInSystemHeader,
8888
InGroup<ModuleImport>;
89+
def remark_module_validation : Remark<
90+
"validating %0 input files in module '%1' from '%2'">,
91+
ShowInSystemHeader,
92+
InGroup<ModuleValidation>;
8993

9094
def err_imported_module_not_found : Error<
9195
"module '%0' in precompiled file '%1' %select{(imported by precompiled file '%2') |}4"

0 commit comments

Comments
 (0)