[PATCH] D131129: [NFC][Inliner] Add Load/Store handler

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 3 17:09:21 PDT 2022


vitalybuka created this revision.
Herald added subscribers: ChuanqiXu, haicheng, hiraditya.
Herald added a project: All.
vitalybuka requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is additioan signal which may benefit sanitizers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131129

Files:
  llvm/lib/Analysis/InlineCost.cpp


Index: llvm/lib/Analysis/InlineCost.cpp
===================================================================
--- llvm/lib/Analysis/InlineCost.cpp
+++ llvm/lib/Analysis/InlineCost.cpp
@@ -125,6 +125,10 @@
 static cl::opt<int> InstrCost("inline-instr-cost", cl::Hidden, cl::init(5),
                               cl::desc("Cost of a single instruction"));
 
+static cl::opt<int>
+    MemAccessCost("inline-memaccess-cost", cl::Hidden, cl::init(0),
+                  cl::desc("Cost of load/store instruction when inlining"));
+
 static cl::opt<int> CallPenalty(
     "inline-call-penalty", cl::Hidden, cl::init(25),
     cl::desc("Call penalty that is applied per callsite when inlining"));
@@ -281,6 +285,9 @@
   /// Called to account for a call.
   virtual void onCallPenalty() {}
 
+  /// Called to account for a load or store.
+  virtual void onMemAccess(){};
+
   /// Called to account for the expectation the inlining would result in a load
   /// elimination.
   virtual void onLoadEliminationOpportunity() {}
@@ -624,6 +631,9 @@
   }
 
   void onCallPenalty() override { addCost(CallPenalty); }
+
+  void onMemAccess() override { addCost(MemAccessCost); }
+
   void onCallArgumentSetup(const CallBase &Call) override {
     // Pay the price of the argument setup. We account for the average 1
     // instruction per call argument setup here.
@@ -2043,6 +2053,7 @@
     return true;
   }
 
+  onMemAccess();
   return false;
 }
 
@@ -2059,6 +2070,8 @@
   // 2. We should probably at some point thread MemorySSA for the callee into
   // this and then use that to actually compute *really* precise savings.
   disableLoadElimination();
+
+  onMemAccess();
   return false;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131129.449836.patch
Type: text/x-patch
Size: 1683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220804/740db8f4/attachment.bin>


More information about the llvm-commits mailing list