[PATCH] D132376: [BOLT][AArch64] Handle external references to the middle of Constant Islands
Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 25 01:40:39 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6040415ef971: [BOLT][AArch64] Handle references to the middle of Constant Islands (authored by Denis Revunov <revunov.denis at huawei-partners.com>).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132376/new/
https://reviews.llvm.org/D132376
Files:
bolt/lib/Core/BinaryContext.cpp
bolt/test/AArch64/ext-island-ref.s
Index: bolt/test/AArch64/ext-island-ref.s
===================================================================
--- /dev/null
+++ bolt/test/AArch64/ext-island-ref.s
@@ -0,0 +1,39 @@
+// 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: deadbeef
+// CHECK-NEXT: deadbeef
+// CHECK-NEXT: [[#%x,ADDR:]]: deadbeef
+// CHECK-NEXT: deadbeef
+// CHECK: <func>:
+// CHECK-NEXT: ldr x0, 0x[[#ADDR]]
+// CHECK-NEXT: ret
+
+.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
+.size main, .-main
Index: bolt/lib/Core/BinaryContext.cpp
===================================================================
--- bolt/lib/Core/BinaryContext.cpp
+++ bolt/lib/Core/BinaryContext.cpp
@@ -390,6 +390,12 @@
// can pull this constant island and emit it as part of this function
// too.
auto IslandIter = AddressToConstantIslandMap.lower_bound(Address);
+
+ if (IslandIter != AddressToConstantIslandMap.begin() &&
+ (IslandIter == AddressToConstantIslandMap.end() ||
+ IslandIter->first > Address))
+ --IslandIter;
+
if (IslandIter != AddressToConstantIslandMap.end()) {
if (MCSymbol *IslandSym =
IslandIter->second->getOrCreateProxyIslandAccess(Address, BF)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132376.455502.patch
Type: text/x-patch
Size: 1874 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220825/252b150b/attachment.bin>
More information about the llvm-commits
mailing list