Skip to content

Commit 47a0c6b

Browse files
authored
Merge branch 'main' into fix-dxil-container-unbounded-array
2 parents 124796f + 3f3ffed commit 47a0c6b

File tree

103 files changed

+3136
-282
lines changed

Some content is hidden

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

103 files changed

+3136
-282
lines changed

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM docker.io/library/ubuntu:24.04 AS base
22
ENV LLVM_SYSROOT=/opt/llvm
33

44
FROM base AS stage1-toolchain
5-
ENV LLVM_VERSION=21.1.1
5+
ENV LLVM_VERSION=21.1.3
66

77
RUN apt-get update && \
88
apt-get install -y \

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/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/CIR/Dialect/IR/CIRAttrs.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,14 @@ def CIR_GlobalCtorAttr : CIR_GlobalCtorDtor<"Ctor", "ctor"> {
814814
}];
815815
}
816816

817+
def CIR_GlobalDtorAttr : CIR_GlobalCtorDtor<"Dtor", "dtor"> {
818+
let summary = "Marks a function as a global destructor";
819+
let description = [{
820+
Marks a function as a global destructor in the module dtors list.
821+
The function will be executed before the module unloading.
822+
}];
823+
}
824+
817825
//===----------------------------------------------------------------------===//
818826
// BitfieldInfoAttr
819827
//===----------------------------------------------------------------------===//

clang/include/clang/CIR/Dialect/IR/CIRDialect.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def CIR_Dialect : Dialect {
4343
static llvm::StringRef getSideEffectAttrName() { return "side_effect"; }
4444
static llvm::StringRef getModuleLevelAsmAttrName() { return "cir.module_asm"; }
4545
static llvm::StringRef getGlobalCtorsAttrName() { return "cir.global_ctors"; }
46+
static llvm::StringRef getGlobalDtorsAttrName() { return "cir.global_dtors"; }
4647

4748
void registerAttributes();
4849
void registerTypes();

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ class CIR_Op<string mnemonic, list<Trait> traits = []> :
8888
code extraLLVMLoweringPatternDecl = "";
8989
}
9090

91+
//===----------------------------------------------------------------------===//
92+
// CIR Operation Traits
93+
//===----------------------------------------------------------------------===//
94+
95+
class HasAtMostOneOfAttrsPred<list<string> names> :
96+
CPred<!foldl("0", names, acc, name, acc # " + (" # name # " ? 1 : 0)")
97+
# " <= 1">;
98+
99+
class HasAtMostOneOfAttrs<list<string> names> : PredOpTrait<
100+
"has only one of the optional attributes: " # !interleave(names, ", "),
101+
HasAtMostOneOfAttrsPred<!foreach(name, names, "$" # name)>
102+
>;
103+
91104
//===----------------------------------------------------------------------===//
92105
// CastOp
93106
//===----------------------------------------------------------------------===//
@@ -2422,9 +2435,17 @@ def CIR_GetMemberOp : CIR_Op<"get_member"> {
24222435
// TODO(CIR): FuncOp is still a tiny shell of what it will become. Many more
24232436
// properties and attributes will be added as upstreaming continues.
24242437

2438+
def CIR_OptionalPriorityAttr : OptionalAttr<
2439+
DefaultValuedAttr<
2440+
ConfinedAttr<I32Attr, [IntMinValue<101>, IntMaxValue<65535>]>,
2441+
"65535"
2442+
>
2443+
>;
2444+
24252445
def CIR_FuncOp : CIR_Op<"func", [
24262446
AutomaticAllocationScope, CallableOpInterface, FunctionOpInterface,
24272447
DeclareOpInterfaceMethods<CIRGlobalValueInterface>,
2448+
HasAtMostOneOfAttrs<["global_ctor_priority", "global_dtor_priority"]>,
24282449
IsolatedFromAbove
24292450
]> {
24302451
let summary = "Declare or define a function";
@@ -2449,6 +2470,12 @@ def CIR_FuncOp : CIR_Op<"func", [
24492470
without a prototype and, consequently, may contain calls with invalid
24502471
arguments and undefined behavior.
24512472

2473+
The `global_ctor` keyword indicates whether a function should execute before
2474+
`main()` function, as specified by `__attribute__((constructor))`. An
2475+
execution priority can also be specified `global_ctor(<priority>)`.
2476+
Similarly, for global destructors both `global_dtor` and
2477+
`global_dtor(<priority>)` are available.
2478+
24522479
Example:
24532480

24542481
```mlir
@@ -2487,7 +2514,9 @@ def CIR_FuncOp : CIR_Op<"func", [
24872514
UnitAttr:$comdat,
24882515
OptionalAttr<DictArrayAttr>:$arg_attrs,
24892516
OptionalAttr<DictArrayAttr>:$res_attrs,
2490-
OptionalAttr<FlatSymbolRefAttr>:$aliasee);
2517+
OptionalAttr<FlatSymbolRefAttr>:$aliasee,
2518+
CIR_OptionalPriorityAttr:$global_ctor_priority,
2519+
CIR_OptionalPriorityAttr:$global_dtor_priority);
24912520

24922521
let regions = (region AnyRegion:$body);
24932522

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ struct MissingFeatures {
3939
static bool opGlobalUsedOrCompilerUsed() { return false; }
4040
static bool opGlobalAnnotations() { return false; }
4141
static bool opGlobalCtorPriority() { return false; }
42-
static bool opGlobalDtorList() { return false; }
4342
static bool setDSOLocal() { return false; }
4443
static bool setComdat() { return false; }
4544

@@ -175,6 +174,10 @@ struct MissingFeatures {
175174
static bool atomicScope() { return false; }
176175
static bool atomicSyncScopeID() { return false; }
177176

177+
// Global ctor handling
178+
static bool globalCtorLexOrder() { return false; }
179+
static bool globalCtorAssociatedData() { return false; }
180+
178181
// Misc
179182
static bool abiArgInfo() { return false; }
180183
static bool addHeapAllocSiteMetadata() { return false; }

0 commit comments

Comments
 (0)