[llvm] [msan] Add handleIntrinsicByApplyingToShadow; support NEON tbl/tbx (PR #114490)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 1 12:50:18 PDT 2024
================
@@ -3944,6 +3944,45 @@ struct MemorySanitizerVisitor : public InstVisitor<MemorySanitizerVisitor> {
}
}
+ /// Handle intrinsics by applying the intrinsic to the shadows. The trailing
+ /// arguments are passed verbatim e.g., for an intrinsic with one trailing
+ /// verbatim argument:
+ /// out = intrinsic(var1, var2, opType)
+ /// we compute:
+ /// shadow[out] = intrinsic(shadow[var1], shadow[var2], opType)
+ ///
+ /// For example, this can be applied to the Arm NEON vector table intrinsics
+ /// (tbl{1,2,3,4}).
+ ///
+ /// The origin is approximated using setOriginForNaryOp.
+ void handleIntrinsicByApplyingToShadow(IntrinsicInst &I,
+ unsigned int trailingVerbatimArgs) {
+ IRBuilder<> IRB(&I);
+
+ assert(trailingVerbatimArgs < I.arg_size());
+
+ SmallVector<Value *, 8> ShadowArgs;
+ // Don't use getNumOperands() because it includes the callee
+ for (unsigned int i = 0; i < I.arg_size(); i++) {
----------------
vitalybuka wrote:
```
for (unsigned int i = 0; i < I.arg_size() - trailingVerbatimArgs; i++) {
Value *Shadow = getShadow(&I, i);
ShadowArgs.push_back(Shadow);
}
for (unsigned int i = I.arg_size() - trailingVerbatimArgs; i < I.arg_size(); i++) {
Value *Arg = I.getArgOperand(i);
insertShadowCheck(Arg, &I);
ShadowArgs.push_back(Arg);
}
```
https://github.com/llvm/llvm-project/pull/114490
More information about the llvm-commits
mailing list