diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index cf3fc8180168a..28cbf4ead63c7 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -1264,15 +1264,6 @@ def Const : InheritableAttr { let SimpleHandler = 1; } -def Realtime : InheritableAttr { - let Spellings = [CXX11<"clang", "realtime">, - C23<"clang", "realtime">, - GCC<"realtime">]; - let Subjects = SubjectList<[Function]>; - let Documentation = [Undocumented]; - let SimpleHandler = 1; -} - def ConstInit : InheritableAttr { // This attribute does not have a C [[]] spelling because it requires the // CPlusPlus language option. diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 9e9d1a70279ea..274eb91f8658e 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -7619,13 +7619,6 @@ its underlying representation to be a WebAssembly ``funcref``. }]; } -def RealtimeDocs : Documentation { - let Category = DocCatFunction; - let Heading = "Realtime Attribute"; - let Content = [{ - }]; -} - def PreferredTypeDocumentation : Documentation { let Category = DocCatField; let Content = [{ diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index f9dfd6efeeaae..fe994a100b4cf 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -2384,8 +2384,6 @@ void CodeGenModule::ConstructAttributeList(StringRef Name, FuncAttrs.addAttribute(llvm::Attribute::NoDuplicate); if (TargetDecl->hasAttr()) FuncAttrs.addAttribute(llvm::Attribute::Convergent); - if (TargetDecl->hasAttr()) - FuncAttrs.addAttribute(llvm::Attribute::Realtime); if (const FunctionDecl *Fn = dyn_cast(TargetDecl)) { AddAttributesFromFunctionProtoType( @@ -2406,6 +2404,12 @@ void CodeGenModule::ConstructAttributeList(StringRef Name, FuncAttrs.addAttribute(llvm::Attribute::NoReturn); NBA = Fn->getAttr(); } + + for (const FunctionEffectWithCondition& Fe : Fn->getFunctionEffects()) { + if (Fe.Effect.kind() == FunctionEffect::Kind::NonBlocking) { + FuncAttrs.addAttribute(llvm::Attribute::NonBlocking); + } + } } if (isa(TargetDecl) || isa(TargetDecl)) { diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 06219769c66da..6a726f396244c 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1592,7 +1592,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, insertCallAtFunctionEntryPoint(Fn, "radsan_off"); } - if (Fn->hasFnAttribute(llvm::Attribute::Realtime)) { + if (Fn->hasFnAttribute(llvm::Attribute::NonBlocking)) { insertCallAtFunctionEntryPoint(Fn, "radsan_realtime_enter"); } } @@ -1605,7 +1605,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn, insertCallAtAllFunctionExitPoints(Fn, "radsan_on"); } - if (Fn->hasFnAttribute(llvm::Attribute::Realtime)) { + if (Fn->hasFnAttribute(llvm::Attribute::NonBlocking)) { insertCallAtAllFunctionExitPoints(Fn, "radsan_realtime_exit"); } } diff --git a/compiler-rt/lib/radsan/radsan.h b/compiler-rt/lib/radsan/radsan.h index 853cddc6927ec..4472fb566ef63 100644 --- a/compiler-rt/lib/radsan/radsan.h +++ b/compiler-rt/lib/radsan/radsan.h @@ -52,7 +52,7 @@ RADSAN_EXPORT void radsan_realtime_exit(); Example: - [[clang::realtime]] float process (float x) + float process (float x) [[clang::nonblocking]] { auto const y = 2.0f * x; diff --git a/compiler-rt/lib/radsan/tests/radsan_test_utilities.h b/compiler-rt/lib/radsan/tests/radsan_test_utilities.h index fb50ee77156e9..83411b3e5e8d3 100644 --- a/compiler-rt/lib/radsan/tests/radsan_test_utilities.h +++ b/compiler-rt/lib/radsan/tests/radsan_test_utilities.h @@ -14,7 +14,8 @@ namespace radsan_testing { template -[[clang::realtime]] void realtimeInvoke(Function &&func) { +void realtimeInvoke(Function &&func) [[clang::nonblocking]] +{ std::forward(func)(); } diff --git a/compiler-rt/test/radsan/TestCases/test_bypass_nosanitize.cpp b/compiler-rt/test/radsan/TestCases/test_bypass_nosanitize.cpp index 6dcd70fbfa3d7..143817b02326d 100644 --- a/compiler-rt/test/radsan/TestCases/test_bypass_nosanitize.cpp +++ b/compiler-rt/test/radsan/TestCases/test_bypass_nosanitize.cpp @@ -21,7 +21,7 @@ void violationLock(pthread_mutex_t& Mutex) { pthread_mutex_lock(&Mutex); } -[[clang::realtime]] void process(pthread_mutex_t& Mutex) { +void process(pthread_mutex_t& Mutex) [[clang::nonblocking]] { bypassedLock(Mutex); bypassedUnlock(Mutex); diff --git a/compiler-rt/test/radsan/TestCases/test_continue_mode.cpp b/compiler-rt/test/radsan/TestCases/test_continue_mode.cpp index 0eb6ccb1aaa90..1cb92723c0460 100644 --- a/compiler-rt/test/radsan/TestCases/test_continue_mode.cpp +++ b/compiler-rt/test/radsan/TestCases/test_continue_mode.cpp @@ -19,7 +19,7 @@ void freeViolation(void* Ptr) { free(Ptr); } -[[clang::realtime]] void process() { +void process() [[clang::nonblocking]] { void* Ptr = mallocViolation(); freeViolation(Ptr); } diff --git a/compiler-rt/test/radsan/TestCases/test_free_nosanitize_has_no_effect.cpp b/compiler-rt/test/radsan/TestCases/test_free_nosanitize_has_no_effect.cpp index 3809cdbefd2b7..777239085f3a6 100644 --- a/compiler-rt/test/radsan/TestCases/test_free_nosanitize_has_no_effect.cpp +++ b/compiler-rt/test/radsan/TestCases/test_free_nosanitize_has_no_effect.cpp @@ -3,7 +3,7 @@ // UNSUPPORTED: ios // Intent: Ensure that a no_sanitize attribute has no impact -// if not in a [[clang::realtime]] function +// if not in a [[clang::nonblocking]] function #include #include diff --git a/compiler-rt/test/radsan/TestCases/test_nosanitize_radsan_inactive.cpp b/compiler-rt/test/radsan/TestCases/test_nosanitize_radsan_inactive.cpp index d191c0a5129cd..e4df679692907 100644 --- a/compiler-rt/test/radsan/TestCases/test_nosanitize_radsan_inactive.cpp +++ b/compiler-rt/test/radsan/TestCases/test_nosanitize_radsan_inactive.cpp @@ -2,7 +2,7 @@ // RUN: %run %t 2>&1 | FileCheck %s // UNSUPPORTED: ios -// Intent: Ensure that no_sanitize and [[clang::realtime]] +// Intent: Ensure that no_sanitize and [[clang::nonblocking]] // have no impact if -fsanitize=realtime is not used #include @@ -13,7 +13,7 @@ void noSanitizeFree(void* Ptr) { free(Ptr); } -[[clang::realtime]] void violation() { +void violation() [[clang::nonblocking]]{ void* Ptr = malloc(2); noSanitizeFree(Ptr); } diff --git a/compiler-rt/test/radsan/TestCases/test_radsan.cpp b/compiler-rt/test/radsan/TestCases/test_radsan.cpp index 6a9c2c3db3c2a..fef5152fb05cf 100644 --- a/compiler-rt/test/radsan/TestCases/test_radsan.cpp +++ b/compiler-rt/test/radsan/TestCases/test_radsan.cpp @@ -2,12 +2,12 @@ // RUN: not %run %t 2>&1 | FileCheck %s // UNSUPPORTED: ios -// Intent: Ensure that an intercepted call in a [[clang::realtime]] function +// Intent: Ensure that an intercepted call in a [[clang::nonblocking]] function // is flagged as an error. Basic smoke test. #include -[[clang::realtime]] void violation() { +void violation() [[clang::nonblocking]]{ void* Ptr = malloc(2); } diff --git a/compiler-rt/test/radsan/TestCases/test_radsan_inactive.cpp b/compiler-rt/test/radsan/TestCases/test_radsan_inactive.cpp index 91e942da8e466..ffcc3a1cafef6 100644 --- a/compiler-rt/test/radsan/TestCases/test_radsan_inactive.cpp +++ b/compiler-rt/test/radsan/TestCases/test_radsan_inactive.cpp @@ -2,14 +2,14 @@ // RUN: %run %t 2>&1 | FileCheck %s // UNSUPPORTED: ios -// Intent: Ensure [[clang::realtime]] has no impact if -fsanitize=realtime is not used +// Intent: Ensure [[clang::nonblocking]] has no impact if -fsanitize=realtime is not used #include #include // In this test, we don't use the -fsanitize=realtime flag, so nothing // should happen here -[[clang::realtime]] void violation() { +void violation() [[clang::nonblocking]] { void* Ptr = malloc(2); } diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 2aca78ed888cf..1d0999d7fd51d 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -2139,7 +2139,7 @@ example: for this function. ``nosanitize_realtime`` This attribute indicates that SanitizerRealtime is disabled for this - function. If called from a function marked ``clang::realtime``, no + function. If called from a function marked ``clang::nonblocking``, no errors that would normally be reported by SanitizerRealtime will be reported. ``null_pointer_is_valid`` diff --git a/llvm/include/llvm/Bitcode/LLVMBitCodes.h b/llvm/include/llvm/Bitcode/LLVMBitCodes.h index 8a9cb9be996c5..d5bba8352a7f0 100644 --- a/llvm/include/llvm/Bitcode/LLVMBitCodes.h +++ b/llvm/include/llvm/Bitcode/LLVMBitCodes.h @@ -744,7 +744,7 @@ enum AttributeKindCodes { ATTR_KIND_CORO_ONLY_DESTROY_WHEN_COMPLETE = 90, ATTR_KIND_DEAD_ON_UNWIND = 91, ATTR_KIND_RANGE = 92, - ATTR_KIND_REALTIME = 93, + ATTR_KIND_NONBLOCKING = 93, ATTR_KIND_NO_SANITIZE_REALTIME = 94, }; diff --git a/llvm/include/llvm/IR/Attributes.td b/llvm/include/llvm/IR/Attributes.td index 49a75c0b2ebeb..c0a262eccf53e 100644 --- a/llvm/include/llvm/IR/Attributes.td +++ b/llvm/include/llvm/IR/Attributes.td @@ -233,8 +233,8 @@ def ReadNone : EnumAttr<"readnone", [ParamAttr]>; /// Function only reads from memory. def ReadOnly : EnumAttr<"readonly", [ParamAttr]>; -/// Function is marked to be analyzed by the realtime sanitizer. -def Realtime : EnumAttr<"realtime", [FnAttr]>; +/// Function is marked to be non-blocking +def NonBlocking : EnumAttr<"nonblocking", [FnAttr]>; /// Return value is always equal to this argument. def Returned : EnumAttr<"returned", [ParamAttr]>; diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 992e242a35f86..719a8058dc07b 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2076,8 +2076,8 @@ static Attribute::AttrKind getAttrFromCode(uint64_t Code) { return Attribute::ReadOnly; case bitc::ATTR_KIND_RETURNED: return Attribute::Returned; - case bitc::ATTR_KIND_REALTIME: - return Attribute::Realtime; + case bitc::ATTR_KIND_NONBLOCKING: + return Attribute::NonBlocking; case bitc::ATTR_KIND_NO_SANITIZE_REALTIME: return Attribute::NoSanitizeRealtime; case bitc::ATTR_KIND_RETURNS_TWICE: diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index f0de38f09af9b..dde1f098bcd47 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -783,8 +783,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) { return bitc::ATTR_KIND_OPTIMIZE_FOR_SIZE; case Attribute::OptimizeNone: return bitc::ATTR_KIND_OPTIMIZE_NONE; - case Attribute::Realtime: - return bitc::ATTR_KIND_REALTIME; + case Attribute::NonBlocking: + return bitc::ATTR_KIND_NONBLOCKING; case Attribute::NoSanitizeRealtime: return bitc::ATTR_KIND_NO_SANITIZE_REALTIME; case Attribute::ReadNone: diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index b2b045e8173ce..144d16cc3b684 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -968,7 +968,7 @@ Function *CodeExtractor::constructFunction(const ValueSet &inputs, case Attribute::MustProgress: case Attribute::NoProfile: case Attribute::SkipProfile: - case Attribute::Realtime: + case Attribute::NonBlocking: case Attribute::NoSanitizeRealtime: break; // These attributes cannot be applied to functions.