[PATCH] D73420: [llvm] Ensure InlineCost-related fields are initialized

Mircea Trofin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 28 12:23:24 PST 2020


mtrofin updated this revision to Diff 240968.
mtrofin added a comment.

Initializing DefaultThreshold to -1.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73420/new/

https://reviews.llvm.org/D73420

Files:
  llvm/include/llvm/Analysis/InlineCost.h


Index: llvm/include/llvm/Analysis/InlineCost.h
===================================================================
--- llvm/include/llvm/Analysis/InlineCost.h
+++ llvm/include/llvm/Analysis/InlineCost.h
@@ -48,7 +48,7 @@
 /// Do not inline functions which allocate this many bytes on the stack
 /// when the caller is recursive.
 const unsigned TotalAllocaSizeRecursiveCaller = 1024;
-}
+} // namespace InlineConstants
 
 /// Represents the cost of inlining a function.
 ///
@@ -61,16 +61,13 @@
 /// directly tested to determine if inlining should occur given the cost and
 /// threshold for this cost metric.
 class InlineCost {
-  enum SentinelValues {
-    AlwaysInlineCost = INT_MIN,
-    NeverInlineCost = INT_MAX
-  };
+  enum SentinelValues { AlwaysInlineCost = INT_MIN, NeverInlineCost = INT_MAX };
 
   /// The estimated cost of inlining this callsite.
-  int Cost;
+  int Cost = 0;
 
   /// The adjusted threshold against which this cost was computed.
-  int Threshold;
+  int Threshold = 0;
 
   /// Must be set for Always and Never instances.
   const char *Reason = nullptr;
@@ -96,9 +93,7 @@
   }
 
   /// Test whether the inline cost is low enough for inlining.
-  explicit operator bool() const {
-    return Cost < Threshold;
-  }
+  explicit operator bool() const { return Cost < Threshold; }
 
   bool isAlways() const { return Cost == AlwaysInlineCost; }
   bool isNever() const { return Cost == NeverInlineCost; }
@@ -160,7 +155,7 @@
 
 struct InlineParams {
   /// The default threshold to start with for a callee.
-  int DefaultThreshold;
+  int DefaultThreshold = -1;
 
   /// Threshold to use for callees with inline hint.
   Optional<int> HintThreshold;
@@ -240,6 +235,6 @@
 
 /// Minimal filter to detect invalid constructs for inlining.
 InlineResult isInlineViable(Function &Callee);
-}
+} // namespace llvm
 
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73420.240968.patch
Type: text/x-patch
Size: 1847 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200128/40f8292e/attachment.bin>


More information about the llvm-commits mailing list