Skip to content

Commit 480e76e

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 ec77ad7 commit 480e76e

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
@@ -80,6 +80,7 @@ namespace opts {
8080
extern cl::list<std::string> HotTextMoveSections;
8181
extern cl::opt<bool> Hugify;
8282
extern cl::opt<bool> Instrument;
83+
extern cl::opt<uint32_t> InstrumentationSleepTime;
8384
extern cl::opt<bool> KeepNops;
8485
extern cl::opt<bool> Lite;
8586
extern cl::list<std::string> ReorderData;
@@ -1497,6 +1498,10 @@ Error RewriteInstance::discoverRtFiniAddress() {
14971498
}
14981499

14991500
if (!BC->FiniArrayAddress || !BC->FiniArraySize) {
1501+
// It is still possible to generate profile without fini hook if
1502+
// InstrumentationSleepTime is set
1503+
if (opts::InstrumentationSleepTime > 0)
1504+
return Error::success();
15001505
return createStringError(
15011506
std::errc::not_supported,
15021507
"Instrumentation needs either DT_FINI or DT_FINI_ARRAY");
@@ -1597,6 +1602,13 @@ void RewriteInstance::updateRtFiniReloc() {
15971602
if (!RT || !RT->getRuntimeFiniAddress())
15981603
return;
15991604

1605+
// It is still possible to generate profile without fini hook if
1606+
// InstrumentationSleepTime is set
1607+
if ((!BC->FiniArrayAddress || !BC->FiniArraySize) &&
1608+
opts::InstrumentationSleepTime > 0) {
1609+
return;
1610+
}
1611+
16001612
assert(BC->FiniArrayAddress && BC->FiniArraySize &&
16011613
"inconsistent .fini_array state");
16021614

0 commit comments

Comments
 (0)