mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-28 05:16:06 +00:00

In non-relocation mode, every function is emitted in its own section. If a function is empty, RuntimeDyld will still allocate 1-byte section for the function and initialize it with zero. As a result, we will overwrite the first byte of the original function contents with zero. Such scenario can happen when the input function had only NOP instructions which BOLT removes by default. Even though such functions likely cause undefined behavior, it's better to preserve their contents. Reviewed By: yota9 Differential Revision: https://reviews.llvm.org/D133978
31 lines
643 B
ArmAsm
31 lines
643 B
ArmAsm
## Check that BOLT preserves nop instruction if it's the only instruction
|
|
## in a function.
|
|
|
|
# REQUIRES: system-linux
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
|
|
# RUN: ld.lld %t.o -o %t.exe -q
|
|
# RUN: llvm-bolt %t.exe -o %t.bolt.exe --relocs=0
|
|
# RUN: llvm-objdump -d %t.bolt.exe | FileCheck %s
|
|
|
|
.text
|
|
.globl nop_function
|
|
.type nop_function,@function
|
|
nop_function:
|
|
.cfi_startproc
|
|
nop
|
|
# CHECK: <nop_function>:
|
|
# CHECK-NEXT: nop
|
|
|
|
.size nop_function, .-nop_function
|
|
.cfi_endproc
|
|
|
|
|
|
.globl _start
|
|
.type _start,@function
|
|
_start:
|
|
.cfi_startproc
|
|
call nop_function
|
|
.size _start, .-_start
|
|
.cfi_endproc
|