Skip to content

Commit 1537915

Browse files
authored
Merge pull request #149 from sx-aurora-dev/feature/merge-upstream-20220202
Feature/merge upstream 20220202
2 parents 23524b6 + 67c845a commit 1537915

File tree

3,342 files changed

+110985
-64483
lines changed

Some content is hidden

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

3,342 files changed

+110985
-64483
lines changed

.clang-tidy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ CheckOptions:
66
value: CamelCase
77
- key: readability-identifier-naming.FunctionCase
88
value: camelBack
9+
# Exclude from scanning as this is an exported symbol used for fuzzing
10+
# throughout the code base.
11+
- key: readability-identifier-naming.FunctionIgnoredRegexp
12+
value: "LLVMFuzzerTestOneInput"
913
- key: readability-identifier-naming.MemberCase
1014
value: CamelCase
1115
- key: readability-identifier-naming.ParameterCase

.github/workflows/closed-issues.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: Labeling closed issues
2+
on:
3+
issues:
4+
types: ['closed']
5+
6+
jobs:
7+
automate-issues-labels:
8+
runs-on: ubuntu-latest
9+
if: github.repository == 'llvm/llvm-project'
10+
steps:
11+
- uses: andymckay/labeler@1.0.4
12+
with:
13+
remove-labels: "awaiting-review"

bolt/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ add_subdirectory(lib)
9191
add_subdirectory(tools)
9292

9393
if (BOLT_INCLUDE_TESTS)
94+
if (EXISTS ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest/include/gtest/gtest.h)
95+
add_subdirectory(unittests)
96+
list(APPEND BOLT_TEST_DEPS BoltUnitTests)
97+
endif()
9498
add_subdirectory(test)
9599
endif()
96100

bolt/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,14 @@ compiler option. Since GCC8 enables this option by default, you have to
3030
explicitly disable it by adding `-fno-reorder-blocks-and-partition` flag if
3131
you are compiling with GCC8 or above.
3232

33+
NOTE2: DWARF v5 is the new debugging format generated by the latest LLVM and GCC
34+
compilers. It offers several benefits over the previous DWARF v4. Currently, the
35+
support for v5 is a work in progress for BOLT. While you will be able to
36+
optimize binaries produced by the latest compilers, until the support is
37+
complete, you will not be able to update the debug info with
38+
`-update-debug-sections`. To temporarily work around the issue, we recommend
39+
compiling binaries with `-gdwarf-4` option that forces DWARF v4 output.
40+
3341
PIE and .so support has been added recently. Please report bugs if you
3442
encounter any issues.
3543

bolt/include/bolt/Core/DebugData.h

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ struct DebugLineTableRowRef {
107107
/// Common buffer vector used for debug info handling.
108108
using DebugBufferVector = SmallVector<char, 16>;
109109

110+
/// Map of old CU offset to new offset and length.
111+
struct CUInfo {
112+
uint32_t Offset;
113+
uint32_t Length;
114+
};
115+
using CUOffsetMap = std::map<uint32_t, CUInfo>;
116+
110117
/// Serializes the .debug_ranges DWARF section.
111118
class DebugRangesSectionWriter {
112119
public:
@@ -155,9 +162,8 @@ class DebugARangesSectionWriter {
155162
/// Writes .debug_aranges with the added ranges to the MCObjectWriter.
156163
/// Takes in \p RangesStream to write into, and \p CUMap which maps CU
157164
/// original offsets to new ones.
158-
void
159-
writeARangesSection(raw_svector_ostream &RangesStream,
160-
const std::unordered_map<uint32_t, uint32_t> CUMap) const;
165+
void writeARangesSection(raw_svector_ostream &RangesStream,
166+
const CUOffsetMap &CUMap) const;
161167

162168
/// Resets the writer to a clear state.
163169
void reset() { CUAddressRanges.clear(); }
@@ -647,8 +653,8 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
647653
void setDWPOffset(uint64_t DWPOffset) { DWPUnitOffset = DWPOffset; }
648654

649655
/// When this function is invoked all of the DebugInfo Patches must be done.
650-
/// Returns a map of old CU offsets to new ones.
651-
std::unordered_map<uint32_t, uint32_t> computeNewOffsets();
656+
/// Returns a map of old CU offsets to new offsets and new sizes.
657+
CUOffsetMap computeNewOffsets(DWARFContext &DWCtx, bool IsDWOContext);
652658

653659
private:
654660
struct PatchDeleter {
@@ -685,7 +691,7 @@ class DebugInfoBinaryPatcher : public SimpleBinaryPatcher {
685691
using UniquePatchPtrType = std::unique_ptr<Patch, PatchDeleter>;
686692

687693
uint64_t DWPUnitOffset{0};
688-
uint32_t ChangeInSize{0};
694+
int32_t ChangeInSize{0};
689695
std::vector<UniquePatchPtrType> DebugPatches;
690696
/// Mutex used for parallel processing of debug info.
691697
std::mutex WriterMutex;
@@ -709,8 +715,11 @@ class DebugAbbrevWriter {
709715
std::unique_ptr<DebugBufferVector> Buffer;
710716
std::unique_ptr<raw_svector_ostream> Stream;
711717
};
712-
/// Map original unit abbrev offset to abbreviations data.
713-
std::map<uint64_t, AbbrevData> UnitsAbbrevData;
718+
/// Map original unit to abbreviations data.
719+
std::unordered_map<const DWARFUnit *, AbbrevData *> UnitsAbbrevData;
720+
721+
/// Map from Hash Signature to AbbrevData.
722+
llvm::StringMap<std::unique_ptr<AbbrevData>> AbbrevDataCache;
714723

715724
/// Attributes substitution (patch) information.
716725
struct PatchInfo {
@@ -777,10 +786,8 @@ class DebugAbbrevWriter {
777786
/// Return an offset in the finalized abbrev section corresponding to CU/TU.
778787
uint64_t getAbbreviationsOffsetForUnit(const DWARFUnit &Unit) {
779788
assert(!DWOId && "offsets are tracked for non-DWO units only");
780-
assert(UnitsAbbrevData.find(Unit.getAbbreviationsOffset()) !=
781-
UnitsAbbrevData.end() &&
782-
"no abbrev data found for unit");
783-
return UnitsAbbrevData[Unit.getAbbreviationsOffset()].Offset;
789+
assert(UnitsAbbrevData.count(&Unit) && "no abbrev data found for unit");
790+
return UnitsAbbrevData[&Unit]->Offset;
784791
}
785792
};
786793

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,14 @@ class MCPlusBuilder {
18981898
}
18991899
};
19001900

1901+
MCPlusBuilder *createX86MCPlusBuilder(const MCInstrAnalysis *,
1902+
const MCInstrInfo *,
1903+
const MCRegisterInfo *);
1904+
1905+
MCPlusBuilder *createAArch64MCPlusBuilder(const MCInstrAnalysis *,
1906+
const MCInstrInfo *,
1907+
const MCRegisterInfo *);
1908+
19011909
} // namespace bolt
19021910
} // namespace llvm
19031911

bolt/include/bolt/Rewrite/DWARFRewriter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@ class DWARFRewriter {
9393
makeFinalLocListsSection(SimpleBinaryPatcher &DebugInfoPatcher);
9494

9595
/// Finalize debug sections in the main binary.
96-
void finalizeDebugSections(DebugInfoBinaryPatcher &DebugInfoPatcher);
96+
CUOffsetMap finalizeDebugSections(DebugInfoBinaryPatcher &DebugInfoPatcher);
9797

9898
/// Patches the binary for DWARF address ranges (e.g. in functions and lexical
9999
/// blocks) to be updated.
100100
void updateDebugAddressRanges();
101101

102102
/// Rewrite .gdb_index section if present.
103-
void updateGdbIndexSection();
103+
void updateGdbIndexSection(CUOffsetMap &CUMap);
104104

105105
/// Output .dwo files.
106106
void writeDWOFiles(std::unordered_map<uint64_t, std::string> &DWOIdToName);

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,11 @@ class RewriteInstance {
545545
friend class RewriteInstanceDiff;
546546
};
547547

548+
MCPlusBuilder *createMCPlusBuilder(const Triple::ArchType Arch,
549+
const MCInstrAnalysis *Analysis,
550+
const MCInstrInfo *Info,
551+
const MCRegisterInfo *RegInfo);
552+
548553
} // namespace bolt
549554
} // namespace llvm
550555

bolt/include/bolt/Utils/CommandLineOpts.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ extern llvm::cl::opt<unsigned long long> HeatmapMinAddress;
4444
extern llvm::cl::opt<bool> HotData;
4545
extern llvm::cl::opt<bool> HotFunctionsAtEnd;
4646
extern llvm::cl::opt<bool> HotText;
47-
extern llvm::cl::opt<std::string> InputFilename;
4847
extern llvm::cl::opt<bool> Instrument;
4948
extern llvm::cl::opt<std::string> OutputFilename;
5049
extern llvm::cl::opt<std::string> PerfData;

0 commit comments

Comments
 (0)