Skip to content

Commit 296a00b

Browse files
[clang][rtsan] Add sanitize_realtime_unsafe attr to [[clang::blocking]] function IR (#111055)
1 parent ed0f407 commit 296a00b

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
850850
for (const FunctionEffectWithCondition &Fe : FD->getFunctionEffects()) {
851851
if (Fe.Effect.kind() == FunctionEffect::Kind::NonBlocking)
852852
Fn->addFnAttr(llvm::Attribute::SanitizeRealtime);
853+
else if (Fe.Effect.kind() == FunctionEffect::Kind::Blocking)
854+
Fn->addFnAttr(llvm::Attribute::SanitizeRealtimeUnsafe);
853855
}
854856

855857
// Apply fuzzing attribute to the function.
Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
// RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=realtime %s -emit-llvm -o - %s | FileCheck %s
22

33
float process(float *a) [[clang::nonblocking]] { return *a; }
4-
5-
// CHECK-LABEL: @process{{.*}}#0 {
4+
// CHECK: @process{{.*}} #0 {
65
// CHECK: attributes #0 = {
7-
// CHECK-SAME: {{.*sanitize_realtime.*}}
6+
// CHECK-SAME: {{.*sanitize_realtime .*}}
7+
8+
int spinlock(int *a) [[clang::blocking]] { return *a; }
9+
// CHECK: @spinlock{{.*}} #1 {
10+
// CHECK: attributes #1 = {
11+
// CHECK-SAME: {{.*sanitize_realtime_unsafe .*}}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
22

33
float process(float *a) [[clang::nonblocking]] { return *a; }
4+
int spinlock(int *a) [[clang::blocking]] { return *a; }
45

5-
// Without the -fsanitize=realtime flag, we shouldn't attach the attribute.
6-
// CHECK-NOT: {{.*sanitize_realtime.*}}
6+
// Without the -fsanitize=realtime flag, we shouldn't attach the attributes.
7+
// CHECK-NOT: {{.*sanitize_realtime .*}}
8+
// CHECK-NOT: {{.*sanitize_realtime_unsafe .*}}

0 commit comments

Comments
 (0)