summaryrefslogtreecommitdiffstats
path: root/llvm/tools/bugpoint
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2019-09-17 08:14:09 +0000
committerFlorian Hahn <flo@fhahn.com>2019-09-17 08:14:09 +0000
commit5c17323dd8eeeb0d2d9c17c4ad0200c8a4e4ded7 (patch)
tree08d741a27c4fad8ebabedb6c9b91b58ca4f8911d /llvm/tools/bugpoint
parent645593844164187a2de37b40e62cd790cfb48a03 (diff)
downloadbcm5719-llvm-5c17323dd8eeeb0d2d9c17c4ad0200c8a4e4ded7.tar.gz
bcm5719-llvm-5c17323dd8eeeb0d2d9c17c4ad0200c8a4e4ded7.zip
[bugpoint] Add support for -Oz and properly enable -Os.
This patch adds -Oz as option and also properly enables support for -Os. Currently, the existing check for -Os is dead, because the enclosing if only checks of O1, O2 and O3. There is still a difference between the -Oz pipeline compared to opt, but I have not been able to track that down yet. Reviewers: bogner, sebpop, efriedma Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D67593 llvm-svn: 372079
Diffstat (limited to 'llvm/tools/bugpoint')
-rw-r--r--llvm/tools/bugpoint/bugpoint.cpp46
1 files changed, 34 insertions, 12 deletions
diff --git a/llvm/tools/bugpoint/bugpoint.cpp b/llvm/tools/bugpoint/bugpoint.cpp
index 2d5322a351a..c7644e75ae4 100644
--- a/llvm/tools/bugpoint/bugpoint.cpp
+++ b/llvm/tools/bugpoint/bugpoint.cpp
@@ -81,6 +81,10 @@ static cl::opt<bool> OptLevelOs(
"Like -O2 with extra optimizations for size. Similar to clang -Os"));
static cl::opt<bool>
+OptLevelOz("Oz",
+ cl::desc("Like -Os but reduces code size further. Similar to clang -Oz"));
+
+static cl::opt<bool>
OptLevelO3("O3", cl::desc("Optimization level 3. Identical to 'opt -O3'"));
static cl::opt<std::string>
@@ -109,6 +113,26 @@ public:
};
}
+// This routine adds optimization passes based on selected optimization level,
+// OptLevel.
+//
+// OptLevel - Optimization Level
+static void AddOptimizationPasses(legacy::FunctionPassManager &FPM,
+ unsigned OptLevel,
+ unsigned SizeLevel) {
+ PassManagerBuilder Builder;
+ Builder.OptLevel = OptLevel;
+ Builder.SizeLevel = SizeLevel;
+
+ if (OptLevel > 1)
+ Builder.Inliner = createFunctionInliningPass(OptLevel, SizeLevel, false);
+ else
+ Builder.Inliner = createAlwaysInlinerLegacyPass();
+
+ Builder.populateFunctionPassManager(FPM);
+ Builder.populateModulePassManager(FPM);
+}
+
#ifdef LINK_POLLY_INTO_TOOLS
namespace polly {
void initializePollyPasses(llvm::PassRegistry &Registry);
@@ -189,18 +213,16 @@ int main(int argc, char **argv) {
Builder.populateLTOPassManager(PM);
}
- if (OptLevelO1 || OptLevelO2 || OptLevelO3) {
- PassManagerBuilder Builder;
- if (OptLevelO1)
- Builder.Inliner = createAlwaysInlinerLegacyPass();
- else if (OptLevelOs || OptLevelO2)
- Builder.Inliner = createFunctionInliningPass(
- 2, OptLevelOs ? 1 : 0, false);
- else
- Builder.Inliner = createFunctionInliningPass(275);
- Builder.populateFunctionPassManager(PM);
- Builder.populateModulePassManager(PM);
- }
+ if (OptLevelO1)
+ AddOptimizationPasses(PM, 1, 0);
+ else if (OptLevelO2)
+ AddOptimizationPasses(PM, 2, 0);
+ else if (OptLevelO3)
+ AddOptimizationPasses(PM, 3, 0);
+ else if (OptLevelOs)
+ AddOptimizationPasses(PM, 2, 1);
+ else if (OptLevelOz)
+ AddOptimizationPasses(PM, 2, 2);
for (const PassInfo *PI : PassList)
D.addPass(PI->getPassArgument());
OpenPOWER on IntegriCloud