Skip to content

Commit 9a7f9dd

Browse files
committed
merge main into amd-staging
Change-Id: I490fc040a8bdf48556e002cf1edc5e853c734008
2 parents cecd30e + 75c1c26 commit 9a7f9dd

File tree

69 files changed

+691
-307
lines changed

Some content is hidden

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

69 files changed

+691
-307
lines changed

clang-tools-extra/modularize/CoverageChecker.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,9 @@ bool CoverageChecker::collectModuleHeaders(const Module &Mod) {
223223
return false;
224224
}
225225

226-
for (auto &HeaderKind : Mod.Headers)
227-
for (auto &Header : HeaderKind)
228-
ModuleMapHeadersSet.insert(
229-
ModularizeUtilities::getCanonicalPath(Header.Entry.getName()));
226+
for (const auto &Header : Mod.getAllHeaders())
227+
ModuleMapHeadersSet.insert(
228+
ModularizeUtilities::getCanonicalPath(Header.Entry.getName()));
230229

231230
for (auto *Submodule : Mod.submodules())
232231
collectModuleHeaders(*Submodule);

clang-tools-extra/modularize/ModularizeUtilities.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ bool ModularizeUtilities::collectModuleHeaders(const clang::Module &Mod) {
358358
} else if (std::optional<clang::Module::DirectoryName> UmbrellaDir =
359359
Mod.getUmbrellaDirAsWritten()) {
360360
// If there normal headers, assume these are umbrellas and skip collection.
361-
if (Mod.Headers->size() == 0) {
361+
if (Mod.getHeaders(Module::HK_Normal).empty()) {
362362
// Collect headers in umbrella directory.
363363
if (!collectUmbrellaHeaders(UmbrellaDir->Entry.getName(),
364364
UmbrellaDependents))
@@ -371,16 +371,8 @@ bool ModularizeUtilities::collectModuleHeaders(const clang::Module &Mod) {
371371
// modules or because they are meant to be included by another header,
372372
// and thus should be ignored by modularize.
373373

374-
int NormalHeaderCount = Mod.Headers[clang::Module::HK_Normal].size();
375-
376-
for (int Index = 0; Index < NormalHeaderCount; ++Index) {
377-
DependentsVector NormalDependents;
378-
// Collect normal header.
379-
const clang::Module::Header &Header(
380-
Mod.Headers[clang::Module::HK_Normal][Index]);
381-
std::string HeaderPath = getCanonicalPath(Header.Entry.getName());
382-
HeaderFileNames.push_back(HeaderPath);
383-
}
374+
for (const auto &Header : Mod.getHeaders(clang::Module::HK_Normal))
375+
HeaderFileNames.push_back(getCanonicalPath(Header.Entry.getName()));
384376

385377
int MissingCountThisModule = Mod.MissingHeaders.size();
386378

clang/docs/RealtimeSanitizer.rst

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ A **partial** list of flags RealtimeSanitizer respects:
183183
- ``true``
184184
- boolean
185185
- If set, use the symbolizer to turn virtual addresses to file/line locations. If false, can greatly speed up the error reporting.
186+
* - ``suppressions``
187+
- ""
188+
- path
189+
- If set to a valid suppressions file, will suppress issue reporting. See details in "Disabling", below.
186190

187191

188192
Some issues with flags can be debugged using the ``verbosity=$NUM`` flag:
@@ -194,12 +198,43 @@ Some issues with flags can be debugged using the ``verbosity=$NUM`` flag:
194198
misspelled_flag
195199
...
196200
197-
Disabling
198-
---------
201+
Disabling and suppressing
202+
-------------------------
199203

200-
In some circumstances, you may want to suppress error reporting in a specific scope.
204+
There are multiple ways to disable error reporting when using RealtimeSanitizer.
201205

202-
In C++, this is achieved via ``__rtsan::ScopedDisabler``. Within the scope where the ``ScopedDisabler`` object is instantiated, all sanitizer error reports are suppressed. This suppression applies to the current scope as well as all invoked functions, including any functions called transitively.
206+
In general, ``ScopedDisabler`` should be preferred, as it is the most performant.
207+
208+
.. list-table:: Suppression methods
209+
:widths: 30 15 15 10 70
210+
:header-rows: 1
211+
212+
* - Method
213+
- Specified at?
214+
- Scope
215+
- Run-time cost
216+
- Description
217+
* - ``ScopedDisabler``
218+
- Compile-time
219+
- Stack
220+
- Very low
221+
- Violations are ignored for the lifetime of the ``ScopedDisabler`` object.
222+
* - ``function-name-matches`` suppression
223+
- Run-time
224+
- Single function
225+
- Medium
226+
- Suppresses intercepted and ``[[clang::blocking]]`` function calls by name.
227+
* - ``call-stack-contains`` suppression
228+
- Run-time
229+
- Stack
230+
- High
231+
- Suppresses any stack trace contaning the specified pattern.
232+
233+
234+
``ScopedDisabler``
235+
##################
236+
237+
At compile time, RealtimeSanitizer may be disabled using ``__rtsan::ScopedDisabler``. RTSan ignores any errors originating within the ``ScopedDisabler`` instance variable scope.
203238

204239
.. code-block:: c++
205240

@@ -233,6 +268,31 @@ In C, you can use the ``__rtsan_disable()`` and ``rtsan_enable()`` functions to
233268

234269
Each call to ``__rtsan_disable()`` must be paired with a subsequent call to ``__rtsan_enable()`` to restore normal sanitizer functionality. If a corresponding ``rtsan_enable()`` call is not made, the behavior is undefined.
235270

271+
Suppression file
272+
################
273+
274+
At run-time, suppressions may be specified using a suppressions file passed in ``RTSAN_OPTIONS``. Run-time suppression may be useful if the source cannot be changed.
275+
276+
.. code-block:: console
277+
278+
> cat suppressions.supp
279+
call-stack-contains:MallocViolation
280+
call-stack-contains:std::*vector
281+
function-name-matches:free
282+
function-name-matches:CustomMarkedBlocking*
283+
> RTSAN_OPTIONS="suppressions=suppressions.supp" ./a.out
284+
...
285+
286+
Suppressions specified in this file are one of two flavors.
287+
288+
``function-name-matches`` suppresses reporting of any intercepted library call, or function marked ``[[clang::blocking]]`` by name. If, for instance, you know that ``malloc`` is real-time safe on your system, you can disable the check for it via ``function-name-matches:malloc``.
289+
290+
``call-stack-contains`` suppresses reporting of errors in any stack that contains a string matching the pattern specified. For example, suppressing error reporting of any non-real-time-safe behavior in ``std::vector`` may be specified ``call-stack-contains:std::*vector``. You must include symbols in your build for this method to be effective, unsymbolicated stack traces cannot be matched. ``call-stack-contains`` has the highest run-time cost of any method of suppression.
291+
292+
Patterns may be exact matches or are "regex-light" patterns, containing special characters such as ``^$*``.
293+
294+
The number of potential errors suppressed via this method may be seen on exit when using the ``print_stats_on_exit`` flag.
295+
236296
Compile-time sanitizer detection
237297
--------------------------------
238298

clang/docs/ReleaseNotes.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,15 @@ NetBSD Support
719719
WebAssembly Support
720720
^^^^^^^^^^^^^^^^^^^
721721

722+
The default target CPU, "generic", now enables the `-mnontrapping-fptoint`
723+
and `-mbulk-memory` flags, which correspond to the [Bulk Memory Operations]
724+
and [Non-trapping float-to-int Conversions] language features, which are
725+
[widely implemented in engines].
726+
727+
[Bulk Memory Operations]: https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
728+
[Non-trapping float-to-int Conversions]: https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
729+
[widely implemented in engines]: https://webassembly.org/features/
730+
722731
AVR Support
723732
^^^^^^^^^^^
724733

clang/include/clang/Basic/AMDGPUTypes.def

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515
AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)
1616
#endif
1717

18+
#ifndef AMDGPU_NAMED_BARRIER_TYPE
19+
#define AMDGPU_NAMED_BARRIER_TYPE(Name, Id, SingletonId, Width, Align, Scope) \
20+
AMDGPU_TYPE(Name, Id, SingletonId, Width, Align)
21+
#endif
22+
1823
AMDGPU_OPAQUE_PTR_TYPE("__amdgpu_buffer_rsrc_t", AMDGPUBufferRsrc, AMDGPUBufferRsrcTy, 128, 128, 8)
1924

25+
AMDGPU_NAMED_BARRIER_TYPE("__amdgpu_named_workgroup_barrier_t", AMDGPUNamedWorkgroupBarrier, AMDGPUNamedWorkgroupBarrierTy, 128, 32, 0)
26+
2027
#undef AMDGPU_TYPE
2128
#undef AMDGPU_OPAQUE_PTR_TYPE
29+
#undef AMDGPU_NAMED_BARRIER_TYPE

clang/include/clang/Basic/Module.h

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,6 @@ class alignas(8) Module {
253253
HK_PrivateTextual,
254254
HK_Excluded
255255
};
256-
static const int NumHeaderKinds = HK_Excluded + 1;
257-
258256
/// Information about a header directive as found in the module map
259257
/// file.
260258
struct Header {
@@ -263,17 +261,36 @@ class alignas(8) Module {
263261
FileEntryRef Entry;
264262
};
265263

266-
/// Information about a directory name as found in the module map
267-
/// file.
264+
private:
265+
static const int NumHeaderKinds = HK_Excluded + 1;
266+
// The begin index for a HeaderKind also acts the end index of HeaderKind - 1.
267+
// The extra element at the end acts as the end index of the last HeaderKind.
268+
unsigned HeaderKindBeginIndex[NumHeaderKinds + 1] = {};
269+
SmallVector<Header, 2> HeadersStorage;
270+
271+
public:
272+
ArrayRef<Header> getAllHeaders() const { return HeadersStorage; }
273+
ArrayRef<Header> getHeaders(HeaderKind HK) const {
274+
assert(HK < NumHeaderKinds && "Invalid Module::HeaderKind");
275+
auto BeginIt = HeadersStorage.begin() + HeaderKindBeginIndex[HK];
276+
auto EndIt = HeadersStorage.begin() + HeaderKindBeginIndex[HK + 1];
277+
return {BeginIt, EndIt};
278+
}
279+
void addHeader(HeaderKind HK, Header H) {
280+
assert(HK < NumHeaderKinds && "Invalid Module::HeaderKind");
281+
auto EndIt = HeadersStorage.begin() + HeaderKindBeginIndex[HK + 1];
282+
HeadersStorage.insert(EndIt, std::move(H));
283+
for (unsigned HKI = HK + 1; HKI != NumHeaderKinds + 1; ++HKI)
284+
++HeaderKindBeginIndex[HKI];
285+
}
286+
287+
/// Information about a directory name as found in the module map file.
268288
struct DirectoryName {
269289
std::string NameAsWritten;
270290
std::string PathRelativeToRootModuleDirectory;
271291
DirectoryEntryRef Entry;
272292
};
273293

274-
/// The headers that are part of this module.
275-
SmallVector<Header, 2> Headers[5];
276-
277294
/// Stored information about a header directive that was found in the
278295
/// module map file but has not been resolved to a file.
279296
struct UnresolvedHeaderDirective {

clang/include/clang/Lex/Preprocessor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ class Preprocessor {
14901490
/// Mark the file as included.
14911491
/// Returns true if this is the first time the file was included.
14921492
bool markIncluded(FileEntryRef File) {
1493-
HeaderInfo.getFileInfo(File);
1493+
HeaderInfo.getFileInfo(File).IsLocallyIncluded = true;
14941494
return IncludedFiles.insert(File).second;
14951495
}
14961496

clang/include/clang/Serialization/ASTBitCodes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ enum PredefinedTypeIDs {
11491149
///
11501150
/// Type IDs for non-predefined types will start at
11511151
/// NUM_PREDEF_TYPE_IDs.
1152-
const unsigned NUM_PREDEF_TYPE_IDS = 512;
1152+
const unsigned NUM_PREDEF_TYPE_IDS = 513;
11531153

11541154
// Ensure we do not overrun the predefined types we reserved
11551155
// in the enum PredefinedTypeIDs above.

clang/lib/Basic/Module.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ void Module::print(raw_ostream &OS, unsigned Indent, bool Dump) const {
528528

529529
for (auto &K : Kinds) {
530530
assert(&K == &Kinds[K.Kind] && "kinds in wrong order");
531-
for (auto &H : Headers[K.Kind]) {
531+
for (auto &H : getHeaders(K.Kind)) {
532532
OS.indent(Indent + 2);
533533
OS << K.Prefix << "header \"";
534534
OS.write_escaped(H.NameAsWritten);

clang/lib/Basic/Targets/WebAssembly.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,20 @@ bool WebAssemblyTargetInfo::initFeatureMap(
154154
llvm::StringMap<bool> &Features, DiagnosticsEngine &Diags, StringRef CPU,
155155
const std::vector<std::string> &FeaturesVec) const {
156156
auto addGenericFeatures = [&]() {
157+
Features["bulk-memory"] = true;
157158
Features["multivalue"] = true;
158159
Features["mutable-globals"] = true;
160+
Features["nontrapping-fptoint"] = true;
159161
Features["reference-types"] = true;
160162
Features["sign-ext"] = true;
161163
};
162164
auto addBleedingEdgeFeatures = [&]() {
163165
addGenericFeatures();
164166
Features["atomics"] = true;
165-
Features["bulk-memory"] = true;
166167
Features["exception-handling"] = true;
167168
Features["extended-const"] = true;
168169
Features["fp16"] = true;
169170
Features["multimemory"] = true;
170-
Features["nontrapping-fptoint"] = true;
171171
Features["tail-call"] = true;
172172
Features["wide-arithmetic"] = true;
173173
setSIMDLevel(Features, RelaxedSIMD, true);

0 commit comments

Comments
 (0)