From 92fe563b57ec3430516d361edd07a5e5440c4101 Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Mon, 8 Jan 2018 21:13:35 +0000 Subject: [PATCH] ArgPromotion: Allow setting MaxElements in the new-style pass llvm-svn: 322025 --- llvm/include/llvm/Transforms/IPO/ArgumentPromotion.h | 4 ++++ llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/Transforms/IPO/ArgumentPromotion.h b/llvm/include/llvm/Transforms/IPO/ArgumentPromotion.h index 82ffc69a166e..49ca6cc73393 100644 --- a/llvm/include/llvm/Transforms/IPO/ArgumentPromotion.h +++ b/llvm/include/llvm/Transforms/IPO/ArgumentPromotion.h @@ -22,7 +22,11 @@ namespace llvm { /// transform it and all of its callers to replace indirect arguments with /// direct (by-value) arguments. class ArgumentPromotionPass : public PassInfoMixin { + unsigned MaxElements; + public: + ArgumentPromotionPass(unsigned MaxElements = 3u) : MaxElements(MaxElements) {} + PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR); }; diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp index b25cbcad3b9d..d3a7b0e76fef 100644 --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -963,7 +963,7 @@ PreservedAnalyses ArgumentPromotionPass::run(LazyCallGraph::SCC &C, return FAM.getResult(F); }; - Function *NewF = promoteArguments(&OldF, AARGetter, 3u, None); + Function *NewF = promoteArguments(&OldF, AARGetter, MaxElements, None); if (!NewF) continue; LocalChange = true;