[PATCH] D156389: [BOLT] Fix instrumenting conditional tail calls
Amir Ayupov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 31 13:53:08 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG70e76e0982a9: [BOLT] Fix instrumenting conditional tail calls (authored by Amir).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156389/new/
https://reviews.llvm.org/D156389
Files:
bolt/lib/Core/BinaryFunction.cpp
bolt/test/runtime/X86/instrumentation-tail-call.s
Index: bolt/test/runtime/X86/instrumentation-tail-call.s
===================================================================
--- bolt/test/runtime/X86/instrumentation-tail-call.s
+++ bolt/test/runtime/X86/instrumentation-tail-call.s
@@ -14,6 +14,9 @@
# CHECK: leaq 0x80(%rsp), %rsp
+# RUN: FileCheck %s --input-file %t.fdata --check-prefix=CHECK-FDATA
+# CHECK-FDATA: 1 main {{.*}} 1 targetFunc 0 0 1
+
.text
.globl main
.type main, %function
@@ -32,7 +35,8 @@
movq %rbp, %rsp
pop %rbp
mov -0x10(%rsp),%rax
- jmp targetFunc
+ test %rsp, %rsp
+ jne targetFunc
.LBBerror:
addq $0x20, %rsp
Index: bolt/lib/Core/BinaryFunction.cpp
===================================================================
--- bolt/lib/Core/BinaryFunction.cpp
+++ bolt/lib/Core/BinaryFunction.cpp
@@ -2305,6 +2305,12 @@
// This branch is no longer a conditional tail call.
BC.MIB->unsetConditionalTailCall(*CTCInstr);
+
+ // Move offset from CTCInstr to TailCallInstr.
+ if (std::optional<uint32_t> Offset = BC.MIB->getOffset(*CTCInstr)) {
+ BC.MIB->setOffset(TailCallInstr, *Offset);
+ BC.MIB->clearOffset(*CTCInstr);
+ }
}
insertBasicBlocks(std::prev(end()), std::move(NewBlocks),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156389.545795.patch
Type: text/x-patch
Size: 1227 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230731/6e76852a/attachment.bin>
More information about the llvm-commits
mailing list