Skip to content

Commit d5fbcff

Browse files
author
Vasily Leonenko
committed
[BOLT] Don't fail if instrumentation-sleep-time>0 and input binary don't have fini & fini_array
1 parent ea571bf commit d5fbcff

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ extern cl::list<std::string> HotTextMoveSections;
8181
extern cl::opt<bool> Hugify;
8282
extern cl::opt<bool> Instrument;
8383
extern cl::opt<bool> InstrumentNoUseEntryPoint;
84+
extern cl::opt<uint32_t> InstrumentationSleepTime;
8485
extern cl::opt<bool> KeepNops;
8586
extern cl::opt<bool> Lite;
8687
extern cl::list<std::string> ReorderData;
@@ -1470,6 +1471,10 @@ Error RewriteInstance::discoverRtFiniAddress() {
14701471
}
14711472

14721473
if (!BC->FiniArrayAddress || !BC->FiniArraySize) {
1474+
// It is still possible to generate profile without fini hook if
1475+
// InstrumentationSleepTime is set
1476+
if (opts::InstrumentationSleepTime > 0)
1477+
return Error::success();
14731478
return createStringError(
14741479
std::errc::not_supported,
14751480
"Instrumentation needs either DT_FINI or DT_FINI_ARRAY");
@@ -1560,6 +1565,13 @@ void RewriteInstance::updateRtFiniReloc() {
15601565
if (!RT || !RT->getRuntimeFiniAddress())
15611566
return;
15621567

1568+
// It is still possible to generate profile without fini hook if
1569+
// InstrumentationSleepTime is set
1570+
if ((!BC->FiniArrayAddress || !BC->FiniArraySize) &&
1571+
opts::InstrumentationSleepTime > 0) {
1572+
return;
1573+
}
1574+
15631575
assert(BC->FiniArrayAddress && BC->FiniArraySize &&
15641576
"inconsistent .fini_array state");
15651577

0 commit comments

Comments
 (0)