Skip to content

Commit 5ef69e3

Browse files
author
Amirhossein Pashaeehir
committed
Merge branch 'main' into make-unwind-table-internals-accessible
2 parents 7610020 + 23be14b commit 5ef69e3

File tree

654 files changed

+18331
-7813
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

654 files changed

+18331
-7813
lines changed

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
#include "llvm/CodeGen/DIE.h"
2121
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
2222
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
23-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
2423
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
24+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
2525
#include "llvm/Support/Allocator.h"
2626

2727
#include <list>

bolt/lib/Core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
set(LLVM_LINK_COMPONENTS
22
DebugInfoDWARF
3+
DebugInfoDWARFLowLevel
34
Demangle
45
MC
56
MCDisassembler

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
#include "llvm/CodeGen/DIE.h"
1515
#include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h"
1616
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
17-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
1817
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
1918
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
2019
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
2120
#include "llvm/DebugInfo/DWARF/DWARFUnitIndex.h"
21+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
2222
#include "llvm/Support/Casting.h"
2323
#include "llvm/Support/Debug.h"
2424
#include "llvm/Support/ErrorHandling.h"

bolt/lib/Core/DebugNames.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
#include "bolt/Core/DebugNames.h"
1010
#include "bolt/Core/BinaryContext.h"
11-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
1211
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
12+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
1313
#include "llvm/Support/EndianStream.h"
1414
#include "llvm/Support/LEB128.h"
1515
#include <cstdint>

bolt/lib/Rewrite/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
set(LLVM_LINK_COMPONENTS
22
Core
33
DebugInfoDWARF
4+
DebugInfoDWARFLowLevel
45
JITLink
56
MC
67
Object

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
2525
#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
2626
#include "llvm/DebugInfo/DWARF/DWARFDebugLoc.h"
27-
#include "llvm/DebugInfo/DWARF/DWARFExpression.h"
2827
#include "llvm/DebugInfo/DWARF/DWARFFormValue.h"
2928
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
3029
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
30+
#include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
3131
#include "llvm/MC/MCAsmBackend.h"
3232
#include "llvm/MC/MCAssembler.h"
3333
#include "llvm/MC/MCObjectWriter.h"

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4190,6 +4190,11 @@ void RewriteInstance::patchELFPHDRTable() {
41904190
NewWritableSegmentSize = NextAvailableAddress - NewWritableSegmentAddress;
41914191
}
41924192

4193+
if (!NewTextSegmentSize && !NewWritableSegmentSize) {
4194+
BC->outs() << "BOLT-INFO: not adding new segments\n";
4195+
return;
4196+
}
4197+
41934198
const uint64_t SavedPos = OS.tell();
41944199
OS.seek(PHDRTableOffset);
41954200

bolt/test/program-header.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Check that llvm-bolt does not add new segments when writing code in-place.
2+
3+
REQUIRES: system-linux
4+
5+
RUN: %clang %cflags %p/Inputs/hello.c -o %t -no-pie -Wl,-q
6+
RUN: llvm-bolt %t -o %t.bolt --use-old-text --align-functions=1 \
7+
RUN: --no-huge-pages --align-text=1 --use-gnu-stack \
8+
RUN: | FileCheck %s --check-prefix=CHECK-BOLT
9+
RUN: llvm-readelf -WS %t.bolt | FileCheck %s
10+
11+
CHECK-BOLT: rewriting .eh_frame_hdr in-place
12+
CHECK-BOLT: not adding new segments
13+
14+
CHECK-NOT: .bolt.org.eh_frame_hdr

bolt/utils/llvm-bolt-wrapper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def get_cfg(key):
7979

8080

8181
# perf2bolt mode
82-
PERF2BOLT_MODE = ["-aggregate-only", "-ignore-build-id"]
82+
PERF2BOLT_MODE = ["-aggregate-only", "-ignore-build-id", "-show-density"]
8383

8484
# boltdiff mode
8585
BOLTDIFF_MODE = ["-diff-only", "-o", "/dev/null"]

clang-tools-extra/clang-doc/BitcodeReader.cpp

Lines changed: 56 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -800,11 +800,39 @@ llvm::Error ClangDocBitcodeReader::readBlock(unsigned ID, T I) {
800800
}
801801
}
802802

803-
// TODO: Create a helper that can receive a function to reduce repetition for
804-
// most blocks.
803+
// TODO: fix inconsistentent returning of errors in add callbacks.
804+
// Once that's fixed, we only need one handleSubBlock.
805+
template <typename InfoType, typename T, typename Callback>
806+
llvm::Error ClangDocBitcodeReader::handleSubBlock(unsigned ID, T Parent,
807+
Callback Function) {
808+
InfoType Info;
809+
if (auto Err = readBlock(ID, &Info))
810+
return Err;
811+
Function(Parent, std::move(Info));
812+
return llvm::Error::success();
813+
}
814+
815+
template <typename InfoType, typename T, typename Callback>
816+
llvm::Error ClangDocBitcodeReader::handleTypeSubBlock(unsigned ID, T Parent,
817+
Callback Function) {
818+
InfoType Info;
819+
if (auto Err = readBlock(ID, &Info))
820+
return Err;
821+
if (auto Err = Function(Parent, std::move(Info)))
822+
return Err;
823+
return llvm::Error::success();
824+
}
825+
805826
template <typename T>
806827
llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) {
807828
llvm::TimeTraceScope("Reducing infos", "readSubBlock");
829+
830+
static auto CreateAddFunc = [](auto AddFunc) {
831+
return [AddFunc](auto Parent, auto Child) {
832+
return AddFunc(Parent, std::move(Child));
833+
};
834+
};
835+
808836
switch (ID) {
809837
// Blocks can only have certain types of sub blocks.
810838
case BI_COMMENT_BLOCK_ID: {
@@ -816,28 +844,16 @@ llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) {
816844
return llvm::Error::success();
817845
}
818846
case BI_TYPE_BLOCK_ID: {
819-
TypeInfo TI;
820-
if (auto Err = readBlock(ID, &TI))
821-
return Err;
822-
if (auto Err = addTypeInfo(I, std::move(TI)))
823-
return Err;
824-
return llvm::Error::success();
847+
return handleTypeSubBlock<TypeInfo>(
848+
ID, I, CreateAddFunc(addTypeInfo<T, TypeInfo>));
825849
}
826850
case BI_FIELD_TYPE_BLOCK_ID: {
827-
FieldTypeInfo TI;
828-
if (auto Err = readBlock(ID, &TI))
829-
return Err;
830-
if (auto Err = addTypeInfo(I, std::move(TI)))
831-
return Err;
832-
return llvm::Error::success();
851+
return handleTypeSubBlock<FieldTypeInfo>(
852+
ID, I, CreateAddFunc(addTypeInfo<T, FieldTypeInfo>));
833853
}
834854
case BI_MEMBER_TYPE_BLOCK_ID: {
835-
MemberTypeInfo TI;
836-
if (auto Err = readBlock(ID, &TI))
837-
return Err;
838-
if (auto Err = addTypeInfo(I, std::move(TI)))
839-
return Err;
840-
return llvm::Error::success();
855+
return handleTypeSubBlock<MemberTypeInfo>(
856+
ID, I, CreateAddFunc(addTypeInfo<T, MemberTypeInfo>));
841857
}
842858
case BI_REFERENCE_BLOCK_ID: {
843859
Reference R;
@@ -848,81 +864,46 @@ llvm::Error ClangDocBitcodeReader::readSubBlock(unsigned ID, T I) {
848864
return llvm::Error::success();
849865
}
850866
case BI_FUNCTION_BLOCK_ID: {
851-
FunctionInfo F;
852-
if (auto Err = readBlock(ID, &F))
853-
return Err;
854-
addChild(I, std::move(F));
855-
return llvm::Error::success();
867+
return handleSubBlock<FunctionInfo>(
868+
ID, I, CreateAddFunc(addChild<T, FunctionInfo>));
856869
}
857870
case BI_BASE_RECORD_BLOCK_ID: {
858-
BaseRecordInfo BR;
859-
if (auto Err = readBlock(ID, &BR))
860-
return Err;
861-
addChild(I, std::move(BR));
862-
return llvm::Error::success();
871+
return handleSubBlock<BaseRecordInfo>(
872+
ID, I, CreateAddFunc(addChild<T, BaseRecordInfo>));
863873
}
864874
case BI_ENUM_BLOCK_ID: {
865-
EnumInfo E;
866-
if (auto Err = readBlock(ID, &E))
867-
return Err;
868-
addChild(I, std::move(E));
869-
return llvm::Error::success();
875+
return handleSubBlock<EnumInfo>(ID, I,
876+
CreateAddFunc(addChild<T, EnumInfo>));
870877
}
871878
case BI_ENUM_VALUE_BLOCK_ID: {
872-
EnumValueInfo EV;
873-
if (auto Err = readBlock(ID, &EV))
874-
return Err;
875-
addChild(I, std::move(EV));
876-
return llvm::Error::success();
879+
return handleSubBlock<EnumValueInfo>(
880+
ID, I, CreateAddFunc(addChild<T, EnumValueInfo>));
877881
}
878882
case BI_TEMPLATE_BLOCK_ID: {
879-
TemplateInfo TI;
880-
if (auto Err = readBlock(ID, &TI))
881-
return Err;
882-
addTemplate(I, std::move(TI));
883-
return llvm::Error::success();
883+
return handleSubBlock<TemplateInfo>(ID, I, CreateAddFunc(addTemplate<T>));
884884
}
885885
case BI_TEMPLATE_SPECIALIZATION_BLOCK_ID: {
886-
TemplateSpecializationInfo TSI;
887-
if (auto Err = readBlock(ID, &TSI))
888-
return Err;
889-
addTemplateSpecialization(I, std::move(TSI));
890-
return llvm::Error::success();
886+
return handleSubBlock<TemplateSpecializationInfo>(
887+
ID, I, CreateAddFunc(addTemplateSpecialization<T>));
891888
}
892889
case BI_TEMPLATE_PARAM_BLOCK_ID: {
893-
TemplateParamInfo TPI;
894-
if (auto Err = readBlock(ID, &TPI))
895-
return Err;
896-
addTemplateParam(I, std::move(TPI));
897-
return llvm::Error::success();
890+
return handleSubBlock<TemplateParamInfo>(
891+
ID, I, CreateAddFunc(addTemplateParam<T>));
898892
}
899893
case BI_TYPEDEF_BLOCK_ID: {
900-
TypedefInfo TI;
901-
if (auto Err = readBlock(ID, &TI))
902-
return Err;
903-
addChild(I, std::move(TI));
904-
return llvm::Error::success();
894+
return handleSubBlock<TypedefInfo>(ID, I,
895+
CreateAddFunc(addChild<T, TypedefInfo>));
905896
}
906897
case BI_CONSTRAINT_BLOCK_ID: {
907-
ConstraintInfo CI;
908-
if (auto Err = readBlock(ID, &CI))
909-
return Err;
910-
addConstraint(I, std::move(CI));
911-
return llvm::Error::success();
898+
return handleSubBlock<ConstraintInfo>(ID, I,
899+
CreateAddFunc(addConstraint<T>));
912900
}
913901
case BI_CONCEPT_BLOCK_ID: {
914-
ConceptInfo CI;
915-
if (auto Err = readBlock(ID, &CI))
916-
return Err;
917-
addChild(I, std::move(CI));
918-
return llvm::Error::success();
902+
return handleSubBlock<ConceptInfo>(ID, I,
903+
CreateAddFunc(addChild<T, ConceptInfo>));
919904
}
920905
case BI_VAR_BLOCK_ID: {
921-
VarInfo VI;
922-
if (auto Err = readBlock(ID, &VI))
923-
return Err;
924-
addChild(I, std::move(VI));
925-
return llvm::Error::success();
906+
return handleSubBlock<VarInfo>(ID, I, CreateAddFunc(addChild<T, VarInfo>));
926907
}
927908
default:
928909
return llvm::createStringError(llvm::inconvertibleErrorCode(),

0 commit comments

Comments
 (0)