Compare commits
10 Commits
cf08a58b30
...
b8e810229c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8e810229c | ||
|
|
883de9278f | ||
|
|
af9482504e | ||
|
|
5fe821c116 | ||
|
|
e4a863997f | ||
|
|
7f781ad8c0 | ||
|
|
73530ba624 | ||
|
|
04a2d3b56a | ||
|
|
36a1929a7d | ||
|
|
a9528f0cef |
@ -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
|
|
||||||
|
|
||||||
21
README.en.md
21
README.en.md
@ -1,9 +1,22 @@
|
|||||||
# llvm-bolt
|
# llvm-bolt-latest
|
||||||
|
|
||||||
#### Description
|
#### Description
|
||||||
BOLT is a post-link optimizer developed to speed up large applications.
|
llvm-bolt is a post-link optimizer developed to speed up large applications
|
||||||
It achieves the improvements by optimizing application's code layout based
|
|
||||||
on execution profile gathered by sampling profiler, such as Linux perf tool.
|
#### Software Architecture
|
||||||
|
Software architecture description
|
||||||
|
|
||||||
|
#### Installation
|
||||||
|
|
||||||
|
1. xxxx
|
||||||
|
2. xxxx
|
||||||
|
3. xxxx
|
||||||
|
|
||||||
|
#### Instructions
|
||||||
|
|
||||||
|
1. xxxx
|
||||||
|
2. xxxx
|
||||||
|
3. xxxx
|
||||||
|
|
||||||
#### Contribution
|
#### Contribution
|
||||||
|
|
||||||
|
|||||||
22
README.md
22
README.md
@ -1,9 +1,23 @@
|
|||||||
# llvm-bolt
|
# llvm-bolt-latest
|
||||||
|
|
||||||
#### 介绍
|
#### 介绍
|
||||||
BOLT is a post-link optimizer developed to speed up large applications.
|
llvm-bolt is a post-link optimizer developed to speed up large applications
|
||||||
It achieves the improvements by optimizing application's code layout based
|
|
||||||
on execution profile gathered by sampling profiler, such as Linux perf tool.
|
#### 软件架构
|
||||||
|
软件架构说明
|
||||||
|
|
||||||
|
|
||||||
|
#### 安装教程
|
||||||
|
|
||||||
|
1. xxxx
|
||||||
|
2. xxxx
|
||||||
|
3. xxxx
|
||||||
|
|
||||||
|
#### 使用说明
|
||||||
|
|
||||||
|
1. xxxx
|
||||||
|
2. xxxx
|
||||||
|
3. xxxx
|
||||||
|
|
||||||
#### 参与贡献
|
#### 参与贡献
|
||||||
|
|
||||||
|
|||||||
@ -1,28 +1,31 @@
|
|||||||
%bcond_without sys_llvm
|
|
||||||
%bcond_with check
|
%bcond_with check
|
||||||
|
%bcond_without toolchain_clang
|
||||||
|
|
||||||
%global maj_ver 17
|
%if %{with toolchain_clang}
|
||||||
%global min_ver 0
|
%global toolchain clang
|
||||||
%global patch_ver 6
|
%endif
|
||||||
|
|
||||||
|
%global maj_ver 18
|
||||||
|
%global min_ver 1
|
||||||
|
%global patch_ver 8
|
||||||
%global bolt_version %{maj_ver}.%{min_ver}.%{patch_ver}
|
%global bolt_version %{maj_ver}.%{min_ver}.%{patch_ver}
|
||||||
%global bolt_srcdir llvm-project-%{bolt_version}.src
|
%global bolt_srcdir llvm-project-%{bolt_version}.src
|
||||||
|
|
||||||
%if %{with sys_llvm}
|
%global _scl_prefix /opt/openEuler
|
||||||
%global pkg_name llvm-bolt
|
%{?scl:%scl_package %scl}
|
||||||
%global install_prefix %{_prefix}
|
%{!?scl:%global scl_prefix llvm-toolset-%{maj_ver}-}
|
||||||
%else
|
%{!?scl:%global pkg_name %{name}}
|
||||||
%global pkg_name llvm-bolt%{maj_ver}
|
%global install_prefix %{!?scl:%{_scl_prefix}/llvm-toolset-%{maj_ver}/root}%{_prefix}
|
||||||
%global install_prefix %{_libdir}/llvm%{maj_ver}
|
%global install_datadir %{!?scl:%{_scl_prefix}/llvm-toolset-%{maj_ver}/root}%{_datadir}
|
||||||
%endif
|
|
||||||
|
|
||||||
%global install_bindir %{install_prefix}/bin
|
%global install_bindir %{install_prefix}/bin
|
||||||
%global install_libdir %{install_prefix}/lib
|
%global install_libdir %{install_prefix}/lib
|
||||||
%global install_docdir %{install_prefix}/share/doc
|
%global install_docdir %{install_prefix}/share/doc
|
||||||
%global max_link_jobs 2
|
%global max_link_jobs 2
|
||||||
|
|
||||||
Name: %{pkg_name}
|
Name: %{?scl_prefix}llvm-bolt
|
||||||
Version: %{bolt_version}
|
Version: %{bolt_version}
|
||||||
Release: 1
|
Release: 2
|
||||||
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/llvm/llvm-project/tree/main/bolt
|
URL: https://github.com/llvm/llvm-project/tree/main/bolt
|
||||||
@ -43,6 +46,11 @@ BuildRequires: zlib-devel
|
|||||||
BuildRequires: python3-lit
|
BuildRequires: python3-lit
|
||||||
BuildRequires: python3-psutil
|
BuildRequires: python3-psutil
|
||||||
BuildRequires: doxygen
|
BuildRequires: doxygen
|
||||||
|
%if %{with toolchain_clang}
|
||||||
|
BuildRequires: clang
|
||||||
|
%endif
|
||||||
|
|
||||||
|
%{?scl:Requires: %scl_runtime}
|
||||||
|
|
||||||
%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.
|
||||||
@ -52,7 +60,7 @@ on execution profile gathered by sampling profiler, such as Linux perf tool.
|
|||||||
%package doc
|
%package doc
|
||||||
Summary: Documentation for BOLT
|
Summary: Documentation for BOLT
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
Requires: %{name} = %{version}-%{release}
|
Requires: %{pkg_name} = %{version}-%{release}
|
||||||
|
|
||||||
%description doc
|
%description doc
|
||||||
Documentation for the BOLT optimizer
|
Documentation for the BOLT optimizer
|
||||||
@ -77,6 +85,10 @@ Documentation for the BOLT optimizer
|
|||||||
-DLLVM_EXTERNAL_LIT=%{_bindir}/lit \
|
-DLLVM_EXTERNAL_LIT=%{_bindir}/lit \
|
||||||
-DLLVM_ENABLE_PROJECTS="bolt" \
|
-DLLVM_ENABLE_PROJECTS="bolt" \
|
||||||
-DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \
|
-DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \
|
||||||
|
%if "%{toolchain}" == "clang"
|
||||||
|
-DCMAKE_C_COMPILER=clang \
|
||||||
|
-DCMAKE_CXX_COMPILER=clang++ \
|
||||||
|
%endif
|
||||||
%ifarch %ix86 x86_64
|
%ifarch %ix86 x86_64
|
||||||
-DLLVM_TARGETS_TO_BUILD="X86"
|
-DLLVM_TARGETS_TO_BUILD="X86"
|
||||||
%endif
|
%endif
|
||||||
@ -135,19 +147,30 @@ rm -f %{buildroot}/%{_builddir}/%{bolt_srcdir}/%{_vpath_builddir}/%{_lib}/lib*.a
|
|||||||
%{install_bindir}/merge-fdata
|
%{install_bindir}/merge-fdata
|
||||||
%{install_bindir}/perf2bolt
|
%{install_bindir}/perf2bolt
|
||||||
%{install_bindir}/llvm-bolt-heatmap
|
%{install_bindir}/llvm-bolt-heatmap
|
||||||
|
%ifnarch riscv64
|
||||||
%ifarch x86_64
|
|
||||||
%{install_libdir}/libbolt_rt_hugify.a
|
%{install_libdir}/libbolt_rt_hugify.a
|
||||||
%{install_libdir}/libbolt_rt_instr.a
|
%{install_libdir}/libbolt_rt_instr.a
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
%exclude %{_builddir}/%{bolt_srcdir}/lib/*
|
|
||||||
|
|
||||||
%files doc
|
%files doc
|
||||||
%doc %{install_docdir}
|
%doc %{install_docdir}
|
||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Dec 23 2024 laokz <zhangkai@iscas.ac.cn> - 18.1.8-2
|
||||||
|
- riscv64: not package non-exist .a files
|
||||||
|
|
||||||
|
* Fri Dec 6 2024 liyunfei <liyunfei33@huawei.com> - 18.1.8-1
|
||||||
|
- init for Multi-Version LLVM-18.1.8
|
||||||
|
|
||||||
|
* Tue Nov 12 2024 Funda Wang <fundawang@yeah.net> - 17.0.6-3
|
||||||
|
- adopt to new cmake macro
|
||||||
|
- build with gcc now, as llvm/clang will produce linking error
|
||||||
|
against libLLVMTableGen.a now
|
||||||
|
|
||||||
|
* Fri Jul 5 2024 liyunfei <liyunfei33@huawei.com> - 17.0.6-2
|
||||||
|
- Add toolchain_clang build support
|
||||||
|
|
||||||
* Mon Dec 4 2023 zhoujing <zhoujing106@huawei.com> 17.0.6-1
|
* Mon Dec 4 2023 zhoujing <zhoujing106@huawei.com> 17.0.6-1
|
||||||
- Update to 17.0.6
|
- Update to 17.0.6
|
||||||
|
|
||||||
|
|||||||
4
llvm-bolt.yaml
Normal file
4
llvm-bolt.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
version_control: github
|
||||||
|
src_repo: llvm/llvm-project
|
||||||
|
tag_prefix: ^llvmorg-
|
||||||
|
separator: .
|
||||||
Binary file not shown.
Binary file not shown.
BIN
llvm-project-18.1.8.src.tar.xz.sig
Normal file
BIN
llvm-project-18.1.8.src.tar.xz.sig
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user