Skip to content

Commit 5ac2615

Browse files
nhuhuanaaupov
authored andcommitted
[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
1 parent 814a0ab commit 5ac2615

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

bolt/include/bolt/Passes/BinaryPasses.h

+2
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ class ReorderBasicBlocks : public BinaryFunctionPass {
142142
/// LT_OPTIMIZE_CACHE piggybacks on the idea from Ispike paper (CGO '04)
143143
/// that suggests putting frequently executed chains first in the layout.
144144
LT_OPTIMIZE_CACHE,
145+
// CACHE_PLUS and EXT_TSP are synonyms, emit warning of deprecation.
146+
LT_OPTIMIZE_CACHE_PLUS,
145147
/// Block reordering guided by the extended TSP metric.
146148
LT_OPTIMIZE_EXT_TSP,
147149
/// Create clusters and use random order for them.

bolt/lib/Passes/BinaryPasses.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,21 @@ cl::opt<bolt::ReorderBasicBlocks::LayoutType> ReorderBlocks(
176176
clEnumValN(bolt::ReorderBasicBlocks::LT_OPTIMIZE_CACHE, "cache",
177177
"perform optimal layout prioritizing I-cache "
178178
"behavior"),
179-
clEnumValN(bolt::ReorderBasicBlocks::LT_OPTIMIZE_EXT_TSP, "cache+",
179+
clEnumValN(bolt::ReorderBasicBlocks::LT_OPTIMIZE_CACHE_PLUS, "cache+",
180180
"perform layout optimizing I-cache behavior"),
181181
clEnumValN(bolt::ReorderBasicBlocks::LT_OPTIMIZE_EXT_TSP, "ext-tsp",
182182
"perform layout optimizing I-cache behavior"),
183183
clEnumValN(bolt::ReorderBasicBlocks::LT_OPTIMIZE_SHUFFLE,
184184
"cluster-shuffle", "perform random layout of clusters")),
185-
cl::ZeroOrMore, cl::cat(BoltOptCategory));
185+
cl::ZeroOrMore, cl::cat(BoltOptCategory),
186+
cl::callback([](const bolt::ReorderBasicBlocks::LayoutType &option) {
187+
if (option == bolt::ReorderBasicBlocks::LT_OPTIMIZE_CACHE_PLUS) {
188+
WithColor::warning()
189+
<< "'-reorder-blocks=cache+' is deprecated, "
190+
<< "please use '-reorder-blocks=ext-tsp' instead\n";
191+
ReorderBlocks = bolt::ReorderBasicBlocks::LT_OPTIMIZE_EXT_TSP;
192+
}
193+
}));
186194

187195
static cl::opt<unsigned>
188196
ReportBadLayout("report-bad-layout",

bolt/test/cache+-deprecated.test

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
3+
REQUIRES: system-linux
4+
5+
RUN: %clangxx %p/Inputs/bolt_icf.cpp -g -Wl,-q -o %t.exe
6+
RUN: llvm-bolt %t.exe -reorder-blocks=cache+ -relocs -o %t 2>&1 | FileCheck %s
7+
8+
CHECK: '-reorder-blocks=cache+' is deprecated, please use '-reorder-blocks=ext-tsp' instead

0 commit comments

Comments
 (0)