mirror of
https://github.com/intel/llvm.git
synced 2026-01-14 03:50:17 +08:00
[BOLT] Add constant island check in scanExternalRefs() (#165577)
The [previous patch](https://github.com/llvm/llvm-project/pull/163418) has added a check to prevent adding an entry point into a constant island, but only for successfully disassembled functions. Because scanExternalRefs() is also called when a function fails to be disassembled or is skipped, it can still attempt to add an entry point at constant islands. The same issue may occur if without a check for it So, this patch complements the 'constant island' check in scanExternalRefs().
This commit is contained in:
@@ -1699,9 +1699,19 @@ bool BinaryFunction::scanExternalRefs() {
|
||||
|
||||
const uint64_t FunctionOffset =
|
||||
TargetAddress - TargetFunction->getAddress();
|
||||
BranchTargetSymbol =
|
||||
FunctionOffset ? TargetFunction->addEntryPointAtOffset(FunctionOffset)
|
||||
: TargetFunction->getSymbol();
|
||||
if (!TargetFunction->isInConstantIsland(TargetAddress)) {
|
||||
BranchTargetSymbol =
|
||||
FunctionOffset
|
||||
? TargetFunction->addEntryPointAtOffset(FunctionOffset)
|
||||
: TargetFunction->getSymbol();
|
||||
} else {
|
||||
TargetFunction->setIgnored();
|
||||
BC.outs() << "BOLT-WARNING: Ignoring entry point at address 0x"
|
||||
<< Twine::utohexstr(Address)
|
||||
<< " in constant island of function " << *TargetFunction
|
||||
<< '\n';
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Can't find more references. Not creating relocations since we are not
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
// This test checks that we ignore functions which add an entry point that
|
||||
// is in a constant island.
|
||||
## This test checks that we ignore functions which add an entry point that
|
||||
## is in a constant island.
|
||||
|
||||
# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
|
||||
# RUN: %clang %cflags %t.o -pie -Wl,-q -o %t.exe
|
||||
|
||||
## Check when the caller is successfully disassembled.
|
||||
# RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
|
||||
|
||||
## Skip caller to check the identical warning is triggered from ScanExternalRefs().
|
||||
# RUN: llvm-bolt %t.exe -o %t.bolt -skip-funcs=caller 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK: BOLT-WARNING: Ignoring entry point at address 0x{{[0-9a-f]+}} in constant island of function func
|
||||
|
||||
.globl func
|
||||
|
||||
Reference in New Issue
Block a user