Skip to content

[BOLT][AArch64] Provide createDummyReturnFunction #96626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions bolt/include/bolt/Core/MCPlusBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -2041,9 +2041,13 @@ class MCPlusBuilder {
return InstructionListType();
}

/// Returns a function body that contains only a return instruction. An
/// example usage is a workaround for the '__bolt_fini_trampoline' of
// Instrumentation.
virtual InstructionListType createDummyReturnFunction(MCContext *Ctx) const {
llvm_unreachable("not implemented");
return InstructionListType();
InstructionListType Insts(1);
createReturn(Insts[0]);
return Insts;
}

/// This method takes an indirect call instruction and splits it up into an
Expand Down
6 changes: 0 additions & 6 deletions bolt/lib/Target/X86/X86MCPlusBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3241,12 +3241,6 @@ class X86MCPlusBuilder : public MCPlusBuilder {
return Insts;
}

InstructionListType createDummyReturnFunction(MCContext *Ctx) const override {
InstructionListType Insts(1);
createReturn(Insts[0]);
return Insts;
}

BlocksVectorTy indirectCallPromotion(
const MCInst &CallInst,
const std::vector<std::pair<MCSymbol *, uint64_t>> &Targets,
Expand Down
28 changes: 28 additions & 0 deletions bolt/test/AArch64/dummy-return.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# REQUIRES: system-linux,target=aarch64{{.*}}

# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown %s -o %t.o
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -static
# RUN: llvm-bolt -instrument -instrumentation-sleep-time=1 %t.exe \
# RUN: -o %t.instr 2>&1 | FileCheck %s
# RUN: llvm-objdump --disassemble-symbols=__bolt_fini_trampoline %t.instr -D \
# RUN: | FileCheck %s -check-prefix=CHECK-ASM

# CHECK: BOLT-INFO: output linked against instrumentation runtime library
# CHECK-ASM: <__bolt_fini_trampoline>:
# CHECK-ASM-NEXT: ret

.text
.align 4
.global _start
.type _start, %function
_start:
bl foo
ret
.size _start, .-_start

.global foo
.type foo, %function
foo:
mov w0, wzr
ret
.size foo, .-foo
Loading