Skip to content

Commit 04c350b

Browse files
Add sanitize_realtime_unsafe attribute verification
1 parent d69cbed commit 04c350b

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
@@ -300,8 +300,8 @@ def SanitizeNumericalStability : EnumAttr<"sanitize_numerical_stability", [FnAtt
300300
/// RealtimeSanitizer is on.
301301
def SanitizeRealtime : EnumAttr<"sanitize_realtime", [FnAttr]>;
302302

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

307307
/// Speculative Load Hardening is enabled.

llvm/lib/IR/Verifier.cpp

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

2226+
Check(!(Attrs.hasFnAttr(Attribute::SanitizeRealtime) &&
2227+
Attrs.hasFnAttr(Attribute::SanitizeRealtimeUnsafe)),
2228+
"Attributes "
2229+
"'sanitize_realtime and sanitize_realtime_unsafe' are incompatible!",
2230+
V);
2231+
22262232
if (Attrs.hasFnAttr(Attribute::OptimizeForDebugging)) {
22272233
Check(!Attrs.hasFnAttr(Attribute::OptimizeForSize),
22282234
"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)