!21 Update llvm-bolt from llvm-bolt to llvm-bolt-15
From: @zhenyu--zhao Reviewed-by: @li-yancheng Signed-off-by: @li-yancheng
This commit is contained in:
commit
dd2eb4b0bc
@ -1,109 +0,0 @@
|
|||||||
From 963d19d86cca708957055f3072cbe8473c8e52e3 Mon Sep 17 00:00:00 2001
|
|
||||||
From: xiongzhou4 <xiongzhou4@huawei.com>
|
|
||||||
Date: Thu, 15 Jun 2023 20:34:42 +0800
|
|
||||||
Subject: [PATCH] [Backport] [BOLT] [AArch64] Handle data at the beginning of a
|
|
||||||
function when disassembling and building CFG.
|
|
||||||
|
|
||||||
---
|
|
||||||
bolt/src/BinaryFunction.cpp | 11 +++++++----
|
|
||||||
bolt/src/BinaryFunction.h | 9 +++++++++
|
|
||||||
bolt/src/Exceptions.cpp | 2 +-
|
|
||||||
bolt/test/AArch64/data-at-0-offset.c | 17 +++++++++++++++++
|
|
||||||
4 files changed, 34 insertions(+), 5 deletions(-)
|
|
||||||
create mode 100644 bolt/test/AArch64/data-at-0-offset.c
|
|
||||||
|
|
||||||
diff --git a/bolt/src/BinaryFunction.cpp b/bolt/src/BinaryFunction.cpp
|
|
||||||
index 9414b83ad..93de63d3f 100644
|
|
||||||
--- a/bolt/src/BinaryFunction.cpp
|
|
||||||
+++ b/bolt/src/BinaryFunction.cpp
|
|
||||||
@@ -1445,6 +1445,9 @@ add_instruction:
|
|
||||||
addInstruction(Offset, std::move(Instruction));
|
|
||||||
}
|
|
||||||
|
|
||||||
+ if (uint64_t Offset = getFirstInstructionOffset())
|
|
||||||
+ Labels[Offset] = BC.Ctx->createNamedTempSymbol();
|
|
||||||
+
|
|
||||||
clearList(Relocations);
|
|
||||||
|
|
||||||
if (!IsSimple) {
|
|
||||||
@@ -1987,7 +1990,7 @@ bool BinaryFunction::buildCFG(MCPlusBuilder::AllocatorIdTy AllocatorId) {
|
|
||||||
return false;
|
|
||||||
|
|
||||||
assert(BasicBlocks.empty() && "basic block list should be empty");
|
|
||||||
- assert((Labels.find(0) != Labels.end()) &&
|
|
||||||
+ assert((Labels.find(getFirstInstructionOffset()) != Labels.end()) &&
|
|
||||||
"first instruction should always have a label");
|
|
||||||
|
|
||||||
// Create basic blocks in the original layout order:
|
|
||||||
@@ -2087,9 +2090,9 @@ bool BinaryFunction::buildCFG(MCPlusBuilder::AllocatorIdTy AllocatorId) {
|
|
||||||
updateOffset(LastInstrOffset);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- if (Offset == 0) {
|
|
||||||
- // Add associated CFI pseudos in the first offset (0)
|
|
||||||
- addCFIPlaceholders(0, InsertBB);
|
|
||||||
+ if (Offset == getFirstInstructionOffset()) {
|
|
||||||
+ // Add associated CFI pseudos in the first offset.
|
|
||||||
+ addCFIPlaceholders(Offset, InsertBB);
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool IsBlockEnd = MIB->isTerminator(Instr);
|
|
||||||
diff --git a/bolt/src/BinaryFunction.h b/bolt/src/BinaryFunction.h
|
|
||||||
index a824f3d58..3b435cfb3 100644
|
|
||||||
--- a/bolt/src/BinaryFunction.h
|
|
||||||
+++ b/bolt/src/BinaryFunction.h
|
|
||||||
@@ -967,6 +967,15 @@ public:
|
|
||||||
return const_cast<BinaryFunction *>(this)->getInstructionAtOffset(Offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ /// Return offset for the first instruction. If there is data at the
|
|
||||||
+ /// beginning of a function then offset of the first instruction could
|
|
||||||
+ /// be different from 0.
|
|
||||||
+ uint64_t getFirstInstructionOffset() const {
|
|
||||||
+ if (Instructions.empty())
|
|
||||||
+ return 0;
|
|
||||||
+ return Instructions.begin()->first;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
/// Return jump table that covers a given \p Address in memory.
|
|
||||||
JumpTable *getJumpTableContainingAddress(uint64_t Address) {
|
|
||||||
auto JTI = JumpTables.upper_bound(Address);
|
|
||||||
diff --git a/bolt/src/Exceptions.cpp b/bolt/src/Exceptions.cpp
|
|
||||||
index f73054aa8..0a64e3fca 100644
|
|
||||||
--- a/bolt/src/Exceptions.cpp
|
|
||||||
+++ b/bolt/src/Exceptions.cpp
|
|
||||||
@@ -499,7 +499,7 @@ bool CFIReaderWriter::fillCFIInfoFor(BinaryFunction &Function) const {
|
|
||||||
Optional<uint64_t> LSDA = CurFDE.getLSDAAddress();
|
|
||||||
Function.setLSDAAddress(LSDA ? *LSDA : 0);
|
|
||||||
|
|
||||||
- uint64_t Offset = 0;
|
|
||||||
+ uint64_t Offset = Function.getFirstInstructionOffset();
|
|
||||||
uint64_t CodeAlignment = CurFDE.getLinkedCIE()->getCodeAlignmentFactor();
|
|
||||||
uint64_t DataAlignment = CurFDE.getLinkedCIE()->getDataAlignmentFactor();
|
|
||||||
if (CurFDE.getLinkedCIE()->getPersonalityAddress()) {
|
|
||||||
diff --git a/bolt/test/AArch64/data-at-0-offset.c b/bolt/test/AArch64/data-at-0-offset.c
|
|
||||||
new file mode 100644
|
|
||||||
index 000000000..e0c689a19
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/bolt/test/AArch64/data-at-0-offset.c
|
|
||||||
@@ -0,0 +1,17 @@
|
|
||||||
+// RUN: %clang %cflags -O2 -fPIE -Wl,-q -pie %s -o %t.exe
|
|
||||||
+// RUN: llvm-bolt %t.exe -o %t.bolt 2>&1 | FileCheck %s
|
|
||||||
+// CHECK-NOT: BOLT-WARNING: unable to disassemble instruction at offset
|
|
||||||
+
|
|
||||||
+void extra_space() {
|
|
||||||
+ asm volatile(".rept 256\n"
|
|
||||||
+ " .byte 0xff\n"
|
|
||||||
+ ".endr\n");
|
|
||||||
+ return;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+int main(int argc, char **argv) {
|
|
||||||
+ void (*fn)(void);
|
|
||||||
+ fn = extra_space + 256;
|
|
||||||
+ fn();
|
|
||||||
+ return 0;
|
|
||||||
+}
|
|
||||||
--
|
|
||||||
2.33.0
|
|
||||||
|
|
||||||
166
llvm-bolt.spec
166
llvm-bolt.spec
@ -1,61 +1,150 @@
|
|||||||
|
%bcond_with check
|
||||||
|
|
||||||
|
%global maj_ver 15
|
||||||
|
%global min_ver 0
|
||||||
|
%global patch_ver 7
|
||||||
|
%global bolt_version %{maj_ver}.%{min_ver}.%{patch_ver}
|
||||||
|
%global bolt_srcdir llvm-project-%{bolt_version}.src
|
||||||
|
|
||||||
|
%global install_prefix %{_prefix}
|
||||||
|
|
||||||
|
%global install_bindir %{install_prefix}/bin
|
||||||
|
%global install_libdir %{install_prefix}/lib
|
||||||
|
%global install_docdir %{install_prefix}/share/doc
|
||||||
|
%global max_link_jobs 2
|
||||||
|
|
||||||
Name: llvm-bolt
|
Name: llvm-bolt
|
||||||
Version: 0
|
Version: %{bolt_version}
|
||||||
Release: 2.20211016.gitb72f753
|
Release: 1
|
||||||
Summary: BOLT is a post-link optimizer developed to speed up large applications
|
Summary: BOLT is a post-link optimizer developed to speed up large applications
|
||||||
License: Apache 2.0
|
License: Apache 2.0
|
||||||
URL: https://github.com/facebookincubator/BOLT
|
URL: https://github.com/llvm/llvm-project/tree/main/bolt
|
||||||
Source0: %{name}-%{version}.tar.xz
|
|
||||||
|
|
||||||
BuildRequires: gcc gcc-c++ cmake ninja-build libstdc++-static chrpath ncurses-devel zlib-devel
|
Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{bolt_version}/%{bolt_srcdir}.tar.xz
|
||||||
Requires: glibc zlib ncurses-libs libstdc++ libgcc
|
|
||||||
|
|
||||||
Patch1: 0001-Backport-Handle-data-at-the-beginning-of-a-function.patch
|
BuildRequires: gcc
|
||||||
|
BuildRequires: gcc-c++
|
||||||
|
BuildRequires: cmake
|
||||||
|
BuildRequires: ninja-build
|
||||||
|
BuildRequires: zlib-devel
|
||||||
|
BuildRequires: python3-lit
|
||||||
|
BuildRequires: python3-psutil
|
||||||
|
BuildRequires: doxygen
|
||||||
|
|
||||||
%description
|
%description
|
||||||
BOLT is a post-link optimizer developed to speed up large applications.
|
BOLT is a post-link optimizer developed to speed up large applications.
|
||||||
It achieves the improvements by optimizing application's code layout based
|
It achieves the improvements by optimizing application's code layout based
|
||||||
on execution profile gathered by sampling profiler, such as Linux perf tool.
|
on execution profile gathered by sampling profiler, such as Linux perf tool.
|
||||||
|
|
||||||
|
%package doc
|
||||||
|
Summary: Documentation for BOLT
|
||||||
|
BuildArch: noarch
|
||||||
|
Requires: %{name} = %{version}-%{release}
|
||||||
|
|
||||||
|
%description doc
|
||||||
|
Documentation for the BOLT optimizer
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -p1
|
%autosetup -n %{bolt_srcdir} -p1
|
||||||
mkdir -p _build
|
|
||||||
cd _build
|
|
||||||
%{__cmake} -G Ninja ../llvm -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_ASSERTIONS=ON \
|
|
||||||
-DLLVM_ENABLE_PROJECTS="clang;lld;bolt" -DCMAKE_INSTALL_PREFIX=%{_usr} \
|
|
||||||
-DLLVM_PARALLEL_LINK_JOBS=1 \
|
|
||||||
%ifarch %ix86 x86_64
|
|
||||||
-DLLVM_TARGETS_TO_BUILD="X86"
|
|
||||||
%endif
|
|
||||||
%ifarch aarch64
|
|
||||||
-DLLVM_TARGETS_TO_BUILD="AArch64"
|
|
||||||
%endif
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
cd _build
|
%{cmake} -G Ninja -S llvm \
|
||||||
%{ninja_build}
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||||
|
-DCMAKE_INSTALL_PREFIX=%{install_prefix} \
|
||||||
|
-DCMAKE_SKIP_RPATH=ON \
|
||||||
|
-DLLVM_DIR=%{install_libdir}/cmake/llvm \
|
||||||
|
-DLLVM_TABLEGEN_EXE=%{install_bindir}/llvm-tblgen \
|
||||||
|
-DLLVM_BUILD_UTILS:BOOL=ON \
|
||||||
|
-DBOLT_INCLUDE_DOCS:BOOL=ON \
|
||||||
|
-DLLVM_INCLUDE_TESTS:BOOL=ON \
|
||||||
|
-DBUILD_SHARED_LIBS:BOOL=OFF \
|
||||||
|
-DLLVM_LINK_LLVM_DYLIB:BOOL=OFF \
|
||||||
|
-DLLVM_ENABLE_ASSERTIONS=ON \
|
||||||
|
-DBOLT_INCLUDE_TESTS:BOOL=ON \
|
||||||
|
-DLLVM_EXTERNAL_LIT=%{_bindir}/lit \
|
||||||
|
-DLLVM_ENABLE_PROJECTS="bolt" \
|
||||||
|
-DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \
|
||||||
|
%ifarch %ix86 x86_64
|
||||||
|
-DLLVM_TARGETS_TO_BUILD="X86"
|
||||||
|
%endif
|
||||||
|
%ifarch aarch64
|
||||||
|
-DLLVM_TARGETS_TO_BUILD="AArch64"
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%ninja_build bolt
|
||||||
|
|
||||||
%install
|
%install
|
||||||
%{ninja_install} -C _build
|
%ninja_install bolt
|
||||||
%global _bolt_install_dir %{_buildrootdir}/%{name}-%{version}-%{release}.%{_arch}/usr
|
|
||||||
# remove extera llvm files.
|
# Remove extera llvm files.
|
||||||
find %{_bolt_install_dir} ! -name "llvm-bolt" ! -name "merge-fdata" ! -name "perf2bolt" -type f,l -exec rm -f '{}' \;
|
find %{buildroot}%{install_prefix} \
|
||||||
# remove static libs.
|
! -name "llvm-bolt" \
|
||||||
rm -rf %{_buildrootdir}/root
|
! -name "merge-fdata" \
|
||||||
# remove rpath
|
! -name "perf2bolt" \
|
||||||
chrpath -d %{_bolt_install_dir}/bin/llvm-bolt
|
! -name "llvm-boltdiff" \
|
||||||
chrpath -d %{_bolt_install_dir}/bin/merge-fdata
|
! -name "llvm-bolt-heatmap" \
|
||||||
|
! -name "libbolt_rt_hugify.a" \
|
||||||
|
! -name "libbolt_rt_instr.a" \
|
||||||
|
-type f,l -exec rm -f '{}' \;
|
||||||
|
|
||||||
|
#
|
||||||
|
rm -f %{_builddir}/%{bolt_srcdir}/lib/lib*.a
|
||||||
|
|
||||||
|
# There currently is not support upstream for building html doc from BOLT
|
||||||
|
install -d %{buildroot}%{install_docdir}
|
||||||
|
mv bolt/README.md bolt/docs/*.md %{buildroot}%{install_docdir}
|
||||||
|
|
||||||
|
%check
|
||||||
|
|
||||||
|
%if %{with check}
|
||||||
|
%ifarch x86_64
|
||||||
|
# Bolt makes incorrect assumptions on the location of libbolt_rt_*.a.
|
||||||
|
mkdir -p %{_builddir}/%{bolt_srcdir}/lib
|
||||||
|
for rt in libbolt_rt_instr libbolt_rt_hugify
|
||||||
|
do
|
||||||
|
ln -s %{buildroot}/%{install_libdir}/${rt}.a %{_builddir}/%{bolt_srcdir}/lib
|
||||||
|
done
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%ifarch aarch64
|
||||||
|
# Failing test cases on aarch64
|
||||||
|
rm bolt/test/cache+-deprecated.test bolt/test/bolt-icf.test bolt/test/R_ABS.pic.lld.cpp
|
||||||
|
%endif
|
||||||
|
|
||||||
|
export LD_LIBRARY_PATH=%{_builddir}/%{bolt_srcdir}/lib
|
||||||
|
export DESTDIR=%{buildroot}
|
||||||
|
%ninja_build check
|
||||||
|
|
||||||
|
# Remove files installed during the check phase.
|
||||||
|
rm -f %{buildroot}/%{_builddir}/%{bolt_srcdir}/lib/lib*.a
|
||||||
|
%endif
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%license bolt/LICENSE.TXT
|
%license bolt/LICENSE.TXT
|
||||||
%doc bolt/docs/*
|
%{install_bindir}/llvm-bolt
|
||||||
%exclude %{_includedir}/*
|
%{install_bindir}/llvm-boltdiff
|
||||||
%exclude %{_datadir}/*
|
%{install_bindir}/merge-fdata
|
||||||
%exclude %{_builddir}/%{name}-%{version}/_build/*
|
%{install_bindir}/perf2bolt
|
||||||
%attr(0755,root,root) %{_bindir}/llvm-bolt
|
%{install_bindir}/llvm-bolt-heatmap
|
||||||
%attr(0755,root,root) %{_bindir}/merge-fdata
|
|
||||||
%attr(-,root,root) %{_bindir}/perf2bolt
|
%ifarch x86_64
|
||||||
|
%{install_libdir}/libbolt_rt_hugify.a
|
||||||
|
%{install_libdir}/libbolt_rt_instr.a
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%exclude %{_builddir}/%{bolt_srcdir}/lib/*
|
||||||
|
|
||||||
|
%files doc
|
||||||
|
%doc %{install_docdir}
|
||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Aug 31 2023 zhenyu zhao <zhaozhenyu17@huaiwei.com> 15.0.7-1
|
||||||
|
- Type:Update
|
||||||
|
- ID:NA
|
||||||
|
- SUG:NA
|
||||||
|
- DESC: Update llvm-bolt from llvm-bolt to llvm-bolt-15
|
||||||
|
|
||||||
* Thu Jun 15 2023 Xiong Zhou <xiongzhou4@huawei.com> 0-2.20211016.gitb72f753
|
* Thu Jun 15 2023 Xiong Zhou <xiongzhou4@huawei.com> 0-2.20211016.gitb72f753
|
||||||
- Type:backport
|
- Type:backport
|
||||||
- ID:NA
|
- ID:NA
|
||||||
@ -72,4 +161,5 @@ chrpath -d %{_bolt_install_dir}/bin/merge-fdata
|
|||||||
- Type:Init
|
- Type:Init
|
||||||
- ID:NA
|
- ID:NA
|
||||||
- SUG:NA
|
- SUG:NA
|
||||||
- DESC:Init llvm-bolt repository
|
- DESC:Init llvm-bolt repository
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user