[PATCH] D19640: Update opt-bisect code to avoid skipping AlwaysInliner

Andy Kaylor via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 17:00:11 PDT 2016


andrew.w.kaylor created this revision.
andrew.w.kaylor added reviewers: tstellarAMD, MatzeB.
andrew.w.kaylor added a subscriber: llvm-commits.
andrew.w.kaylor set the repository for this revision to rL LLVM.

While working on an improved test for the opt bisect code I discovered that the AlwaysInliner pass was being skipped because it inherits its runOnSCC implementation from the Inliner base class.  This causes failures for AMDGPU targets.

This patch works around that problem by making the skipSCC method virtual and overriding it in AlwaysInliner.  There doesn't seem to be a good existing way to determine from the run function whether or not the derived pass can be skipped.  Alternatives I considered were either adding a virtual method specific to this purpose (which seemed equivalent to the approach taken in this patch but with extra baggage) and removing the skipSCC check in the base Inliner class but adding case checks for individual function inlining and checking for the "always-inline" attribute at the callsite (which would be useful but leaks a bit of the attribute handling into the base class).

Repository:
  rL LLVM

http://reviews.llvm.org/D19640

Files:
  include/llvm/Analysis/CallGraphSCCPass.h
  lib/Transforms/IPO/InlineAlways.cpp

Index: lib/Transforms/IPO/InlineAlways.cpp
===================================================================
--- lib/Transforms/IPO/InlineAlways.cpp
+++ lib/Transforms/IPO/InlineAlways.cpp
@@ -53,6 +53,11 @@
   bool doFinalization(CallGraph &CG) override {
     return removeDeadFunctions(CG, /*AlwaysInlineOnly=*/ true);
   }
+
+protected:
+  // AlwaysInliner can't be skipped but it gets its runOnSCC implementation
+  // from Inliner, which can be skipped, so we need to override the skip check.
+  bool skipSCC(CallGraphSCC &SCC) const override { return false; }
 };
 
 }
Index: include/llvm/Analysis/CallGraphSCCPass.h
===================================================================
--- include/llvm/Analysis/CallGraphSCCPass.h
+++ include/llvm/Analysis/CallGraphSCCPass.h
@@ -81,7 +81,7 @@
 protected:
   /// Optional passes call this function to check whether the pass should be
   /// skipped. This is the case when optimization bisect is over the limit.
-  bool skipSCC(CallGraphSCC &SCC) const;
+  virtual bool skipSCC(CallGraphSCC &SCC) const;
 };
 
 /// CallGraphSCC - This is a single SCC that a CallGraphSCCPass is run on.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19640.55358.patch
Type: text/x-patch
Size: 1143 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160428/9a0cf5fd/attachment.bin>


More information about the llvm-commits mailing list