[PATCH] D132376: [BOLT][AArch64] Handle external references to the middle of Constant Islands
Denis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 22 07:16:18 PDT 2022
treapster created this revision.
treapster added a reviewer: yota9.
Herald added subscribers: ayermolo, kristof.beyls.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
treapster requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Fix `BinaryContext::handleAddressRef` to properly detect references to other function's Constant islands.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D132376
Files:
bolt/lib/Core/BinaryContext.cpp
bolt/test/AArch64/data-after-function.s
Index: bolt/test/AArch64/data-after-function.s
===================================================================
--- /dev/null
+++ bolt/test/AArch64/data-after-function.s
@@ -0,0 +1,38 @@
+// This test checks that references to the middle of CI from other function
+// are handled properly
+
+// RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
+// RUN: %clang %cflags --target=aarch64-unknown-linux %t.o -o %t.exe -Wl,-q
+// RUN: llvm-bolt %t.exe -o %t.bolt -lite=false
+// RUN: llvm-objdump -d -j .text %t.bolt | FileCheck %s
+
+// CHECK: <func>:
+// CHECK-NEXT: ldr x0, 0x[[#%x,ADDR:]]
+// CHECK-NEXT: ret
+// CHECK: deadbeef
+// CHECK-NEXT: deadbeef
+// CHECK-NEXT: [[#ADDR]]: deadbeef
+// CHECK-NEXT: deadbeef
+
+.type funcWithIsland, %function
+funcWithIsland:
+ ret
+ .word 0xdeadbeef
+ .word 0xdeadbeef
+ .word 0xdeadbeef
+ .word 0xdeadbeef
+.size funcWithIsland, .-funcWithIsland
+
+.type func, %function
+func:
+ ldr x0, funcWithIsland + 12
+ ret
+.size func, .-func
+
+.global main
+.type main, %function
+main:
+ bl funcWithIsland
+ bl func
+ mov w8, #93
+ svc #0
Index: bolt/lib/Core/BinaryContext.cpp
===================================================================
--- bolt/lib/Core/BinaryContext.cpp
+++ bolt/lib/Core/BinaryContext.cpp
@@ -390,6 +390,15 @@
// can pull this constant island and emit it as part of this function
// too.
auto IslandIter = AddressToConstantIslandMap.lower_bound(Address);
+
+ if (IslandIter != AddressToConstantIslandMap.end() &&
+ IslandIter->first > Address) {
+ if (IslandIter == AddressToConstantIslandMap.begin())
+ IslandIter = AddressToConstantIslandMap.end();
+ else
+ --IslandIter;
+ }
+
if (IslandIter != AddressToConstantIslandMap.end()) {
if (MCSymbol *IslandSym =
IslandIter->second->getOrCreateProxyIslandAccess(Address, BF)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132376.454496.patch
Type: text/x-patch
Size: 1938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220822/0c1ad531/attachment.bin>
More information about the llvm-commits
mailing list