[PATCH] D96940: [dfsan] Refactor runtime functions checking
stephan.yichao.zhao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 18 00:08:53 PST 2021
stephan.yichao.zhao created this revision.
stephan.yichao.zhao added a reviewer: morehouse.
Herald added a subscriber: hiraditya.
stephan.yichao.zhao requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This is a part of https://reviews.llvm.org/D95835.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D96940
Files:
llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -393,6 +393,7 @@
FunctionCallee DFSanStoreCallbackFn;
FunctionCallee DFSanMemTransferCallbackFn;
FunctionCallee DFSanCmpCallbackFn;
+ SmallPtrSet<Value *, 12> DFSanRuntimeFunctions;
MDNode *ColdCallWeights;
DFSanABIList ABIList;
DenseMap<Value *, Function *> UnwrappedFnMap;
@@ -1048,6 +1049,30 @@
Mod->getOrInsertFunction("__dfsan_nonzero_label", DFSanNonzeroLabelFnTy);
DFSanVarargWrapperFn = Mod->getOrInsertFunction("__dfsan_vararg_wrapper",
DFSanVarargWrapperFnTy);
+
+ DFSanRuntimeFunctions.insert(DFSanUnionFn.getCallee()->stripPointerCasts());
+ DFSanRuntimeFunctions.insert(
+ DFSanCheckedUnionFn.getCallee()->stripPointerCasts());
+ DFSanRuntimeFunctions.insert(
+ DFSanUnionLoadFn.getCallee()->stripPointerCasts());
+ DFSanRuntimeFunctions.insert(
+ DFSanUnionLoadFast16LabelsFn.getCallee()->stripPointerCasts());
+ DFSanRuntimeFunctions.insert(
+ DFSanUnimplementedFn.getCallee()->stripPointerCasts());
+ DFSanRuntimeFunctions.insert(
+ DFSanSetLabelFn.getCallee()->stripPointerCasts());
+ DFSanRuntimeFunctions.insert(
+ DFSanNonzeroLabelFn.getCallee()->stripPointerCasts());
+ DFSanRuntimeFunctions.insert(
+ DFSanVarargWrapperFn.getCallee()->stripPointerCasts());
+ DFSanRuntimeFunctions.insert(
+ DFSanLoadCallbackFn.getCallee()->stripPointerCasts());
+ DFSanRuntimeFunctions.insert(
+ DFSanStoreCallbackFn.getCallee()->stripPointerCasts());
+ DFSanRuntimeFunctions.insert(
+ DFSanMemTransferCallbackFn.getCallee()->stripPointerCasts());
+ DFSanRuntimeFunctions.insert(
+ DFSanCmpCallbackFn.getCallee()->stripPointerCasts());
}
// Initializes event callback functions and declare them in the module
@@ -1095,22 +1120,9 @@
std::vector<Function *> FnsToInstrument;
SmallPtrSet<Function *, 2> FnsWithNativeABI;
- for (Function &i : M) {
- if (!i.isIntrinsic() &&
- &i != DFSanUnionFn.getCallee()->stripPointerCasts() &&
- &i != DFSanCheckedUnionFn.getCallee()->stripPointerCasts() &&
- &i != DFSanUnionLoadFn.getCallee()->stripPointerCasts() &&
- &i != DFSanUnionLoadFast16LabelsFn.getCallee()->stripPointerCasts() &&
- &i != DFSanUnimplementedFn.getCallee()->stripPointerCasts() &&
- &i != DFSanSetLabelFn.getCallee()->stripPointerCasts() &&
- &i != DFSanNonzeroLabelFn.getCallee()->stripPointerCasts() &&
- &i != DFSanVarargWrapperFn.getCallee()->stripPointerCasts() &&
- &i != DFSanLoadCallbackFn.getCallee()->stripPointerCasts() &&
- &i != DFSanStoreCallbackFn.getCallee()->stripPointerCasts() &&
- &i != DFSanMemTransferCallbackFn.getCallee()->stripPointerCasts() &&
- &i != DFSanCmpCallbackFn.getCallee()->stripPointerCasts())
+ for (Function &i : M)
+ if (!i.isIntrinsic() && !DFSanRuntimeFunctions.contains(&i))
FnsToInstrument.push_back(&i);
- }
// Give function aliases prefixes when necessary, and build wrappers where the
// instrumentedness is inconsistent.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96940.324545.patch
Type: text/x-patch
Size: 3311 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210218/b90f8377/attachment.bin>
More information about the llvm-commits
mailing list