diff --git a/bolt/include/bolt/Core/MCPlusBuilder.h b/bolt/include/bolt/Core/MCPlusBuilder.h index ab07f07e49845..885d627f7b64f 100644 --- a/bolt/include/bolt/Core/MCPlusBuilder.h +++ b/bolt/include/bolt/Core/MCPlusBuilder.h @@ -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 diff --git a/bolt/lib/Target/X86/X86MCPlusBuilder.cpp b/bolt/lib/Target/X86/X86MCPlusBuilder.cpp index 37136f4a5c551..e46c42533031c 100644 --- a/bolt/lib/Target/X86/X86MCPlusBuilder.cpp +++ b/bolt/lib/Target/X86/X86MCPlusBuilder.cpp @@ -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> &Targets, diff --git a/bolt/test/AArch64/dummy-return.s b/bolt/test/AArch64/dummy-return.s new file mode 100644 index 0000000000000..a446343161730 --- /dev/null +++ b/bolt/test/AArch64/dummy-return.s @@ -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