[PATCH] D158685: [BOLT] Don't choke on injected functions' IO map
Rafael Auler via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 24 12:03:22 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb59cf211a096: [BOLT] Don't choke on injected functions' IO map (authored by rafauler).
Changed prior to commit:
https://reviews.llvm.org/D158685?vs=552927&id=553222#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D158685/new/
https://reviews.llvm.org/D158685
Files:
bolt/lib/Core/BinaryFunction.cpp
bolt/test/X86/patch-entries.c
Index: bolt/test/X86/patch-entries.c
===================================================================
--- /dev/null
+++ bolt/test/X86/patch-entries.c
@@ -0,0 +1,19 @@
+// Checking crashes against injected binary functions created by patch
+// entries pass and debug info turned on. In these cases, we were
+// trying to fetch input to output maps on injected functions and
+// crashing.
+
+// REQUIRES: system-linux
+
+// RUN: %clang %cflags -no-pie -g %s -fuse-ld=lld -o %t.exe -Wl,-q
+// RUN: llvm-bolt -relocs %t.exe -o %t.out --update-debug-sections \
+// RUN: --force-patch
+
+#include <stdio.h>
+
+static void foo() { printf("foo\n"); }
+
+int main() {
+ foo();
+ return 0;
+}
Index: bolt/lib/Core/BinaryFunction.cpp
===================================================================
--- bolt/lib/Core/BinaryFunction.cpp
+++ bolt/lib/Core/BinaryFunction.cpp
@@ -4129,8 +4129,14 @@
(void)FragmentBaseAddress;
}
- const uint64_t BBAddress =
- *BC.getIOAddressMap().lookup(BB->getInputOffset() + getAddress());
+ // Injected functions likely will fail lookup, as they have no
+ // input range. Just assign the BB the output address of the
+ // function.
+ auto MaybeBBAddress =
+ BC.getIOAddressMap().lookup(BB->getInputOffset() + getAddress());
+ const uint64_t BBAddress = MaybeBBAddress ? *MaybeBBAddress
+ : BB->isSplit() ? FF.getAddress()
+ : getOutputAddress();
BB->setOutputStartAddress(BBAddress);
if (PrevBB)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158685.553222.patch
Type: text/x-patch
Size: 1592 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230824/34f40a47/attachment.bin>
More information about the llvm-commits
mailing list