Skip to content

Commit 67572f4

Browse files
author
z1.cciauto
committed
merge main into amd-staging
2 parents a9ebaa5 + 5c15caa commit 67572f4

File tree

143 files changed

+4092
-1939
lines changed

Some content is hidden

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

143 files changed

+4092
-1939
lines changed

.ci/metrics/metrics.py

Lines changed: 94 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,67 @@ class JobMetrics:
2626
workflow_id: int
2727

2828

29-
def get_metrics(github_repo: github.Repository, workflows_to_track: dict[str, int]):
29+
@dataclass
30+
class GaugeMetric:
31+
name: str
32+
value: int
33+
time_ns: int
34+
35+
36+
def get_sampled_workflow_metrics(github_repo: github.Repository):
37+
"""Gets global statistics about the Github workflow queue
38+
39+
Args:
40+
github_repo: A github repo object to use to query the relevant information.
41+
42+
Returns:
43+
Returns a list of GaugeMetric objects, containing the relevant metrics about
44+
the workflow
45+
"""
46+
47+
# Other states are available (pending, waiting, etc), but the meaning
48+
# is not documented (See #70540).
49+
# "queued" seems to be the info we want.
50+
queued_workflow_count = len(
51+
[
52+
x
53+
for x in github_repo.get_workflow_runs(status="queued")
54+
if x.name in WORKFLOWS_TO_TRACK
55+
]
56+
)
57+
running_workflow_count = len(
58+
[
59+
x
60+
for x in github_repo.get_workflow_runs(status="in_progress")
61+
if x.name in WORKFLOWS_TO_TRACK
62+
]
63+
)
64+
65+
workflow_metrics = []
66+
workflow_metrics.append(
67+
GaugeMetric(
68+
"workflow_queue_size",
69+
queued_workflow_count,
70+
time.time_ns(),
71+
)
72+
)
73+
workflow_metrics.append(
74+
GaugeMetric(
75+
"running_workflow_count",
76+
running_workflow_count,
77+
time.time_ns(),
78+
)
79+
)
80+
# Always send a hearbeat metric so we can monitor is this container is still able to log to Grafana.
81+
workflow_metrics.append(
82+
GaugeMetric("metrics_container_heartbeat", 1, time.time_ns())
83+
)
84+
return workflow_metrics
85+
86+
87+
def get_per_workflow_metrics(
88+
github_repo: github.Repository, workflows_to_track: dict[str, int]
89+
):
3090
"""Gets the metrics for specified Github workflows.
3191
3292
This function takes in a list of workflows to track, and optionally the
@@ -43,14 +103,14 @@ def get_metrics(github_repo: github.Repository, workflows_to_track: dict[str, in
43103
Returns a list of JobMetrics objects, containing the relevant metrics about
44104
the workflow.
45105
"""
46-
workflow_runs = iter(github_repo.get_workflow_runs())
47-
48106
workflow_metrics = []
49107

50108
workflows_to_include = set(workflows_to_track.keys())
51109

52-
while len(workflows_to_include) > 0:
53-
workflow_run = next(workflow_runs)
110+
for workflow_run in iter(github_repo.get_workflow_runs()):
111+
if len(workflows_to_include) == 0:
112+
break
113+
54114
if workflow_run.status != "completed":
55115
continue
56116

@@ -139,12 +199,27 @@ def upload_metrics(workflow_metrics, metrics_userid, api_key):
139199
metrics_userid: The userid to use for the upload.
140200
api_key: The API key to use for the upload.
141201
"""
202+
203+
if len(workflow_metrics) == 0:
204+
print("No metrics found to upload.", file=sys.stderr)
205+
return
206+
142207
metrics_batch = []
143208
for workflow_metric in workflow_metrics:
144-
workflow_formatted_name = workflow_metric.job_name.lower().replace(" ", "_")
145-
metrics_batch.append(
146-
f"{workflow_formatted_name} queue_time={workflow_metric.queue_time},run_time={workflow_metric.run_time},status={workflow_metric.status} {workflow_metric.created_at_ns}"
147-
)
209+
if isinstance(workflow_metric, GaugeMetric):
210+
name = workflow_metric.name.lower().replace(" ", "_")
211+
metrics_batch.append(
212+
f"{name} value={workflow_metric.value} {workflow_metric.time_ns}"
213+
)
214+
elif isinstance(workflow_metric, JobMetrics):
215+
name = workflow_metric.job_name.lower().replace(" ", "_")
216+
metrics_batch.append(
217+
f"{name} queue_time={workflow_metric.queue_time},run_time={workflow_metric.run_time},status={workflow_metric.status} {workflow_metric.created_at_ns}"
218+
)
219+
else:
220+
raise ValueError(
221+
f"Unsupported object type {type(workflow_metric)}: {str(workflow_metric)}"
222+
)
148223

149224
request_data = "\n".join(metrics_batch)
150225
response = requests.post(
@@ -176,16 +251,21 @@ def main():
176251
# Enter the main loop. Every five minutes we wake up and dump metrics for
177252
# the relevant jobs.
178253
while True:
179-
current_metrics = get_metrics(github_repo, workflows_to_track)
180-
if len(current_metrics) == 0:
181-
print("No metrics found to upload.", file=sys.stderr)
182-
continue
254+
current_metrics = get_per_workflow_metrics(github_repo, workflows_to_track)
255+
current_metrics += get_sampled_workflow_metrics(github_repo)
256+
# Always send a hearbeat metric so we can monitor is this container is still able to log to Grafana.
257+
current_metrics.append(
258+
GaugeMetric("metrics_container_heartbeat", 1, time.time_ns())
259+
)
183260

184261
upload_metrics(current_metrics, grafana_metrics_userid, grafana_api_key)
185262
print(f"Uploaded {len(current_metrics)} metrics", file=sys.stderr)
186263

187264
for workflow_metric in reversed(current_metrics):
188-
workflows_to_track[workflow_metric.job_name] = workflow_metric.workflow_id
265+
if isinstance(workflow_metric, JobMetrics):
266+
workflows_to_track[
267+
workflow_metric.job_name
268+
] = workflow_metric.workflow_id
189269

190270
time.sleep(SCRAPE_INTERVAL_SECONDS)
191271

clang/docs/Multilib.rst

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,73 @@ subclass and a suitable base multilib variant is present then the
122122
It is the responsibility of layered multilib authors to ensure that headers and
123123
libraries in each layer are complete enough to mask any incompatibilities.
124124

125+
Multilib custom flags
126+
=====================
127+
128+
Introduction
129+
------------
130+
131+
The multilib mechanism supports library variants that correspond to target,
132+
code generation or language command-line flags. Examples include ``--target``,
133+
``-mcpu``, ``-mfpu``, ``-mbranch-protection``, ``-fno-rtti``. However, some library
134+
variants are particular to features that do not correspond to any command-line
135+
option. Multithreading and semihosting, for instance, have no associated
136+
compiler option.
137+
138+
In order to support the selection of variants for which no compiler option
139+
exists, the multilib specification includes the concept of *custom flags*.
140+
These flags have no impact on code generation and are only used in the multilib
141+
processing.
142+
143+
Multilib custom flags follow this format in the driver invocation:
144+
145+
::
146+
147+
-fmultilib-flag=<value>
148+
149+
They are fed into the multilib system alongside the remaining flags.
150+
151+
Custom flag declarations
152+
------------------------
153+
154+
Custom flags can be declared in the YAML file under the *Flags* section.
155+
156+
.. code-block:: yaml
157+
158+
Flags:
159+
- Name: multithreaded
160+
Values:
161+
- Name: no-multithreaded
162+
MacroDefines: [__SINGLE_THREAD__]
163+
- Name: multithreaded
164+
Default: no-multithreaded
165+
166+
* Name: the name to categorize a flag.
167+
* Values: a list of flag Values (defined below).
168+
* Default: it specifies the name of the value this flag should take if not
169+
specified in the command-line invocation. It must be one value from the Values
170+
field.
171+
172+
Each flag *Value* is defined as:
173+
174+
* Name: name of the value. This is the string to be used in
175+
``-fmultilib-flag=<string>``.
176+
* MacroDefines: a list of strings to be used as macro definitions. Each string
177+
is fed into the driver as ``-D<string>``.
178+
179+
The namespace of flag values is common across all flags. This means that flag
180+
value names must be unique.
181+
182+
Usage of custom flags in the *Variants* specifications
183+
------------------------------------------------------
184+
185+
Library variants should list their requirement on one or more custom flags like
186+
they do for any other flag. Each requirement must be listed as
187+
``-fmultilib-flag=<value>``.
188+
189+
A variant that does not specify a requirement on one particular flag can be
190+
matched against any value of that flag.
191+
125192
Stability
126193
=========
127194

@@ -222,6 +289,23 @@ For a more comprehensive example see
222289
# Flags is a list of one or more strings.
223290
Flags: [--target=thumbv7m-none-eabi]
224291
292+
# Custom flag declarations. Each item is a different declaration.
293+
Flags:
294+
# Name of the flag
295+
- Name: multithreaded
296+
# List of custom flag values
297+
Values:
298+
# Name of the custom flag value. To be used in -fmultilib-flag=<string>.
299+
- Name: no-multithreaded
300+
# Macro definitions. Useful for defining extra macros for building the
301+
# associated library variant(s).
302+
MacroDefines: [__SINGLE_THREAD__]
303+
- Name: multithreaded
304+
# Default flag value. If no value for this flag declaration is used in the
305+
# command-line, the multilib system will use this one. Must be equal to one
306+
# of the flag value names from this flag declaration.
307+
Default: no-multithreaded
308+
225309
Design principles
226310
=================
227311

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,6 @@ C++23 Feature Support
321321
C++20 Feature Support
322322
^^^^^^^^^^^^^^^^^^^^^
323323

324-
- Implemented module level lookup for C++20 modules. (#GH90154)
325-
326324

327325
Resolutions to C++ Defect Reports
328326
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -984,6 +982,8 @@ Bug Fixes to C++ Support
984982
- Clang now identifies unexpanded parameter packs within the type constraint on a non-type template parameter. (#GH88866)
985983
- Fixed an issue while resolving type of expression indexing into a pack of values of non-dependent type (#GH121242)
986984
- Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (#GH121274)
985+
- Fixed a crash caused by the incorrect construction of template arguments for CTAD alias guides when type
986+
constraints are applied. (#GH122134)
987987

988988
Bug Fixes to AST Handling
989989
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/DeclBase.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -836,10 +836,6 @@ class alignas(8) Decl {
836836
return isFromASTFile() ? getImportedOwningModule() : getLocalOwningModule();
837837
}
838838

839-
/// Get the top level owning named module that owns this declaration if any.
840-
/// \returns nullptr if the declaration is not owned by a named module.
841-
Module *getTopLevelOwningNamedModule() const;
842-
843839
/// Get the module that owns this declaration for linkage purposes.
844840
/// There only ever is such a standard C++ module.
845841
Module *getOwningModuleForLinkage() const;
@@ -2726,12 +2722,6 @@ class DeclContext {
27262722
bool Deserialize = false) const;
27272723

27282724
private:
2729-
/// Lookup all external visible declarations and the external declarations
2730-
/// within the same module specified by \c NamedModule. We can't
2731-
/// get it from \c this since the same declaration may be declared in
2732-
/// multiple modules. e.g., namespace.
2733-
lookup_result lookupImpl(DeclarationName Name, Module *NamedModule) const;
2734-
27352725
/// Whether this declaration context has had externally visible
27362726
/// storage added since the last lookup. In this case, \c LookupPtr's
27372727
/// invariant may not hold and needs to be fixed before we perform

clang/include/clang/AST/ExternalASTMerger.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ class ExternalASTMerger : public ExternalASTSource {
141141

142142
/// Implementation of the ExternalASTSource API.
143143
bool FindExternalVisibleDeclsByName(const DeclContext *DC,
144-
DeclarationName Name,
145-
Module *NamedModule) override;
144+
DeclarationName Name) override;
146145

147146
/// Implementation of the ExternalASTSource API.
148147
void

clang/include/clang/AST/ExternalASTSource.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class RecordDecl;
5151
class Selector;
5252
class Stmt;
5353
class TagDecl;
54-
class Module;
5554

5655
/// Abstract interface for external sources of AST nodes.
5756
///
@@ -146,20 +145,12 @@ class ExternalASTSource : public RefCountedBase<ExternalASTSource> {
146145
/// Find all declarations with the given name in the given context,
147146
/// and add them to the context by calling SetExternalVisibleDeclsForName
148147
/// or SetNoExternalVisibleDeclsForName.
149-
/// \param DC the context for lookup.
150-
/// \param Name the name of the declarations to find.
151-
/// \param NamedModule find declarations visible to the given module
152-
/// \c NamedModule . This may be different from owning module of \c DC since
153-
/// there are declarations (e.g., namespace declaration) can appear in
154-
/// multiple modules.
155-
///
156-
/// \return \c true if any declarations might have been found, and \c false
157-
/// if we definitely have no declarations with this name.
148+
/// \return \c true if any declarations might have been found, \c false if
149+
/// we definitely have no declarations with tbis name.
158150
///
159151
/// The default implementation of this method is a no-op returning \c false.
160-
virtual bool FindExternalVisibleDeclsByName(const DeclContext *DC,
161-
DeclarationName Name,
162-
Module *NamedModule);
152+
virtual bool
153+
FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name);
163154

164155
/// Load all the external specializations for the Decl \param D if \param
165156
/// OnlyPartial is false. Otherwise, load all the external **partial**

clang/include/clang/Driver/Driver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ class Driver {
501501
/// ArgList.
502502
llvm::opt::InputArgList ParseArgStrings(ArrayRef<const char *> Args,
503503
bool UseDriverMode,
504-
bool &ContainsError);
504+
bool &ContainsError) const;
505505

506506
/// BuildInputs - Construct the list of inputs and their types from
507507
/// the given arguments.

clang/include/clang/Driver/Multilib.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,18 @@ class MultilibSet {
168168
const_iterator begin() const { return Multilibs.begin(); }
169169
const_iterator end() const { return Multilibs.end(); }
170170

171+
/// Process custom flags from \p Flags and returns an expanded flags list and
172+
/// a list of macro defines.
173+
/// Returns a pair where:
174+
/// - first: the new flags list including custom flags after processing.
175+
/// - second: the extra macro defines to be fed to the driver.
176+
std::pair<Multilib::flags_list, SmallVector<StringRef>>
177+
processCustomFlags(const Driver &D, const Multilib::flags_list &Flags) const;
178+
171179
/// Select compatible variants, \returns false if none are compatible
172180
bool select(const Driver &D, const Multilib::flags_list &Flags,
173-
llvm::SmallVectorImpl<Multilib> &) const;
181+
llvm::SmallVectorImpl<Multilib> &,
182+
llvm::SmallVector<StringRef> * = nullptr) const;
174183

175184
unsigned size() const { return Multilibs.size(); }
176185

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4261,9 +4261,9 @@ def ftrap_function_EQ : Joined<["-"], "ftrap-function=">, Group<f_Group>,
42614261
HelpText<"Issue call to specified function rather than a trap instruction">,
42624262
MarshallingInfoString<CodeGenOpts<"TrapFuncName">>;
42634263
def funroll_loops : Flag<["-"], "funroll-loops">, Group<f_Group>,
4264-
HelpText<"Turn on loop unroller">, Visibility<[ClangOption, CC1Option]>;
4264+
HelpText<"Turn on loop unroller">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>;
42654265
def fno_unroll_loops : Flag<["-"], "fno-unroll-loops">, Group<f_Group>,
4266-
HelpText<"Turn off loop unroller">, Visibility<[ClangOption, CC1Option]>;
4266+
HelpText<"Turn off loop unroller">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>;
42674267
def ffinite_loops: Flag<["-"], "ffinite-loops">, Group<f_Group>,
42684268
HelpText<"Assume all non-trivial loops are finite.">, Visibility<[ClangOption, CC1Option]>;
42694269
def fno_finite_loops: Flag<["-"], "fno-finite-loops">, Group<f_Group>,

clang/include/clang/Driver/ToolChain.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,13 @@ class ToolChain {
707707
/// Add warning options that need to be passed to cc1 for this target.
708708
virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const;
709709

710+
// Get the list of extra macro defines requested by the multilib
711+
// configuration.
712+
virtual SmallVector<std::string>
713+
getMultilibMacroDefinesStr(llvm::opt::ArgList &Args) const {
714+
return {};
715+
};
716+
710717
// GetRuntimeLibType - Determine the runtime library type to use with the
711718
// given compilation arguments.
712719
virtual RuntimeLibType

0 commit comments

Comments
 (0)