Skip to content

Commit e631981

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-resumephi-vpinst-for-reductions
2 parents 99af3f5 + 7fe149c commit e631981

File tree

324 files changed

+16247
-1120
lines changed

Some content is hidden

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

324 files changed

+16247
-1120
lines changed

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
@@ -690,6 +690,15 @@ NetBSD Support
690690
WebAssembly Support
691691
^^^^^^^^^^^^^^^^^^^
692692

693+
The default target CPU, "generic", now enables the `-mnontrapping-fptoint`
694+
and `-mbulk-memory` flags, which correspond to the [Bulk Memory Operations]
695+
and [Non-trapping float-to-int Conversions] language features, which are
696+
[widely implemented in engines].
697+
698+
[Bulk Memory Operations]: https://github.com/WebAssembly/bulk-memory-operations/blob/master/proposals/bulk-memory-operations/Overview.md
699+
[Non-trapping float-to-int Conversions]: https://github.com/WebAssembly/spec/blob/master/proposals/nontrapping-float-to-int-conversion/Overview.md
700+
[widely implemented in engines]: https://webassembly.org/features/
701+
693702
AVR Support
694703
^^^^^^^^^^^
695704

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/AST/ByteCode/Interp.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ bool CheckConstant(InterpState &S, CodePtr OpPC, const Descriptor *Desc) {
400400
}
401401

402402
static bool CheckConstant(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
403-
if (!Ptr.isBlockPointer())
403+
if (!Ptr.isStatic() || !Ptr.isBlockPointer())
404404
return true;
405405
return CheckConstant(S, OpPC, Ptr.getDeclDesc());
406406
}
@@ -513,8 +513,8 @@ bool CheckMutable(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
513513
return false;
514514
}
515515

516-
bool CheckVolatile(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
517-
AccessKinds AK) {
516+
static bool CheckVolatile(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
517+
AccessKinds AK) {
518518
assert(Ptr.isLive());
519519

520520
// FIXME: This check here might be kinda expensive. Maybe it would be better

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);

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
852852
if (Fe.Effect.kind() == FunctionEffect::Kind::NonBlocking)
853853
Fn->addFnAttr(llvm::Attribute::SanitizeRealtime);
854854
else if (Fe.Effect.kind() == FunctionEffect::Kind::Blocking)
855-
Fn->addFnAttr(llvm::Attribute::SanitizeRealtimeUnsafe);
855+
Fn->addFnAttr(llvm::Attribute::SanitizeRealtimeBlocking);
856856
}
857857

858858
// Apply fuzzing attribute to the function.

clang/lib/Lex/HeaderSearch.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,6 @@ bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor &PP,
15821582
}
15831583
}
15841584

1585-
FileInfo.IsLocallyIncluded = true;
15861585
IsFirstIncludeOfFile = PP.markIncluded(File);
15871586
return true;
15881587
}

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,8 +2163,8 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
21632163
continue; // We have no information on this being a header file.
21642164
if (!HFI->isCompilingModuleHeader && HFI->isModuleHeader)
21652165
continue; // Header file info is tracked by the owning module file.
2166-
if (!HFI->isCompilingModuleHeader && !PP->alreadyIncluded(*File))
2167-
continue; // Non-modular header not included is not needed.
2166+
if (!HFI->isCompilingModuleHeader && !HFI->IsLocallyIncluded)
2167+
continue; // Header file info is tracked by the including module file.
21682168

21692169
// Massage the file path into an appropriate form.
21702170
StringRef Filename = File->getName();
@@ -2176,7 +2176,7 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
21762176
SavedStrings.push_back(Filename.data());
21772177
}
21782178

2179-
bool Included = PP->alreadyIncluded(*File);
2179+
bool Included = HFI->IsLocallyIncluded || PP->alreadyIncluded(*File);
21802180

21812181
HeaderFileInfoTrait::key_type Key = {
21822182
Filename, File->getSize(), getTimestampForOutput(*File)

clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp

Lines changed: 12 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -513,70 +513,25 @@ ProgramStateRef ExprEngine::updateObjectsUnderConstruction(
513513
static ProgramStateRef
514514
bindRequiredArrayElementToEnvironment(ProgramStateRef State,
515515
const ArrayInitLoopExpr *AILE,
516-
const LocationContext *LCtx, SVal Idx) {
517-
// The ctor in this case is guaranteed to be a copy ctor, otherwise we hit a
518-
// compile time error.
519-
//
520-
// -ArrayInitLoopExpr <-- we're here
521-
// |-OpaqueValueExpr
522-
// | `-DeclRefExpr <-- match this
523-
// `-CXXConstructExpr
524-
// `-ImplicitCastExpr
525-
// `-ArraySubscriptExpr
526-
// |-ImplicitCastExpr
527-
// | `-OpaqueValueExpr
528-
// | `-DeclRefExpr
529-
// `-ArrayInitIndexExpr
530-
//
531-
// The resulting expression might look like the one below in an implicit
532-
// copy/move ctor.
533-
//
534-
// ArrayInitLoopExpr <-- we're here
535-
// |-OpaqueValueExpr
536-
// | `-MemberExpr <-- match this
537-
// | (`-CXXStaticCastExpr) <-- move ctor only
538-
// | `-DeclRefExpr
539-
// `-CXXConstructExpr
540-
// `-ArraySubscriptExpr
541-
// |-ImplicitCastExpr
542-
// | `-OpaqueValueExpr
543-
// | `-MemberExpr
544-
// | `-DeclRefExpr
545-
// `-ArrayInitIndexExpr
546-
//
547-
// The resulting expression for a multidimensional array.
548-
// ArrayInitLoopExpr <-- we're here
549-
// |-OpaqueValueExpr
550-
// | `-DeclRefExpr <-- match this
551-
// `-ArrayInitLoopExpr
552-
// |-OpaqueValueExpr
553-
// | `-ArraySubscriptExpr
554-
// | |-ImplicitCastExpr
555-
// | | `-OpaqueValueExpr
556-
// | | `-DeclRefExpr
557-
// | `-ArrayInitIndexExpr
558-
// `-CXXConstructExpr <-- extract this
559-
// ` ...
560-
561-
const auto *OVESrc = AILE->getCommonExpr()->getSourceExpr();
516+
const LocationContext *LCtx, NonLoc Idx) {
517+
SValBuilder &SVB = State->getStateManager().getSValBuilder();
518+
MemRegionManager &MRMgr = SVB.getRegionManager();
519+
ASTContext &Ctx = SVB.getContext();
562520

563521
// HACK: There is no way we can put the index of the array element into the
564522
// CFG unless we unroll the loop, so we manually select and bind the required
565523
// parameter to the environment.
566-
const auto *CE =
524+
const Expr *SourceArray = AILE->getCommonExpr()->getSourceExpr();
525+
const auto *Ctor =
567526
cast<CXXConstructExpr>(extractElementInitializerFromNestedAILE(AILE));
568527

569-
SVal Base = UnknownVal();
570-
if (const auto *ME = dyn_cast<MemberExpr>(OVESrc))
571-
Base = State->getSVal(ME, LCtx);
572-
else if (const auto *DRE = dyn_cast<DeclRefExpr>(OVESrc))
573-
Base = State->getLValue(cast<VarDecl>(DRE->getDecl()), LCtx);
574-
else
575-
llvm_unreachable("ArrayInitLoopExpr contains unexpected source expression");
576-
577-
SVal NthElem = State->getLValue(CE->getType(), Idx, Base);
528+
const auto *SourceArrayRegion =
529+
cast<SubRegion>(State->getSVal(SourceArray, LCtx).getAsRegion());
530+
const ElementRegion *ElementRegion =
531+
MRMgr.getElementRegion(Ctor->getType(), Idx, SourceArrayRegion, Ctx);
578532

579-
return State->BindExpr(CE->getArg(0), LCtx, NthElem);
533+
return State->BindExpr(Ctor->getArg(0), LCtx,
534+
loc::MemRegionVal(ElementRegion));
580535
}
581536

582537
void ExprEngine::handleConstructor(const Expr *E,

0 commit comments

Comments
 (0)