Skip to content

Commit 9833759

Browse files
Add sanitize_realtime_unsafe attribute verification
1 parent ec17c60 commit 9833759

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

llvm/include/llvm/IR/Attributes.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,8 @@ def SanitizeNumericalStability : EnumAttr<"sanitize_numerical_stability", [FnAtt
303303
/// RealtimeSanitizer is on.
304304
def SanitizeRealtime : EnumAttr<"sanitize_realtime", [FnAttr]>;
305305

306-
/// RealtimeSanitizer should error if an realtime_unsafe function is called
307-
/// during a sanitize_realtime function.
306+
/// RealtimeSanitizer should error if a real-time unsafe function is invoked
307+
/// during a real-time sanitized function (see `sanitize_realtime`).
308308
def SanitizeRealtimeUnsafe : EnumAttr<"sanitize_realtime_unsafe", [FnAttr]>;
309309

310310
/// Speculative Load Hardening is enabled.

llvm/lib/IR/Verifier.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,6 +2224,12 @@ void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
22242224
"Attributes 'optdebug and optnone' are incompatible!", V);
22252225
}
22262226

2227+
Check(!(Attrs.hasFnAttr(Attribute::SanitizeRealtime) &&
2228+
Attrs.hasFnAttr(Attribute::SanitizeRealtimeUnsafe)),
2229+
"Attributes "
2230+
"'sanitize_realtime and sanitize_realtime_unsafe' are incompatible!",
2231+
V);
2232+
22272233
if (Attrs.hasFnAttr(Attribute::OptimizeForDebugging)) {
22282234
Check(!Attrs.hasFnAttr(Attribute::OptimizeForSize),
22292235
"Attributes 'optsize and optdebug' are incompatible!", V);

llvm/test/Verifier/rtsan-attrs.ll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: not llvm-as -disable-output %s 2>&1 | FileCheck %s
2+
3+
; CHECK: Attributes 'sanitize_realtime and sanitize_realtime_unsafe' are incompatible!
4+
; CHECK-NEXT: ptr @sanitize_unsafe
5+
define void @sanitize_unsafe() #0 {
6+
ret void
7+
}
8+
9+
attributes #0 = { sanitize_realtime sanitize_realtime_unsafe }

0 commit comments

Comments
 (0)