[compiler-rt] [rtsan][compiler-rt] Get rid of [[blocking]] stub in tests (PR #111392)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 7 09:59:10 PDT 2024


================
@@ -7,18 +7,11 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-// TODO: Remove when [[blocking]] is implemented.
-extern "C" void __rtsan_notify_blocking_call(const char *function_name);
-
-void custom_blocking_function() {
-  // TODO: When [[blocking]] is implemented, don't call this directly.
-  __rtsan_notify_blocking_call(__func__);
+void custom_blocking_function() [[clang::blocking]] {
+  printf("In blocking function\n");
 }
 
-void safe_call() {
-  // TODO: When [[blocking]] is implemented, don't call this directly.
-  __rtsan_notify_blocking_call(__func__);
-}
+void safe_call() [[clang::blocking]] { printf("In safe call\n"); }
----------------
davidtrevelyan wrote:

Oops - I missed the call to `safe_call` in `main` - my mistake. Anyway, if we wanted to make an improvement, I think we could organise `main` into:

```cpp
int main() {
    nonrealtime_function();
    realtime_function();
    return 0;
}
```

where the wrappers `nonrealtime_function` and `realtime_function` are simply:

```cpp
void realtime_function() [[clang::nonblocking]] { custom_blocking_function(); }
void nonrealtime_function() { custom_blocking_function(); }
```

and notice we have eliminated `safe_call`.

https://github.com/llvm/llvm-project/pull/111392


More information about the llvm-commits mailing list