summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2017-04-23 23:39:04 +0000
committerXinliang David Li <davidxl@google.com>2017-04-23 23:39:04 +0000
commitdb8d09b6c20f4976753ff19379fa2ad518d68a24 (patch)
tree796254f1e8c7b6ee7f2adcc51b3187202b0ce03c /llvm/lib/Transforms
parent70eccdc7275eecd3ca8241910b9f7dc95ebdef9d (diff)
downloadbcm5719-llvm-db8d09b6c20f4976753ff19379fa2ad518d68a24.tar.gz
bcm5719-llvm-db8d09b6c20f4976753ff19379fa2ad518d68a24.zip
[PartialInine]: add triaging options
There are more bugs (runtime failures) triggered when partial inlining is turned on. Add options to help triaging problems. llvm-svn: 301148
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/PartialInlining.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/PartialInlining.cpp b/llvm/lib/Transforms/IPO/PartialInlining.cpp
index 6a9a6a272da..78e71c18fe2 100644
--- a/llvm/lib/Transforms/IPO/PartialInlining.cpp
+++ b/llvm/lib/Transforms/IPO/PartialInlining.cpp
@@ -33,6 +33,17 @@ using namespace llvm;
STATISTIC(NumPartialInlined, "Number of functions partially inlined");
+// Command line option to disable partial-inlining. The default is false:
+static cl::opt<bool>
+ DisablePartialInlining("disable-partial-inlining", cl::init(false),
+ cl::Hidden, cl::desc("Disable partial ininling"));
+
+// Command line option to set the maximum number of partial inlining allowed
+// for the module. The default value of -1 means no limit.
+static cl::opt<int> MaxNumPartialInlining(
+ "max-partial-inlining", cl::init(-1), cl::Hidden, cl::ZeroOrMore,
+ cl::desc("Max number of partial inlining. The default is unlimited"));
+
namespace {
struct PartialInlinerImpl {
PartialInlinerImpl(InlineFunctionInfo IFI) : IFI(std::move(IFI)) {}
@@ -41,6 +52,12 @@ struct PartialInlinerImpl {
private:
InlineFunctionInfo IFI;
+ int NumPartialInlining = 0;
+
+ bool IsLimitReached() {
+ return (MaxNumPartialInlining != -1 &&
+ NumPartialInlining >= MaxNumPartialInlining);
+ }
};
struct PartialInlinerLegacyPass : public ModulePass {
static char ID; // Pass identification, replacement for typeid
@@ -164,6 +181,10 @@ Function *PartialInlinerImpl::unswitchFunction(Function *F) {
else
llvm_unreachable("All uses must be calls");
+ if (IsLimitReached())
+ continue;
+ NumPartialInlining++;
+
OptimizationRemarkEmitter ORE(CS.getCaller());
DebugLoc DLoc = CS.getInstruction()->getDebugLoc();
BasicBlock *Block = CS.getParent();
@@ -185,6 +206,9 @@ Function *PartialInlinerImpl::unswitchFunction(Function *F) {
}
bool PartialInlinerImpl::run(Module &M) {
+ if (DisablePartialInlining)
+ return false;
+
std::vector<Function *> Worklist;
Worklist.reserve(M.size());
for (Function &F : M)
OpenPOWER on IntegriCloud