[llvm] [Asan] Add TTI hook to provide memory reference information of target intrinsic. (PR #133361)

via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 27 21:19:33 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 81c6ce3b33ff462a23744c82f493e1e1ea3844de 871f4435a78badfde781f5a093422f41168eed91 --extensions cpp,h -- llvm/include/llvm/Analysis/TargetTransformInfo.h llvm/include/llvm/Analysis/TargetTransformInfoImpl.h llvm/lib/Analysis/TargetTransformInfo.cpp llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfo.h b/llvm/include/llvm/Analysis/TargetTransformInfo.h
index a216d36a5d..82587c710f 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfo.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfo.h
@@ -1665,10 +1665,12 @@ public:
   /// if false is returned.
   bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) const;
 
-  /// \returns True if the intrinsic is a supported memory instrinsic, 
+  /// \returns True if the intrinsic is a supported memory instrinsic,
   /// and store the \p InterestingMemoryOperand into array \p Interesting
   /// for Asan instrumentation.
-  bool getTgtMemIntrinsicOperand(IntrinsicInst *Inst, SmallVectorImpl<InterestingMemoryOperand> &Interesting) const; 
+  bool getTgtMemIntrinsicOperand(
+      IntrinsicInst *Inst,
+      SmallVectorImpl<InterestingMemoryOperand> &Interesting) const;
 
   /// \returns The maximum element size, in bytes, for an element
   /// unordered-atomic memory intrinsic.
@@ -2291,8 +2293,9 @@ public:
   getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) = 0;
   virtual bool getTgtMemIntrinsic(IntrinsicInst *Inst,
                                   MemIntrinsicInfo &Info) = 0;
-  virtual bool getTgtMemIntrinsicOperand(IntrinsicInst *Inst,
-                                  SmallVectorImpl<InterestingMemoryOperand> &Interesting) = 0;
+  virtual bool getTgtMemIntrinsicOperand(
+      IntrinsicInst *Inst,
+      SmallVectorImpl<InterestingMemoryOperand> &Interesting) = 0;
   virtual unsigned getAtomicMemIntrinsicMaxElementSize() const = 0;
   virtual Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
                                                    Type *ExpectedType) = 0;
@@ -3064,8 +3067,9 @@ public:
                           MemIntrinsicInfo &Info) override {
     return Impl.getTgtMemIntrinsic(Inst, Info);
   }
-  bool getTgtMemIntrinsicOperand(IntrinsicInst *Inst,
-                          SmallVectorImpl<InterestingMemoryOperand> &Interesting) override {
+  bool getTgtMemIntrinsicOperand(
+      IntrinsicInst *Inst,
+      SmallVectorImpl<InterestingMemoryOperand> &Interesting) override {
     return Impl.getTgtMemIntrinsicOperand(Inst, Interesting);
   }
   unsigned getAtomicMemIntrinsicMaxElementSize() const override {
diff --git a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
index cf2cc6fddb..9d506ec6e7 100644
--- a/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ b/llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -905,9 +905,11 @@ public:
   bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) const {
     return false;
   }
-  bool getTgtMemIntrinsicOperand(IntrinsicInst *Inst, SmallVectorImpl<InterestingMemoryOperand> &Interesting) const {
+  bool getTgtMemIntrinsicOperand(
+      IntrinsicInst *Inst,
+      SmallVectorImpl<InterestingMemoryOperand> &Interesting) const {
     return false;
-  } 
+  }
   unsigned getAtomicMemIntrinsicMaxElementSize() const {
     // Note for overrides: You must ensure for all element unordered-atomic
     // memory intrinsics that all power-of-2 element sizes up to, and
diff --git a/llvm/lib/Analysis/TargetTransformInfo.cpp b/llvm/lib/Analysis/TargetTransformInfo.cpp
index 08b4e5f77c..8af6731195 100644
--- a/llvm/lib/Analysis/TargetTransformInfo.cpp
+++ b/llvm/lib/Analysis/TargetTransformInfo.cpp
@@ -1273,8 +1273,9 @@ bool TargetTransformInfo::getTgtMemIntrinsic(IntrinsicInst *Inst,
   return TTIImpl->getTgtMemIntrinsic(Inst, Info);
 }
 
-bool TargetTransformInfo::getTgtMemIntrinsicOperand(IntrinsicInst *Inst,
-                                             SmallVectorImpl<InterestingMemoryOperand> &Interesting) const {
+bool TargetTransformInfo::getTgtMemIntrinsicOperand(
+    IntrinsicInst *Inst,
+    SmallVectorImpl<InterestingMemoryOperand> &Interesting) const {
   return TTIImpl->getTgtMemIntrinsicOperand(Inst, Interesting);
 }
 
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 136a1cf310..f78d834558 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -15,8 +15,8 @@
 #include "llvm/CodeGen/TargetLowering.h"
 #include "llvm/CodeGen/ValueTypes.h"
 #include "llvm/IR/Instructions.h"
-#include "llvm/IR/PatternMatch.h"
 #include "llvm/IR/IntrinsicsRISCV.h"
+#include "llvm/IR/PatternMatch.h"
 #include <cmath>
 #include <optional>
 using namespace llvm;
@@ -38,8 +38,9 @@ static cl::opt<unsigned> SLPMaxVF(
         "exclusively by SLP vectorizer."),
     cl::Hidden);
 
-bool RISCVTTIImpl::getTgtMemIntrinsicOperand(IntrinsicInst *Inst, 
-                                      SmallVectorImpl<InterestingMemoryOperand> &Interesting) const {
+bool RISCVTTIImpl::getTgtMemIntrinsicOperand(
+    IntrinsicInst *Inst,
+    SmallVectorImpl<InterestingMemoryOperand> &Interesting) const {
   const DataLayout &DL = getDataLayout();
   Intrinsic::ID IID = Inst->getIntrinsicID();
   LLVMContext &C = Inst->getContext();
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
index 8c4d863682..af9ab0819e 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
@@ -151,10 +151,10 @@ public:
   void getPeelingPreferences(Loop *L, ScalarEvolution &SE,
                              TTI::PeelingPreferences &PP);
 
-  
-  bool getTgtMemIntrinsicOperand(IntrinsicInst *Inst,
-                           SmallVectorImpl<InterestingMemoryOperand> &Interesting) const;
-  
+  bool getTgtMemIntrinsicOperand(
+      IntrinsicInst *Inst,
+      SmallVectorImpl<InterestingMemoryOperand> &Interesting) const;
+
   unsigned getMinVectorRegisterBitWidth() const {
     return ST->useRVVForFixedLengthVectors() ? 16 : 0;
   }
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 17c2f1436b..d00830d07d 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -800,7 +800,7 @@ struct AddressSanitizer {
 
   bool ignoreAccess(Instruction *Inst, Value *Ptr);
   void getInterestingMemoryOperands(
-      Instruction *I, SmallVectorImpl<InterestingMemoryOperand> &Interesting, 
+      Instruction *I, SmallVectorImpl<InterestingMemoryOperand> &Interesting,
       const TargetTransformInfo *TTI);
 
   void instrumentMop(ObjectSizeOffsetVisitor &ObjSizeVis,
@@ -841,7 +841,8 @@ struct AddressSanitizer {
   void instrumentMemIntrinsic(MemIntrinsic *MI, RuntimeCallInserter &RTCI);
   Value *memToShadow(Value *Shadow, IRBuilder<> &IRB);
   bool suppressInstrumentationSiteForDebug(int &Instrumented);
-  bool instrumentFunction(Function &F, const TargetLibraryInfo *TLI, const TargetTransformInfo *TTI);
+  bool instrumentFunction(Function &F, const TargetLibraryInfo *TLI,
+                          const TargetTransformInfo *TTI);
   bool maybeInsertAsanInitAtFunctionEntry(Function &F);
   bool maybeInsertDynamicShadowAtFunctionEntry(Function &F);
   void markEscapedLocalAllocas(Function &F);
@@ -3006,7 +3007,7 @@ bool AddressSanitizer::suppressInstrumentationSiteForDebug(int &Instrumented) {
 
 bool AddressSanitizer::instrumentFunction(Function &F,
                                           const TargetLibraryInfo *TLI,
-					  const TargetTransformInfo *TTI) {
+                                          const TargetTransformInfo *TTI) {
   bool FunctionModified = false;
 
   // Do not apply any instrumentation for naked functions.

``````````

</details>


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


More information about the llvm-commits mailing list