[llvm] [LLVM][rtsan] Add LLVM nosanitize_realtime attribute (PR #105447)
Chris Apple via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 22 15:45:04 PDT 2024
cjappl wrote:
> That being said, we normally only add positive LLVM attributes for sanitizers and arrange for the Clang attribute `__attribute__((no_sanitize("sanitizername")))` to inhibit adding the LLVM attribute (see `CodeGenFunction::StartFunction`). Is there a reason why this approach doesn't work for the realtime sanitizer?
This won't work in our case, because the realtime sanitizer is selective, ignoring the vast majority of functions, and only focusing on function calls from functions that have an ancestor marked [[clang::nonblocking]] (some more detail in our little [design doc](https://github.com/realtime-sanitizer/radsan/blob/doc/review-support/doc/review.md))
Because a user may want to ignore errors in a call stack that has a [[clang::nonblocking]] ancestor, we need to look for this LLVM attribute, and insert calls to bypass the stack (__rtsan_bypass_on/_off).
So:
* Most functions - not attributed with either, will not be looked at by the realtime sanitizer or impacted at all
* `[[clang::nonblocking]]` functions - in our transform will add the __rtsan_realtime_enter/_exit commands
* `__attribute__((no_sanitize("sanitizername")))` called from a `[[clang::noblocking]]` setting - need to bypass rtsan with bypass_on/_off.
Because we care about these function in this third state, we can't just omit the sanitizer, we have to add the attribute and transform them in our pass.
I guess another way to do it would be add the _bypass to all functions, and only add the _realtime_enter to functions marked [[clang::nonblocking]], but that seems like it would add runtime overhead to user code as compared to this approach
https://github.com/llvm/llvm-project/pull/105447
More information about the llvm-commits
mailing list