Skip to content

Commit a1e9b7e

Browse files
authored
Revert "[clang][rtsan] Introduce realtime sanitizer codegen and drive… (#105744)
…r (#102622)" This reverts commit d010ec6. Build failure: https://lab.llvm.org/buildbot/#/builders/159/builds/4466
1 parent 911e246 commit a1e9b7e

16 files changed

+5
-208
lines changed

clang/docs/RealtimeSanitizer.rst

-85
This file was deleted.

clang/docs/ReleaseNotes.rst

-5
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,6 @@ Moved checkers
454454

455455
Sanitizers
456456
----------
457-
- Introduced Realtime Sanitizer, activated by using the -fsanitize=realtime
458-
flag. This sanitizer detects unsafe system library calls, such as memory
459-
allocations and mutex locks. If any such function is called during invocation
460-
of a function marked with the ``[[clang::nonblocking]]`` attribute, an error
461-
is printed to the console and the process exits non-zero.
462457

463458
- Added the ``-fsanitize-undefined-ignore-overflow-pattern`` flag which can be
464459
used to disable specific overflow-dependent code patterns. The supported

clang/docs/UsersManual.rst

-2
Original file line numberDiff line numberDiff line change
@@ -2068,8 +2068,6 @@ are listed below.
20682068
integrity.
20692069
- ``-fsanitize=safe-stack``: :doc:`safe stack <SafeStack>`
20702070
protection against stack-based memory corruption errors.
2071-
- ``-fsanitize=realtime``: :doc:`RealtimeSanitizer`,
2072-
a real-time safety checker.
20732071

20742072
There are more fine-grained checks available: see
20752073
the :ref:`list <ubsan-checks>` of specific kinds of

clang/docs/index.rst

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ Using Clang as a Compiler
3232
UndefinedBehaviorSanitizer
3333
DataFlowSanitizer
3434
LeakSanitizer
35-
RealtimeSanitizer
3635
SanitizerCoverage
3736
SanitizerStats
3837
SanitizerSpecialCaseList

clang/include/clang/Basic/Sanitizers.def

-3
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ SANITIZER("thread", Thread)
7979
// Numerical stability sanitizer.
8080
SANITIZER("numerical", NumericalStability)
8181

82-
// RealtimeSanitizer
83-
SANITIZER("realtime", Realtime)
84-
8582
// LeakSanitizer
8683
SANITIZER("leak", Leak)
8784

clang/include/clang/Driver/SanitizerArgs.h

-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ class SanitizerArgs {
107107
bool needsNsanRt() const {
108108
return Sanitizers.has(SanitizerKind::NumericalStability);
109109
}
110-
bool needsRtsanRt() const { return Sanitizers.has(SanitizerKind::Realtime); }
111110

112111
bool hasMemTag() const {
113112
return hasMemtagHeap() || hasMemtagStack() || hasMemtagGlobals();

clang/lib/CodeGen/BackendUtil.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
7979
#include "llvm/Transforms/Instrumentation/NumericalStabilitySanitizer.h"
8080
#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"
81-
#include "llvm/Transforms/Instrumentation/RealtimeSanitizer.h"
8281
#include "llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h"
8382
#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
8483
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
@@ -991,13 +990,6 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
991990
FPM.addPass(BoundsCheckingPass());
992991
});
993992

994-
if (LangOpts.Sanitize.has(SanitizerKind::Realtime))
995-
PB.registerScalarOptimizerLateEPCallback(
996-
[](FunctionPassManager &FPM, OptimizationLevel Level) {
997-
RealtimeSanitizerOptions Opts;
998-
FPM.addPass(RealtimeSanitizerPass(Opts));
999-
});
1000-
1001993
// Don't add sanitizers if we are here from ThinLTO PostLink. That already
1002994
// done on PreLink stage.
1003995
if (!IsThinLTOPostLink) {

clang/lib/CodeGen/CodeGenFunction.cpp

-7
Original file line numberDiff line numberDiff line change
@@ -845,13 +845,6 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
845845
if (SanOpts.has(SanitizerKind::ShadowCallStack))
846846
Fn->addFnAttr(llvm::Attribute::ShadowCallStack);
847847

848-
if (SanOpts.has(SanitizerKind::Realtime))
849-
if (FD && FD->getASTContext().hasAnyFunctionEffects())
850-
for (const FunctionEffectWithCondition &Fe : FD->getFunctionEffects()) {
851-
if (Fe.Effect.kind() == FunctionEffect::Kind::NonBlocking)
852-
Fn->addFnAttr(llvm::Attribute::SanitizeRealtime);
853-
}
854-
855848
// Apply fuzzing attribute to the function.
856849
if (SanOpts.hasOneOf(SanitizerKind::Fuzzer | SanitizerKind::FuzzerNoLink))
857850
Fn->addFnAttr(llvm::Attribute::OptForFuzzing);

clang/lib/Driver/SanitizerArgs.cpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,11 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
558558
SanitizerKind::Leak | SanitizerKind::Thread |
559559
SanitizerKind::Memory | SanitizerKind::KernelAddress |
560560
SanitizerKind::Scudo | SanitizerKind::SafeStack),
561-
std::make_pair(SanitizerKind::MemTag, SanitizerKind::Address |
562-
SanitizerKind::KernelAddress |
563-
SanitizerKind::HWAddress |
564-
SanitizerKind::KernelHWAddress),
565-
std::make_pair(SanitizerKind::KCFI, SanitizerKind::Function),
566-
std::make_pair(SanitizerKind::Realtime,
567-
SanitizerKind::Address | SanitizerKind::Thread |
568-
SanitizerKind::Undefined | SanitizerKind::Memory)};
569-
561+
std::make_pair(SanitizerKind::MemTag,
562+
SanitizerKind::Address | SanitizerKind::KernelAddress |
563+
SanitizerKind::HWAddress |
564+
SanitizerKind::KernelHWAddress),
565+
std::make_pair(SanitizerKind::KCFI, SanitizerKind::Function)};
570566
// Enable toolchain specific default sanitizers if not explicitly disabled.
571567
SanitizerMask Default = TC.getDefaultSanitizers() & ~AllRemove;
572568

clang/lib/Driver/ToolChains/CommonArgs.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -1456,8 +1456,6 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
14561456
if (!Args.hasArg(options::OPT_shared))
14571457
HelperStaticRuntimes.push_back("hwasan-preinit");
14581458
}
1459-
if (SanArgs.needsRtsanRt() && SanArgs.linkRuntimes())
1460-
SharedRuntimes.push_back("rtsan");
14611459
}
14621460

14631461
// The stats_client library is also statically linked into DSOs.
@@ -1483,10 +1481,6 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
14831481
StaticRuntimes.push_back("asan_cxx");
14841482
}
14851483

1486-
if (!SanArgs.needsSharedRt() && SanArgs.needsRtsanRt() &&
1487-
SanArgs.linkRuntimes())
1488-
StaticRuntimes.push_back("rtsan");
1489-
14901484
if (!SanArgs.needsSharedRt() && SanArgs.needsMemProfRt()) {
14911485
StaticRuntimes.push_back("memprof");
14921486
if (SanArgs.linkCXXRuntimes())

clang/lib/Driver/ToolChains/Darwin.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -1519,8 +1519,6 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
15191519
const char *sanitizer = nullptr;
15201520
if (Sanitize.needsUbsanRt()) {
15211521
sanitizer = "UndefinedBehaviorSanitizer";
1522-
} else if (Sanitize.needsRtsanRt()) {
1523-
sanitizer = "RealtimeSanitizer";
15241522
} else if (Sanitize.needsAsanRt()) {
15251523
sanitizer = "AddressSanitizer";
15261524
} else if (Sanitize.needsTsanRt()) {
@@ -1543,11 +1541,6 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args,
15431541
AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
15441542
}
15451543
}
1546-
if (Sanitize.needsRtsanRt()) {
1547-
assert(Sanitize.needsSharedRt() &&
1548-
"Static sanitizer runtimes not supported");
1549-
AddLinkSanitizerLibArgs(Args, CmdArgs, "rtsan");
1550-
}
15511544
if (Sanitize.needsLsanRt())
15521545
AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
15531546
if (Sanitize.needsUbsanRt()) {
@@ -3546,7 +3539,6 @@ SanitizerMask Darwin::getSupportedSanitizers() const {
35463539
Res |= SanitizerKind::Address;
35473540
Res |= SanitizerKind::PointerCompare;
35483541
Res |= SanitizerKind::PointerSubtract;
3549-
Res |= SanitizerKind::Realtime;
35503542
Res |= SanitizerKind::Leak;
35513543
Res |= SanitizerKind::Fuzzer;
35523544
Res |= SanitizerKind::FuzzerNoLink;

clang/lib/Driver/ToolChains/Linux.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,6 @@ SanitizerMask Linux::getSupportedSanitizers() const {
800800
Res |= SanitizerKind::Address;
801801
Res |= SanitizerKind::PointerCompare;
802802
Res |= SanitizerKind::PointerSubtract;
803-
Res |= SanitizerKind::Realtime;
804803
Res |= SanitizerKind::Fuzzer;
805804
Res |= SanitizerKind::FuzzerNoLink;
806805
Res |= SanitizerKind::KernelAddress;

clang/test/CodeGen/rtsan_attribute_inserted.c

-7
This file was deleted.

clang/test/CodeGen/rtsan_entry_exit_insertion.c

-13
This file was deleted.

clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c

-6
This file was deleted.

clang/test/Driver/fsanitize.c

-46
Original file line numberDiff line numberDiff line change
@@ -1040,49 +1040,3 @@
10401040
// RUN: not %clang --target=aarch64-none-elf -fsanitize=dataflow %s -### 2>&1 | FileCheck %s -check-prefix=UNSUPPORTED-BAREMETAL
10411041
// RUN: not %clang --target=arm-arm-none-eabi -fsanitize=shadow-call-stack %s -### 2>&1 | FileCheck %s -check-prefix=UNSUPPORTED-BAREMETAL
10421042
// UNSUPPORTED-BAREMETAL: unsupported option '-fsanitize={{.*}}' for target
1043-
1044-
// RUN: %clang --target=x86_64-apple-darwin -fsanitize=realtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RTSAN-X86-64-DARWIN
1045-
// CHECK-RTSAN-X86-64-DARWIN-NOT: unsupported option
1046-
1047-
// RUN: %clang --target=x86_64-apple-darwin -fsanitize=realtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RTSAN-X86-64-DARWIN
1048-
// CHECK-RTSAN-X86-64-DARWIN-NOT: unsupported option
1049-
// RUN: %clang --target=x86_64-apple-macos -fsanitize=realtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RTSAN-X86-64-MACOS
1050-
// CHECK-RTSAN-X86-64-MACOS-NOT: unsupported option
1051-
// RUN: %clang --target=arm64-apple-macos -fsanitize=realtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RTSAN-ARM64-MACOS
1052-
// CHECK-RTSAN-ARM64-MACOS-NOT: unsupported option
1053-
1054-
// RUN: %clang --target=arm64-apple-ios-simulator -fsanitize=realtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RTSAN-ARM64-IOSSIMULATOR
1055-
// CHECK-RTSAN-ARM64-IOSSIMULATOR-NOT: unsupported option
1056-
1057-
// RUN: %clang --target=arm64-apple-watchos-simulator -fsanitize=realtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RTSAN-ARM64-WATCHOSSIMULATOR
1058-
// CHECK-RTSAN-ARM64-WATCHOSSIMULATOR-NOT: unsupported option
1059-
1060-
// RUN: %clang --target=arm64-apple-tvos-simulator -fsanitize=realtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RTSAN-ARM64-TVOSSIMULATOR
1061-
// CHECK-RTSAN-ARM64-TVOSSIMULATOR-NOT: unsupported option
1062-
1063-
// RUN: %clang --target=x86_64-apple-ios-simulator -fsanitize=realtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RTSAN-X86-64-IOSSIMULATOR
1064-
// CHECK-RTSAN-X86-64-IOSSIMULATOR-NOT: unsupported option
1065-
1066-
// RUN: %clang --target=x86_64-apple-watchos-simulator -fsanitize=realtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RTSAN-X86-64-WATCHOSSIMULATOR
1067-
// CHECK-RTSAN-X86-64-WATCHOSSIMULATOR-NOT: unsupported option
1068-
1069-
// RUN: %clang --target=x86_64-apple-tvos-simulator -fsanitize=realtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RTSAN-X86-64-TVOSSIMULATOR
1070-
// CHECK-RTSAN-X86-64-TVOSSIMULATOR-NOT: unsupported option
1071-
1072-
// RUN: %clang --target=x86_64-linux-gnu -fsanitize=realtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RTSAN-X86-64-LINUX
1073-
// CHECK-RTSAN-X86-64-LINUX-NOT: unsupported option
1074-
1075-
// RUN: not %clang --target=i386-pc-openbsd -fsanitize=realtime %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-RTSAN-OPENBSD
1076-
// CHECK-RTSAN-OPENBSD: unsupported option '-fsanitize=realtime' for target 'i386-pc-openbsd'
1077-
1078-
// RUN: not %clang --target=x86_64-linux-gnu -fsanitize=realtime,thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-REALTIME-TSAN
1079-
// CHECK-REALTIME-TSAN: error: invalid argument '-fsanitize=realtime' not allowed with '-fsanitize=thread'
1080-
1081-
// RUN: not %clang --target=x86_64-linux-gnu -fsanitize=realtime,address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-REALTIME-ASAN
1082-
// CHECK-REALTIME-ASAN: error: invalid argument '-fsanitize=realtime' not allowed with '-fsanitize=address'
1083-
1084-
// RUN: not %clang --target=x86_64-linux-gnu -fsanitize=realtime,memory %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-REALTIME-MSAN
1085-
// CHECK-REALTIME-MSAN: error: invalid argument '-fsanitize=realtime' not allowed with '-fsanitize=memory'
1086-
1087-
// RUN: not %clang --target=x86_64-linux-gnu -fsanitize=realtime,undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-REALTIME-UBSAN
1088-
// CHECK-REALTIME-UBSAN: error: invalid argument '-fsanitize=realtime' not allowed with '-fsanitize=undefined'

0 commit comments

Comments
 (0)