Skip to content

Commit 690d485

Browse files
Addressing reviewers.
1 parent 31dd42a commit 690d485

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

bolt/lib/Passes/LongJmp.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "bolt/Passes/LongJmp.h"
14-
#include "bolt/Utils/CommandLineOpts.h"
1514

1615
#define DEBUG_TYPE "longjmp"
1716

@@ -326,7 +325,7 @@ uint64_t LongJmpPass::tentativeLayoutRelocMode(
326325
const BinaryContext &BC, std::vector<BinaryFunction *> &SortedFunctions,
327326
uint64_t DotAddress) {
328327
// Compute hot cold frontier
329-
uint32_t LastHotIndex = -1u;
328+
int64_t LastHotIndex = -1u;
330329
uint32_t CurrentIndex = 0;
331330
if (opts::HotFunctionsAtEnd) {
332331
for (BinaryFunction *BF : SortedFunctions) {
@@ -351,23 +350,21 @@ uint64_t LongJmpPass::tentativeLayoutRelocMode(
351350
// Hot
352351
CurrentIndex = 0;
353352
bool ColdLayoutDone = false;
353+
auto runColdLayout = [&]() {
354+
DotAddress = tentativeLayoutRelocColdPart(BC, SortedFunctions, DotAddress);
355+
ColdLayoutDone = true;
356+
if (opts::HotFunctionsAtEnd)
357+
DotAddress = alignTo(DotAddress, opts::AlignText);
358+
};
354359
for (BinaryFunction *Func : SortedFunctions) {
355360
if (!BC.shouldEmit(*Func)) {
356361
HotAddresses[Func] = Func->getAddress();
357-
// Don't perform any tentative address estimation of a function's cold
358-
// layout if it won't be emitted, unless we are ignoring a large number of
359-
// functions (ie, on lite mode) and we haven't done such estimation yet.
360-
if (opts::processAllFunctions() || ColdLayoutDone)
361-
continue;
362-
}
363-
if (!ColdLayoutDone && CurrentIndex >= LastHotIndex) {
364-
DotAddress =
365-
tentativeLayoutRelocColdPart(BC, SortedFunctions, DotAddress);
366-
ColdLayoutDone = true;
367-
if (opts::HotFunctionsAtEnd)
368-
DotAddress = alignTo(DotAddress, opts::AlignText);
362+
continue;
369363
}
370364

365+
if (!ColdLayoutDone && CurrentIndex >= LastHotIndex)
366+
runColdLayout();
367+
371368
DotAddress = alignTo(DotAddress, Func->getMinAlignment());
372369
uint64_t Pad =
373370
offsetToAlignment(DotAddress, llvm::Align(Func->getAlignment()));
@@ -386,9 +383,11 @@ uint64_t LongJmpPass::tentativeLayoutRelocMode(
386383
++CurrentIndex;
387384
}
388385

386+
// Ensure that tentative code layout always runs for cold blocks.
389387
if (!ColdLayoutDone)
390-
assert(ColdLayoutDone &&
391-
"Did not perform tentative code layout for cold blocks.");
388+
runColdLayout();
389+
assert(ColdLayoutDone &&
390+
"Did not perform tentative code layout for cold blocks.");
392391

393392
// BBs
394393
for (BinaryFunction *Func : SortedFunctions)

bolt/test/AArch64/split-funcs-lite.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ REQUIRES: system-linux
99
RUN: %clang %cflags %p/../Inputs/asm_main.c -Wl,-q -o %t
1010

1111
RUN: llvm-bolt %t -o %t.bolt -lite=1 -split-functions -split-all-cold \
12-
RUN: --skip-funcs="_init,_start,call_weak_fn/1,deregister_tm_clones/1,register_tm_clones/1,__do_global_dtors_aux/1,frame_dummy/1,main,foo,_fini" 2>&1 | FileCheck %s
12+
RUN: --skip-funcs="main,foo" 2>&1 | FileCheck %s
1313

1414
CHECK-NOT: Did not perform tentative code layout for cold blocks.

0 commit comments

Comments
 (0)