Skip to content

Commit 3d8f75a

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:f99bd2961087 into amd-gfx:ac6784fe29a3
Local branch amd-gfx ac6784f Merged main:fef1bec39642 into amd-gfx:b13841aa3970 Remote branch main f99bd29 [BOLT][NFC] Run ADRRelaxationPass in parallel (llvm#67831)
2 parents ac6784f + f99bd29 commit 3d8f75a

File tree

5 files changed

+39
-33
lines changed

5 files changed

+39
-33
lines changed

bolt/lib/Passes/ADRRelaxationPass.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@ static cl::opt<bool>
2929
namespace llvm {
3030
namespace bolt {
3131

32+
// We don't exit directly from runOnFunction since it would call ThreadPool
33+
// destructor which might result in internal assert if we're not finished
34+
// creating async jobs on the moment of exit. So we're finishing all parallel
35+
// jobs and checking the exit flag after it.
36+
static bool PassFailed = false;
37+
3238
void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
39+
if (PassFailed)
40+
return;
41+
3342
BinaryContext &BC = BF.getBinaryContext();
3443
for (BinaryBasicBlock &BB : BF) {
3544
for (auto It = BB.begin(); It != BB.end(); ++It) {
@@ -54,8 +63,12 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
5463
MCPhysReg Reg;
5564
BC.MIB->getADRReg(Inst, Reg);
5665
int64_t Addend = BC.MIB->getTargetAddend(Inst);
57-
InstructionListType Addr =
58-
BC.MIB->materializeAddress(Symbol, BC.Ctx.get(), Reg, Addend);
66+
InstructionListType Addr;
67+
68+
{
69+
auto L = BC.scopeLock();
70+
Addr = BC.MIB->materializeAddress(Symbol, BC.Ctx.get(), Reg, Addend);
71+
}
5972

6073
if (It != BB.begin() && BC.MIB->isNoop(*std::prev(It))) {
6174
It = BB.eraseInstruction(std::prev(It));
@@ -68,7 +81,8 @@ void ADRRelaxationPass::runOnFunction(BinaryFunction &BF) {
6881
errs() << formatv("BOLT-ERROR: Cannot relax adr in non-simple function "
6982
"{0}. Can't proceed in current mode.\n",
7083
BF.getOneName());
71-
exit(1);
84+
PassFailed = true;
85+
return;
7286
}
7387
It = BB.replaceInstruction(It, Addr);
7488
}
@@ -85,7 +99,10 @@ void ADRRelaxationPass::runOnFunctions(BinaryContext &BC) {
8599

86100
ParallelUtilities::runOnEachFunction(
87101
BC, ParallelUtilities::SchedulingPolicy::SP_TRIVIAL, WorkFun, nullptr,
88-
"ADRRelaxationPass", /* ForceSequential */ true);
102+
"ADRRelaxationPass");
103+
104+
if (PassFailed)
105+
exit(1);
89106
}
90107

91108
} // end namespace bolt

bolt/lib/Rewrite/BinaryPassManager.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static cl::opt<bool>
111111

112112
static cl::opt<bool> PrintJTFootprintReduction(
113113
"print-after-jt-footprint-reduction",
114-
cl::desc("print function after jt-footprint-reduction pass"),
114+
cl::desc("print function after jt-footprint-reduction pass"), cl::Hidden,
115115
cl::cat(BoltOptCategory));
116116

117117
static cl::opt<bool>
@@ -160,7 +160,7 @@ static cl::opt<bool>
160160

161161
static cl::opt<bool> PrintRetpolineInsertion(
162162
"print-retpoline-insertion",
163-
cl::desc("print functions after retpoline insertion pass"),
163+
cl::desc("print functions after retpoline insertion pass"), cl::Hidden,
164164
cl::cat(BoltCategory));
165165

166166
static cl::opt<bool> PrintSCTC(
@@ -179,21 +179,21 @@ static cl::opt<bool>
179179

180180
static cl::opt<bool>
181181
PrintStoke("print-stoke", cl::desc("print functions after stoke analysis"),
182-
cl::cat(BoltOptCategory));
182+
cl::Hidden, cl::cat(BoltOptCategory));
183183

184184
static cl::opt<bool>
185185
PrintFixRelaxations("print-fix-relaxations",
186186
cl::desc("print functions after fix relaxations pass"),
187-
cl::cat(BoltOptCategory));
187+
cl::Hidden, cl::cat(BoltOptCategory));
188188

189189
static cl::opt<bool>
190190
PrintFixRISCVCalls("print-fix-riscv-calls",
191191
cl::desc("print functions after fix RISCV calls pass"),
192-
cl::cat(BoltOptCategory));
192+
cl::Hidden, cl::cat(BoltOptCategory));
193193

194194
static cl::opt<bool> PrintVeneerElimination(
195195
"print-veneer-elimination",
196-
cl::desc("print functions after veneer elimination pass"),
196+
cl::desc("print functions after veneer elimination pass"), cl::Hidden,
197197
cl::cat(BoltOptCategory));
198198

199199
static cl::opt<bool>

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,8 +2278,7 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
22782278
}
22792279

22802280
void UnwrappedLineParser::tryToParseJSFunction() {
2281-
assert(FormatTok->is(Keywords.kw_function) ||
2282-
FormatTok->startsSequence(Keywords.kw_async, Keywords.kw_function));
2281+
assert(FormatTok->is(Keywords.kw_function));
22832282
if (FormatTok->is(Keywords.kw_async))
22842283
nextToken();
22852284
// Consume "function".
@@ -2357,8 +2356,7 @@ bool UnwrappedLineParser::parseBracedList(bool ContinueOnSemicolons,
23572356
continue;
23582357
}
23592358
if (Style.isJavaScript()) {
2360-
if (FormatTok->is(Keywords.kw_function) ||
2361-
FormatTok->startsSequence(Keywords.kw_async, Keywords.kw_function)) {
2359+
if (FormatTok->is(Keywords.kw_function)) {
23622360
tryToParseJSFunction();
23632361
continue;
23642362
}
@@ -2511,14 +2509,10 @@ bool UnwrappedLineParser::parseParens(TokenType AmpAmpTokenType) {
25112509
nextToken();
25122510
break;
25132511
case tok::identifier:
2514-
if (Style.isJavaScript() &&
2515-
(FormatTok->is(Keywords.kw_function) ||
2516-
FormatTok->startsSequence(Keywords.kw_async,
2517-
Keywords.kw_function))) {
2512+
if (Style.isJavaScript() && (FormatTok->is(Keywords.kw_function)))
25182513
tryToParseJSFunction();
2519-
} else {
2514+
else
25202515
nextToken();
2521-
}
25222516
break;
25232517
case tok::kw_requires: {
25242518
auto RequiresToken = FormatTok;

clang/lib/Format/UnwrappedLineParser.h

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,26 @@ struct UnwrappedLineNode;
4040
/// \c UnwrappedLineFormatter. The key property is that changing the formatting
4141
/// within an unwrapped line does not affect any other unwrapped lines.
4242
struct UnwrappedLine {
43-
UnwrappedLine();
43+
UnwrappedLine() = default;
4444

4545
/// The \c Tokens comprising this \c UnwrappedLine.
4646
std::list<UnwrappedLineNode> Tokens;
4747

4848
/// The indent level of the \c UnwrappedLine.
49-
unsigned Level;
49+
unsigned Level = 0;
5050

5151
/// The \c PPBranchLevel (adjusted for header guards) if this line is a
5252
/// \c InMacroBody line, and 0 otherwise.
53-
unsigned PPLevel;
53+
unsigned PPLevel = 0;
5454

5555
/// Whether this \c UnwrappedLine is part of a preprocessor directive.
56-
bool InPPDirective;
56+
bool InPPDirective = false;
5757
/// Whether this \c UnwrappedLine is part of a pramga directive.
58-
bool InPragmaDirective;
58+
bool InPragmaDirective = false;
5959
/// Whether it is part of a macro body.
60-
bool InMacroBody;
60+
bool InMacroBody = false;
6161

62-
bool MustBeDeclaration;
62+
bool MustBeDeclaration = false;
6363

6464
/// \c True if this line should be indented by ContinuationIndent in
6565
/// addition to the normal indention level.
@@ -410,11 +410,6 @@ struct UnwrappedLineNode {
410410
SmallVector<UnwrappedLine, 0> Children;
411411
};
412412

413-
inline UnwrappedLine::UnwrappedLine()
414-
: Level(0), PPLevel(0), InPPDirective(false), InPragmaDirective(false),
415-
InMacroBody(false), MustBeDeclaration(false),
416-
MatchingOpeningBlockLineIndex(kInvalidIndex) {}
417-
418413
} // end namespace format
419414
} // end namespace clang
420415

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 476447
19+
#define LLVM_MAIN_REVISION 476451
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

0 commit comments

Comments
 (0)