[compiler-rt] [llvm] [nsan] Emit calls to optimized functions (PR #98900)

Alexander Shaposhnikov via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 16 13:20:05 PDT 2024


================
@@ -493,6 +494,103 @@ class ValueToShadowMap {
   DenseMap<Value *, Value *> Map;
 };
 
+// Base class for handling some details of __nsan_* functions
+class NsanInstrumentationFunction {
+public:
+  virtual std::pair<FunctionCallee, int>
+  getCalleeAndNumArgsForMemoryOp(const uint64_t MemOpSize) const = 0;
+  virtual FunctionCallee getGeneralFunction() const = 0;
+  virtual ~NsanInstrumentationFunction() = default;
+};
+
+// Helper class for __nsan_copy_* family
----------------
alexander-shaposhnikov wrote:

How about simplifying / removing duplication, i.e. like this:
```

template <size_t N>
class MemOp {
public:
    MemOp(Module &M, ArrayRef<StringRef> Sized, StringRef Fallback);

    FunctionCallee getFunctionFor(MemIntrinsic &MI) const;    
    FunctionCallee getFallback() const;   
private:
    std::array<FunctionCallee, N> functions;
};

MemOp<4> NsanCopy;
MemOp<4> NsanSetUnknown;
```



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


More information about the llvm-commits mailing list