-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[rtsan][compiler-rt] Get rid of [[blocking]] stub in tests #111392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Chris Apple (cjappl) ChangesAdded the printfs to ensure we wouldn't have these empty functions compiled out. Full diff: https://github.com/llvm/llvm-project/pull/111392.diff 1 Files Affected:
diff --git a/compiler-rt/test/rtsan/blocking_call.cpp b/compiler-rt/test/rtsan/blocking_call.cpp
index 47ce3d5544cbd6..7bc46f24fd5432 100644
--- a/compiler-rt/test/rtsan/blocking_call.cpp
+++ b/compiler-rt/test/rtsan/blocking_call.cpp
@@ -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"); }
void process() [[clang::nonblocking]] { custom_blocking_function(); }
@@ -28,7 +21,7 @@ int main() {
return 0;
// CHECK-NOT: {{.*safe_call*}}
// CHECK: ==ERROR: RealtimeSanitizer: blocking-call
- // CHECK-NEXT: Call to blocking function `custom_blocking_function` in real-time context!
+ // CHECK-NEXT: Call to blocking function `custom_blocking_function()` in real-time context!
// CHECK-NEXT: {{.*custom_blocking_function*}}
// CHECK-NEXT: {{.*process*}}
}
|
@@ -28,7 +21,7 @@ int main() { | |||
return 0; | |||
// CHECK-NOT: {{.*safe_call*}} | |||
// CHECK: ==ERROR: RealtimeSanitizer: blocking-call | |||
// CHECK-NEXT: Call to blocking function `custom_blocking_function` in real-time context! | |||
// CHECK-NEXT: Call to blocking function `custom_blocking_function()` in real-time context! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change was because func behaves different from the LLVM IR demangling of the same func
@davidtrevelyan I'm submitting this once tests are green, feel free to review before or post-commit |
// 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"); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused as to why we have a function called safe_call
that's attributed [[clang::blocking]]
. The test assertions also check that safe_call
is not printed. Was it originally a mistake to call __rtsan_notify_blocking_call
in the test when it was first written, maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call is to test that [[blocking]] called from an un-attributed setting (main) does not result in any error. Happy to take suggestions on how to make this more clear!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just took a second crack at it with different assertions etc, let me know what you think
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
int main() {
nonrealtime_function();
realtime_function();
return 0;
}
where the wrappers nonrealtime_function
and realtime_function
are simply:
void realtime_function() [[clang::nonblocking]] { custom_blocking_function(); }
void nonrealtime_function() { custom_blocking_function(); }
and notice we have eliminated safe_call
.
04fde07
to
e8bc15b
Compare
Build failure unrelated - merging |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/123/builds/7101 Here is the relevant piece of the build log for the reference
|
Added the printfs to ensure we wouldn't have these empty functions compiled out.