Author: davidtrevelyan Date: 2024-10-04T09:33:53-07:00 New Revision: 296a00bead8a25d875975ce68a5cd12c5fce6233
URL: https://github.com/llvm/llvm-project/commit/296a00bead8a25d875975ce68a5cd12c5fce6233 DIFF: https://github.com/llvm/llvm-project/commit/296a00bead8a25d875975ce68a5cd12c5fce6233.diff LOG: [clang][rtsan] Add sanitize_realtime_unsafe attr to [[clang::blocking]] function IR (#111055) Added: Modified: clang/lib/CodeGen/CodeGenFunction.cpp clang/test/CodeGen/rtsan_attribute_inserted.c clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 24723e392c2a3a..e1fd9b72b8d7b2 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -850,6 +850,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, for (const FunctionEffectWithCondition &Fe : FD->getFunctionEffects()) { if (Fe.Effect.kind() == FunctionEffect::Kind::NonBlocking) Fn->addFnAttr(llvm::Attribute::SanitizeRealtime); + else if (Fe.Effect.kind() == FunctionEffect::Kind::Blocking) + Fn->addFnAttr(llvm::Attribute::SanitizeRealtimeUnsafe); } // Apply fuzzing attribute to the function. diff --git a/clang/test/CodeGen/rtsan_attribute_inserted.c b/clang/test/CodeGen/rtsan_attribute_inserted.c index 05a1d9a8c2047a..b21ecb6b6b06a9 100644 --- a/clang/test/CodeGen/rtsan_attribute_inserted.c +++ b/clang/test/CodeGen/rtsan_attribute_inserted.c @@ -1,7 +1,11 @@ // RUN: %clang_cc1 -triple x86_64-unknown-linux -fsanitize=realtime %s -emit-llvm -o - %s | FileCheck %s float process(float *a) [[clang::nonblocking]] { return *a; } - -// CHECK-LABEL: @process{{.*}}#0 { +// CHECK: @process{{.*}} #0 { // CHECK: attributes #0 = { -// CHECK-SAME: {{.*sanitize_realtime.*}} +// CHECK-SAME: {{.*sanitize_realtime .*}} + +int spinlock(int *a) [[clang::blocking]] { return *a; } +// CHECK: @spinlock{{.*}} #1 { +// CHECK: attributes #1 = { +// CHECK-SAME: {{.*sanitize_realtime_unsafe .*}} diff --git a/clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c b/clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c index 43ad6ed1a429ee..0f43007c5e4c16 100644 --- a/clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c +++ b/clang/test/CodeGen/rtsan_no_attribute_sanitizer_disabled.c @@ -1,6 +1,8 @@ // RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s float process(float *a) [[clang::nonblocking]] { return *a; } +int spinlock(int *a) [[clang::blocking]] { return *a; } -// Without the -fsanitize=realtime flag, we shouldn't attach the attribute. -// CHECK-NOT: {{.*sanitize_realtime.*}} +// Without the -fsanitize=realtime flag, we shouldn't attach the attributes. +// CHECK-NOT: {{.*sanitize_realtime .*}} +// CHECK-NOT: {{.*sanitize_realtime_unsafe .*}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits