Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,21 @@ static void insertCallAtAllFunctionExitPoints(Function &Fn,
insertCallBeforeInstruction(Fn, I, InsertFnName, FunctionArgs);
}

static PreservedAnalyses rtsanPreservedCFGAnalyses() {
PreservedAnalyses PA;
PA.preserveSet<CFGAnalyses>();
return PA;
}
static void runSanitizeRealtime(Function &Fn) {
if (Fn.empty())
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there precedence in other sanitizer passes for doing this? (Curious how they solved this problem)


static PreservedAnalyses runSanitizeRealtime(Function &Fn) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not returning these preserved analyses going to bite us elsewhere? I remember most of the sanitizer transform passes (or transform passes generally) returning these.

insertCallAtFunctionEntryPoint(Fn, "__rtsan_realtime_enter", {});
insertCallAtAllFunctionExitPoints(Fn, "__rtsan_realtime_exit", {});
return rtsanPreservedCFGAnalyses();
}

static PreservedAnalyses runSanitizeRealtimeBlocking(Function &Fn) {
static void runSanitizeRealtimeBlocking(Function &Fn) {
if (Fn.empty())
return;

IRBuilder<> Builder(&Fn.front().front());
Value *Name = Builder.CreateGlobalString(demangle(Fn.getName()));
insertCallAtFunctionEntryPoint(Fn, "__rtsan_notify_blocking_call", {Name});
return rtsanPreservedCFGAnalyses();
}

PreservedAnalyses RealtimeSanitizerPass::run(Module &M,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
; RUN: opt < %s -passes='rtsan' -S | FileCheck %s

declare void @declared_realtime_function() sanitize_realtime #0

declare void @declared_blocking_function() sanitize_realtime_blocking #0

; RealtimeSanitizer pass should ignore attributed functions that are just declarations
; CHECK: declared_realtime_function
; CHECK-EMPTY:
; CHECK: declared_blocking_function
; CHECK-EMPTY: