Skip to content

Commit b0e4cf3

Browse files
Demangle [[clang::blocking]] function names in rtsan pass
1 parent 21b7f16 commit b0e4cf3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/IR/IRBuilder.h"
1818
#include "llvm/IR/Module.h"
1919

20+
#include "llvm/Demangle/Demangle.h"
2021
#include "llvm/Transforms/Instrumentation/RealtimeSanitizer.h"
2122

2223
using namespace llvm;
@@ -53,7 +54,7 @@ static PreservedAnalyses rtsanPreservedCFGAnalyses() {
5354

5455
static void insertExpectNotRealtimeAtFunctionEntryPoint(Function &F) {
5556
IRBuilder<> Builder(&F.front().front());
56-
Value *NameArg = Builder.CreateGlobalString(F.getName());
57+
Value *NameArg = Builder.CreateGlobalString(demangle(F.getName()));
5758

5859
FunctionType *FuncType =
5960
FunctionType::get(Type::getVoidTy(F.getContext()),
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
; RUN: opt < %s -passes=rtsan -S | FileCheck %s
22

3-
define void @blocking_function() #0 {
3+
define void @_Z17blocking_functionv() #0 {
44
ret void
55
}
66

77
define noundef i32 @main() #2 {
8-
call void @blocking_function() #4
8+
call void @_Z17blocking_functionv() #4
99
ret i32 0
1010
}
1111

1212
attributes #0 = { mustprogress noinline sanitize_realtime_unsafe optnone ssp uwtable(sync) }
1313

14-
; RealtimeSanitizer pass should insert __rtsan_expect_not_realtime at function entrypoint
15-
; CHECK-LABEL: @blocking_function()
16-
; CHECK-NEXT: call{{.*}}@__rtsan_expect_not_realtime({{ptr .*}})
14+
; RealtimeSanitizer pass should create the demangled function name as a global string, and
15+
; pass it as input to an inserted __rtsan_expect_not_realtime call at the function entrypoint
16+
; CHECK: [[GLOBAL_STR:@[a-zA-Z0-9\.]+]]
17+
; CHECK-SAME: c"blocking_function()\00"
18+
; CHECK-LABEL: @_Z17blocking_functionv()
19+
; CHECK-NEXT: call{{.*}}@__rtsan_expect_not_realtime(ptr{{.*}}[[GLOBAL_STR]])

0 commit comments

Comments
 (0)