[clang] [compiler-rt] [llvm] [rtsan][llvm][NFC] Rename sanitize_realtime_unsafe attr to sanitize_realtime_blocking (PR #113155)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 22 13:03:42 PDT 2024
https://github.com/davidtrevelyan updated https://github.com/llvm/llvm-project/pull/113155
>From bf6c3c2a7953aff02549b0d03ef84fb846ad9d12 Mon Sep 17 00:00:00 2001
From: David Trevelyan <david.trevelyan at gmail.com>
Date: Mon, 21 Oct 2024 12:04:22 +0100
Subject: [PATCH 1/2] [rtsan][llvm][NFC] Rename sanitize_realtime_unsafe attr
to *_blocking
---
clang/lib/CodeGen/CodeGenFunction.cpp | 2 +-
clang/test/CodeGen/rtsan_attribute_inserted.c | 2 +-
clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c | 2 +-
compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp | 4 ++--
llvm/docs/LangRef.rst | 2 +-
llvm/include/llvm/Bitcode/LLVMBitCodes.h | 2 +-
llvm/include/llvm/IR/Attributes.td | 4 ++--
llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 ++--
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 4 ++--
llvm/lib/IR/Verifier.cpp | 4 ++--
llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp | 6 +++---
llvm/lib/Transforms/Utils/CodeExtractor.cpp | 2 +-
llvm/test/Bitcode/attributes.ll | 4 ++--
llvm/test/Bitcode/compatibility.ll | 6 +++---
.../{rtsan_unsafe.ll => rtsan_blocking.ll} | 4 ++--
llvm/test/Verifier/rtsan-attrs.ll | 4 ++--
16 files changed, 28 insertions(+), 28 deletions(-)
rename llvm/test/Instrumentation/RealtimeSanitizer/{rtsan_unsafe.ll => rtsan_blocking.ll} (87%)
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 465dc8c661af5c..d793a05086d83d 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -852,7 +852,7 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
if (Fe.Effect.kind() == FunctionEffect::Kind::NonBlocking)
Fn->addFnAttr(llvm::Attribute::SanitizeRealtime);
else if (Fe.Effect.kind() == FunctionEffect::Kind::Blocking)
- Fn->addFnAttr(llvm::Attribute::SanitizeRealtimeUnsafe);
+ Fn->addFnAttr(llvm::Attribute::SanitizeRealtimeBlocking);
}
// Apply fuzzing attribute to the function.
diff --git a/clang/test/CodeGen/rtsan_attribute_inserted.c b/clang/test/CodeGen/rtsan_attribute_inserted.c
index b21ecb6b6b06a9..cebfe43c81234c 100644
--- a/clang/test/CodeGen/rtsan_attribute_inserted.c
+++ b/clang/test/CodeGen/rtsan_attribute_inserted.c
@@ -8,4 +8,4 @@ float process(float *a) [[clang::nonblocking]] { return *a; }
int spinlock(int *a) [[clang::blocking]] { return *a; }
// CHECK: @spinlock{{.*}} #1 {
// CHECK: attributes #1 = {
-// CHECK-SAME: {{.*sanitize_realtime_unsafe .*}}
+// CHECK-SAME: {{.*sanitize_realtime_blocking .*}}
diff --git a/clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c b/clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c
index 0f43007c5e4c16..86305080c94ace 100644
--- a/clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c
+++ b/clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c
@@ -5,4 +5,4 @@ int spinlock(int *a) [[clang::blocking]] { return *a; }
// Without the -fsanitize=realtime flag, we shouldn't attach the attributes.
// CHECK-NOT: {{.*sanitize_realtime .*}}
-// CHECK-NOT: {{.*sanitize_realtime_unsafe .*}}
+// CHECK-NOT: {{.*sanitize_realtime_blocking .*}}
diff --git a/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp b/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
index 9e455f0326a549..ed9ee4ded7b059 100644
--- a/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
+++ b/compiler-rt/lib/rtsan/tests/rtsan_test_functional.cpp
@@ -204,11 +204,11 @@ TEST(TestRtsan, ThrowingAnExceptionDiesWhenRealtime) {
TEST(TestRtsan, DoesNotDieIfTurnedOff) {
std::mutex mutex;
- auto RealtimeUnsafeFunc = [&]() {
+ auto RealtimeBlockingFunc = [&]() {
__rtsan_disable();
mutex.lock();
mutex.unlock();
__rtsan_enable();
};
- RealtimeInvoke(RealtimeUnsafeFunc);
+ RealtimeInvoke(RealtimeBlockingFunc);
}
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index b83675c6ed97aa..f9ec33da1b651b 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -2334,7 +2334,7 @@ example:
This attribute indicates that RealtimeSanitizer checks
(realtime safety analysis - no allocations, syscalls or exceptions) are enabled
for this function.
-``sanitize_realtime_unsafe``
+``sanitize_realtime_blocking``
This attribute indicates that RealtimeSanitizer should error immediately
if the attributed function is called during invocation of a function
attributed with ``sanitize_realtime``.
diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
index 08574cc356e514..41a6447356c23b 100644
--- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h
+++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h
@@ -768,7 +768,7 @@ enum AttributeKindCodes {
ATTR_KIND_INITIALIZES = 94,
ATTR_KIND_HYBRID_PATCHABLE = 95,
ATTR_KIND_SANITIZE_REALTIME = 96,
- ATTR_KIND_SANITIZE_REALTIME_UNSAFE = 97,
+ ATTR_KIND_SANITIZE_REALTIME_BLOCKING = 97,
ATTR_KIND_CORO_ELIDE_SAFE = 98,
ATTR_KIND_NO_EXT = 99,
ATTR_KIND_NO_DIVERGENCE_SOURCE = 100,
diff --git a/llvm/include/llvm/IR/Attributes.td b/llvm/include/llvm/IR/Attributes.td
index b6d36a5f7ae4fb..49f4527bde66e7 100644
--- a/llvm/include/llvm/IR/Attributes.td
+++ b/llvm/include/llvm/IR/Attributes.td
@@ -334,7 +334,7 @@ def SanitizeRealtime : EnumAttr<"sanitize_realtime", IntersectPreserve, [FnAttr]
/// RealtimeSanitizer should error if a real-time unsafe function is invoked
/// during a real-time sanitized function (see `sanitize_realtime`).
-def SanitizeRealtimeUnsafe : EnumAttr<"sanitize_realtime_unsafe", IntersectPreserve, [FnAttr]>;
+def SanitizeRealtimeBlocking : EnumAttr<"sanitize_realtime_blocking", IntersectPreserve, [FnAttr]>;
/// Speculative Load Hardening is enabled.
///
@@ -430,7 +430,7 @@ def : CompatRule<"isEqual<SanitizeHWAddressAttr>">;
def : CompatRule<"isEqual<SanitizeMemTagAttr>">;
def : CompatRule<"isEqual<SanitizeNumericalStabilityAttr>">;
def : CompatRule<"isEqual<SanitizeRealtimeAttr>">;
-def : CompatRule<"isEqual<SanitizeRealtimeUnsafeAttr>">;
+def : CompatRule<"isEqual<SanitizeRealtimeBlockingAttr>">;
def : CompatRule<"isEqual<SafeStackAttr>">;
def : CompatRule<"isEqual<ShadowCallStackAttr>">;
def : CompatRule<"isEqual<UseSampleProfileAttr>">;
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 5a6fb5064b3166..47421462216718 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -2165,8 +2165,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) {
return Attribute::SanitizeNumericalStability;
case bitc::ATTR_KIND_SANITIZE_REALTIME:
return Attribute::SanitizeRealtime;
- case bitc::ATTR_KIND_SANITIZE_REALTIME_UNSAFE:
- return Attribute::SanitizeRealtimeUnsafe;
+ case bitc::ATTR_KIND_SANITIZE_REALTIME_BLOCKING:
+ return Attribute::SanitizeRealtimeBlocking;
case bitc::ATTR_KIND_SPECULATIVE_LOAD_HARDENING:
return Attribute::SpeculativeLoadHardening;
case bitc::ATTR_KIND_SWIFT_ERROR:
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index d9002149fba55a..ee9cc4b6e0c0eb 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -853,8 +853,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) {
return bitc::ATTR_KIND_SANITIZE_NUMERICAL_STABILITY;
case Attribute::SanitizeRealtime:
return bitc::ATTR_KIND_SANITIZE_REALTIME;
- case Attribute::SanitizeRealtimeUnsafe:
- return bitc::ATTR_KIND_SANITIZE_REALTIME_UNSAFE;
+ case Attribute::SanitizeRealtimeBlocking:
+ return bitc::ATTR_KIND_SANITIZE_REALTIME_BLOCKING;
case Attribute::SpeculativeLoadHardening:
return bitc::ATTR_KIND_SPECULATIVE_LOAD_HARDENING;
case Attribute::SwiftError:
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index f34fe7594c8602..bd90f8c9921486 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2235,9 +2235,9 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
}
Check(!(Attrs.hasFnAttr(Attribute::SanitizeRealtime) &&
- Attrs.hasFnAttr(Attribute::SanitizeRealtimeUnsafe)),
+ Attrs.hasFnAttr(Attribute::SanitizeRealtimeBlocking)),
"Attributes "
- "'sanitize_realtime and sanitize_realtime_unsafe' are incompatible!",
+ "'sanitize_realtime and sanitize_realtime_blocking' are incompatible!",
V);
if (Attrs.hasFnAttr(Attribute::OptimizeForDebugging)) {
diff --git a/llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp
index c4cb72ab2e4da9..88cb04695217d5 100644
--- a/llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp
@@ -69,7 +69,7 @@ static PreservedAnalyses runSanitizeRealtime(Function &Fn) {
return rtsanPreservedCFGAnalyses();
}
-static PreservedAnalyses runSanitizeRealtimeUnsafe(Function &Fn) {
+static PreservedAnalyses runSanitizeRealtimeBlocking(Function &Fn) {
IRBuilder<> Builder(&Fn.front().front());
Value *Name = Builder.CreateGlobalString(demangle(Fn.getName()));
insertCallAtFunctionEntryPoint(Fn, "__rtsan_notify_blocking_call", {Name});
@@ -84,8 +84,8 @@ PreservedAnalyses RealtimeSanitizerPass::run(Function &Fn,
if (Fn.hasFnAttribute(Attribute::SanitizeRealtime))
return runSanitizeRealtime(Fn);
- if (Fn.hasFnAttribute(Attribute::SanitizeRealtimeUnsafe))
- return runSanitizeRealtimeUnsafe(Fn);
+ if (Fn.hasFnAttribute(Attribute::SanitizeRealtimeBlocking))
+ return runSanitizeRealtimeBlocking(Fn);
return PreservedAnalyses::all();
}
diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
index 15b26a38cc28ef..ed4ad15e5ab695 100644
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -953,7 +953,7 @@ Function *CodeExtractor::constructFunction(const ValueSet &inputs,
case Attribute::SanitizeHWAddress:
case Attribute::SanitizeMemTag:
case Attribute::SanitizeRealtime:
- case Attribute::SanitizeRealtimeUnsafe:
+ case Attribute::SanitizeRealtimeBlocking:
case Attribute::SpeculativeLoadHardening:
case Attribute::StackProtect:
case Attribute::StackProtectReq:
diff --git a/llvm/test/Bitcode/attributes.ll b/llvm/test/Bitcode/attributes.ll
index 737f49aa86a7ba..492de663884df4 100644
--- a/llvm/test/Bitcode/attributes.ll
+++ b/llvm/test/Bitcode/attributes.ll
@@ -512,7 +512,7 @@ define void @f92() sanitize_realtime
}
; CHECK: define void @f93() #54
-define void @f93() sanitize_realtime_unsafe {
+define void @f93() sanitize_realtime_blocking {
ret void;
}
@@ -616,7 +616,7 @@ define void @initializes(ptr initializes((-4, 0), (4, 8)) %a) {
; CHECK: attributes #51 = { uwtable(sync) }
; CHECK: attributes #52 = { nosanitize_bounds }
; CHECK: attributes #53 = { sanitize_realtime }
-; CHECK: attributes #54 = { sanitize_realtime_unsafe }
+; CHECK: attributes #54 = { sanitize_realtime_blocking }
; CHECK: attributes [[FNRETTHUNKEXTERN]] = { fn_ret_thunk_extern }
; CHECK: attributes [[SKIPPROFILE]] = { skipprofile }
; CHECK: attributes [[OPTDEBUG]] = { optdebug }
diff --git a/llvm/test/Bitcode/compatibility.ll b/llvm/test/Bitcode/compatibility.ll
index 280c3a99d7535f..39b01a3e8c21b2 100644
--- a/llvm/test/Bitcode/compatibility.ll
+++ b/llvm/test/Bitcode/compatibility.ll
@@ -2048,8 +2048,8 @@ declare void @f.sanitize_numerical_stability() sanitize_numerical_stability
declare void @f.sanitize_realtime() sanitize_realtime
; CHECK: declare void @f.sanitize_realtime() #52
-declare void @f.sanitize_realtime_unsafe() sanitize_realtime_unsafe
-; CHECK: declare void @f.sanitize_realtime_unsafe() #53
+declare void @f.sanitize_realtime_blocking() sanitize_realtime_unsafe
+; CHECK: declare void @f.sanitize_realtime_blocking() #53
; CHECK: declare nofpclass(snan) float @nofpclass_snan(float nofpclass(snan))
declare nofpclass(snan) float @nofpclass_snan(float nofpclass(snan))
@@ -2183,7 +2183,7 @@ define float @nofpclass_callsites(float %arg, { float } %arg1) {
; CHECK: attributes #50 = { allockind("alloc,uninitialized") }
; CHECK: attributes #51 = { sanitize_numerical_stability }
; CHECK: attributes #52 = { sanitize_realtime }
-; CHECK: attributes #53 = { sanitize_realtime_unsafe }
+; CHECK: attributes #53 = { sanitize_realtime_blocking }
; CHECK: attributes #54 = { builtin }
;; Metadata
diff --git a/llvm/test/Instrumentation/RealtimeSanitizer/rtsan_unsafe.ll b/llvm/test/Instrumentation/RealtimeSanitizer/rtsan_blocking.ll
similarity index 87%
rename from llvm/test/Instrumentation/RealtimeSanitizer/rtsan_unsafe.ll
rename to llvm/test/Instrumentation/RealtimeSanitizer/rtsan_blocking.ll
index 5abf5de3044816..80eb28c3923c2d 100644
--- a/llvm/test/Instrumentation/RealtimeSanitizer/rtsan_unsafe.ll
+++ b/llvm/test/Instrumentation/RealtimeSanitizer/rtsan_blocking.ll
@@ -25,7 +25,7 @@ define noundef i32 @main() #2 {
ret i32 0
}
-attributes #0 = { mustprogress noinline sanitize_realtime_unsafe optnone ssp uwtable(sync) }
+attributes #0 = { mustprogress noinline sanitize_realtime_blocking optnone ssp uwtable(sync) }
;.
-; CHECK: attributes #[[ATTR0]] = { mustprogress noinline optnone sanitize_realtime_unsafe ssp uwtable(sync) }
+; CHECK: attributes #[[ATTR0]] = { mustprogress noinline optnone sanitize_realtime_blocking ssp uwtable(sync) }
;.
diff --git a/llvm/test/Verifier/rtsan-attrs.ll b/llvm/test/Verifier/rtsan-attrs.ll
index fcc44d8d63c1de..c813266b434f8c 100644
--- a/llvm/test/Verifier/rtsan-attrs.ll
+++ b/llvm/test/Verifier/rtsan-attrs.ll
@@ -1,9 +1,9 @@
; RUN: not llvm-as -disable-output %s 2>&1 | FileCheck %s
-; CHECK: Attributes 'sanitize_realtime and sanitize_realtime_unsafe' are incompatible!
+; CHECK: Attributes 'sanitize_realtime and sanitize_realtime_blocking' are incompatible!
; CHECK-NEXT: ptr @sanitize_unsafe
define void @sanitize_unsafe() #0 {
ret void
}
-attributes #0 = { sanitize_realtime sanitize_realtime_unsafe }
+attributes #0 = { sanitize_realtime sanitize_realtime_blocking }
>From 4a76f06075ea541ce785fae8aa7b4ae582e6cbb6 Mon Sep 17 00:00:00 2001
From: David Trevelyan <david.trevelyan at gmail.com>
Date: Tue, 22 Oct 2024 21:03:13 +0100
Subject: [PATCH 2/2] Fix missed replacement in Bitcode test
---
llvm/test/Bitcode/compatibility.ll | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/test/Bitcode/compatibility.ll b/llvm/test/Bitcode/compatibility.ll
index 39b01a3e8c21b2..a849789da536ac 100644
--- a/llvm/test/Bitcode/compatibility.ll
+++ b/llvm/test/Bitcode/compatibility.ll
@@ -2048,7 +2048,7 @@ declare void @f.sanitize_numerical_stability() sanitize_numerical_stability
declare void @f.sanitize_realtime() sanitize_realtime
; CHECK: declare void @f.sanitize_realtime() #52
-declare void @f.sanitize_realtime_blocking() sanitize_realtime_unsafe
+declare void @f.sanitize_realtime_blocking() sanitize_realtime_blocking
; CHECK: declare void @f.sanitize_realtime_blocking() #53
; CHECK: declare nofpclass(snan) float @nofpclass_snan(float nofpclass(snan))
More information about the cfe-commits
mailing list