[llvm] [llvm][rtsan] Add transform pass for sanitize_realtime_unsafe (PR #109543)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 09:24:08 PDT 2024


================
@@ -45,6 +46,26 @@ static void insertCallAtAllFunctionExitPoints(Function &Fn,
         insertCallBeforeInstruction(Fn, I, InsertFnName);
 }
 
+static PreservedAnalyses rtsanPreservedCFGAnalyses() {
+  PreservedAnalyses PA;
+  PA.preserveSet<CFGAnalyses>();
+  return PA;
+}
+
+static void insertNotifyBlockingCallAtFunctionEntryPoint(Function &F) {
+  IRBuilder<> Builder(&F.front().front());
+  Value *NameArg = Builder.CreateGlobalString(demangle(F.getName()));
+
+  FunctionType *FuncType =
+      FunctionType::get(Type::getVoidTy(F.getContext()),
+                        {PointerType::getUnqual(F.getContext())}, false);
+
+  FunctionCallee Func = F.getParent()->getOrInsertFunction(
+      "__rtsan_notify_blocking_call", FuncType);
+
+  Builder.CreateCall(Func, {NameArg});
----------------
davidtrevelyan wrote:

Thanks for the suggestion. I was originally intending to keep the diff minimal, but I prefer refactoring for code re-use. I've pushed up a change that I think tidies it up nicely - let me know what you think!

https://github.com/llvm/llvm-project/pull/109543


More information about the llvm-commits mailing list