[llvm] Rtsan/blocking 2 llvm pass (PR #109543)
Chris Apple via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 22 06:35:46 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});
----------------
cjappl wrote:
Should we just combine this with a better version of `insertCallAtFunctionEntryPoint` that takes an optional args value? What are the pros/cons of that?
I know in my loop code, I will also need to insert a call here, this time with two variables to the input function. We then have two approaches:
1. Write well named helper functions that do that action and that action only (like you have here)
2. Write a general helper that takes in any number of arguments, which you construct outside the function.
Which do you feel is more appropriate?
https://github.com/llvm/llvm-project/pull/109543
More information about the llvm-commits
mailing list