From 5ac26156fee704bb688ac537c9b93ac926dbbfc9 Mon Sep 17 00:00:00 2001 From: Huan Nguyen Date: Fri, 3 Jun 2022 14:16:24 -0700 Subject: [PATCH] [BOLT][NFC] Warning for deprecated option '-reorder-blocks=cache+' Emit warning when using deprecated option '-reorder-blocks=cache+'. Auto switch to option '-reorder-blocks=ext-tsp'. Test Plan: ``` ninja check-bolt ``` Added a new test cache+-deprecated.test. Run and verify that the upstream tests are passed. Reviewed By: rafauler, Amir, maksfb Differential Revision: https://reviews.llvm.org/D126722 --- bolt/include/bolt/Passes/BinaryPasses.h | 2 ++ bolt/lib/Passes/BinaryPasses.cpp | 12 ++++++++++-- bolt/test/cache+-deprecated.test | 8 ++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 bolt/test/cache+-deprecated.test diff --git a/bolt/include/bolt/Passes/BinaryPasses.h b/bolt/include/bolt/Passes/BinaryPasses.h index 8169ff68e860..f036f99a0dff 100644 --- a/bolt/include/bolt/Passes/BinaryPasses.h +++ b/bolt/include/bolt/Passes/BinaryPasses.h @@ -142,6 +142,8 @@ public: /// LT_OPTIMIZE_CACHE piggybacks on the idea from Ispike paper (CGO '04) /// that suggests putting frequently executed chains first in the layout. LT_OPTIMIZE_CACHE, + // CACHE_PLUS and EXT_TSP are synonyms, emit warning of deprecation. + LT_OPTIMIZE_CACHE_PLUS, /// Block reordering guided by the extended TSP metric. LT_OPTIMIZE_EXT_TSP, /// Create clusters and use random order for them. diff --git a/bolt/lib/Passes/BinaryPasses.cpp b/bolt/lib/Passes/BinaryPasses.cpp index 125ae3246d60..7c44f37cc89f 100644 --- a/bolt/lib/Passes/BinaryPasses.cpp +++ b/bolt/lib/Passes/BinaryPasses.cpp @@ -176,13 +176,21 @@ cl::opt ReorderBlocks( clEnumValN(bolt::ReorderBasicBlocks::LT_OPTIMIZE_CACHE, "cache", "perform optimal layout prioritizing I-cache " "behavior"), - clEnumValN(bolt::ReorderBasicBlocks::LT_OPTIMIZE_EXT_TSP, "cache+", + clEnumValN(bolt::ReorderBasicBlocks::LT_OPTIMIZE_CACHE_PLUS, "cache+", "perform layout optimizing I-cache behavior"), clEnumValN(bolt::ReorderBasicBlocks::LT_OPTIMIZE_EXT_TSP, "ext-tsp", "perform layout optimizing I-cache behavior"), clEnumValN(bolt::ReorderBasicBlocks::LT_OPTIMIZE_SHUFFLE, "cluster-shuffle", "perform random layout of clusters")), - cl::ZeroOrMore, cl::cat(BoltOptCategory)); + cl::ZeroOrMore, cl::cat(BoltOptCategory), + cl::callback([](const bolt::ReorderBasicBlocks::LayoutType &option) { + if (option == bolt::ReorderBasicBlocks::LT_OPTIMIZE_CACHE_PLUS) { + WithColor::warning() + << "'-reorder-blocks=cache+' is deprecated, " + << "please use '-reorder-blocks=ext-tsp' instead\n"; + ReorderBlocks = bolt::ReorderBasicBlocks::LT_OPTIMIZE_EXT_TSP; + } + })); static cl::opt ReportBadLayout("report-bad-layout", diff --git a/bolt/test/cache+-deprecated.test b/bolt/test/cache+-deprecated.test new file mode 100644 index 000000000000..2676711a02a5 --- /dev/null +++ b/bolt/test/cache+-deprecated.test @@ -0,0 +1,8 @@ + + +REQUIRES: system-linux + +RUN: %clangxx %p/Inputs/bolt_icf.cpp -g -Wl,-q -o %t.exe +RUN: llvm-bolt %t.exe -reorder-blocks=cache+ -relocs -o %t 2>&1 | FileCheck %s + +CHECK: '-reorder-blocks=cache+' is deprecated, please use '-reorder-blocks=ext-tsp' instead