Skip to content

Commit 62ad0bd

Browse files
committed
Merge commit '2b4807ba' into matthias.bump_llvm_green-2b4807
2 parents 3663896 + 2b4807b commit 62ad0bd

File tree

2,553 files changed

+166860
-50278
lines changed

Some content is hidden

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

2,553 files changed

+166860
-50278
lines changed

.github/workflows/release-tasks.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,36 @@ jobs:
7575
git config user.name "llvmbot"
7676
git commit -a -m "Add ${{ steps.validate-tag.outputs.release-version }} documentation"
7777
git push https://${{ secrets.WWW_RELEASES_TOKEN }}@github.com/${{ github.repository_owner }}/www-releases main:main
78+
79+
release-lit:
80+
runs-on: ubuntu-latest
81+
if: github.repository == 'llvm/llvm-project'
82+
steps:
83+
- name: Checkout LLVM
84+
uses: actions/checkout@v3
85+
86+
- name: Install dependencies
87+
run: apt-get install -y python3-setuptools
88+
89+
- name: Test lit
90+
run: |
91+
cd llvm/utils/lit
92+
python3 lit.py tests
93+
94+
- name: Package lit
95+
run: |
96+
cd llvm/utils/lit
97+
# Remove 'dev' suffix from lit version.
98+
sed -i "s/ + 'dev'//g" lit/__init__.py
99+
python3 setup.py sdist
100+
101+
- name: Upload lit to test.pypi.org
102+
uses: pypa/gh-action-pypi-publish@release/v1
103+
with:
104+
password: ${{ secrets.LLVM_LIT_TEST_PYPI_API_TOKEN }}
105+
repository-url: https://test.pypi.org/legacy/
106+
107+
- name: Upload lit to pypi.org
108+
uses: pypa/gh-action-pypi-publish@release/v1
109+
with:
110+
password: ${{ secrets.LLVM_LIT_PYPI_API_TOKEN }}

bolt/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ set(BOLT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
44
set(BOLT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
55
set(CMAKE_CXX_STANDARD 17)
66

7+
# Add path for custom modules.
8+
list(INSERT CMAKE_MODULE_PATH 0 "${BOLT_SOURCE_DIR}/cmake/modules")
9+
710
# Determine default set of targets to build -- the intersection of
811
# those BOLT supports and those LLVM is targeting.
912
set(BOLT_TARGETS_TO_BUILD_all "AArch64;X86")
@@ -111,6 +114,15 @@ endif()
111114

112115
find_program(GNU_LD_EXECUTABLE NAMES ${LLVM_DEFAULT_TARGET_TRIPLE}-ld.bfd ld.bfd DOC "GNU ld")
113116

117+
include(AddBOLT)
118+
119+
option(BOLT_BUILD_TOOLS
120+
"Build the BOLT tools. If OFF, just generate build targets." ON)
121+
122+
add_custom_target(bolt)
123+
set_target_properties(bolt PROPERTIES FOLDER "BOLT")
124+
add_llvm_install_targets(install-bolt DEPENDS bolt COMPONENT bolt)
125+
114126
include_directories(
115127
${CMAKE_CURRENT_SOURCE_DIR}/include
116128
${CMAKE_CURRENT_BINARY_DIR}/include

bolt/cmake/modules/AddBOLT.cmake

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
include(GNUInstallDirs)
2+
include(LLVMDistributionSupport)
3+
4+
macro(add_bolt_executable name)
5+
add_llvm_executable(${name} ${ARGN})
6+
set_target_properties(${name} PROPERTIES FOLDER "BOLT")
7+
endmacro()
8+
9+
macro(add_bolt_tool name)
10+
if (NOT BOLT_BUILD_TOOLS)
11+
set(EXCLUDE_FROM_ALL ON)
12+
endif()
13+
14+
add_bolt_executable(${name} ${ARGN})
15+
16+
if (BOLT_BUILD_TOOLS)
17+
get_target_export_arg(${name} BOLT export_to_bolttargets)
18+
install(TARGETS ${name}
19+
${export_to_bolttargets}
20+
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
21+
COMPONENT bolt)
22+
23+
if(NOT LLVM_ENABLE_IDE)
24+
add_llvm_install_targets(install-${name}
25+
DEPENDS ${name}
26+
COMPONENT bolt)
27+
endif()
28+
set_property(GLOBAL APPEND PROPERTY BOLT_EXPORTS ${name})
29+
endif()
30+
endmacro()
31+
32+
macro(add_bolt_tool_symlink name dest)
33+
llvm_add_tool_symlink(BOLT ${name} ${dest} ALWAYS_GENERATE)
34+
# Always generate install targets
35+
llvm_install_symlink(BOLT ${name} ${dest} ALWAYS_GENERATE COMPONENT bolt)
36+
endmacro()

bolt/include/bolt/Profile/DataAggregator.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,10 @@ class DataAggregator : public DataReader {
199199
/// execution order.
200200
///
201201
/// Return true if the trace is valid, false otherwise.
202-
bool recordTrace(
203-
BinaryFunction &BF, const LBREntry &First, const LBREntry &Second,
204-
uint64_t Count = 1,
205-
SmallVector<std::pair<uint64_t, uint64_t>, 16> *Branches = nullptr) const;
202+
bool
203+
recordTrace(BinaryFunction &BF, const LBREntry &First, const LBREntry &Second,
204+
uint64_t Count,
205+
SmallVector<std::pair<uint64_t, uint64_t>, 16> &Branches) const;
206206

207207
/// Return a vector of offsets corresponding to a trace in a function
208208
/// (see recordTrace() above).

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -838,11 +838,9 @@ bool DataAggregator::doTrace(const LBREntry &First, const LBREntry &Second,
838838
}
839839

840840
bool DataAggregator::recordTrace(
841-
BinaryFunction &BF,
842-
const LBREntry &FirstLBR,
843-
const LBREntry &SecondLBR,
841+
BinaryFunction &BF, const LBREntry &FirstLBR, const LBREntry &SecondLBR,
844842
uint64_t Count,
845-
SmallVector<std::pair<uint64_t, uint64_t>, 16> *Branches) const {
843+
SmallVector<std::pair<uint64_t, uint64_t>, 16> &Branches) const {
846844
BinaryContext &BC = BF.getBinaryContext();
847845

848846
if (!BF.isSimple())
@@ -902,24 +900,27 @@ bool DataAggregator::recordTrace(
902900
return false;
903901
}
904902

905-
// Record fall-through jumps
906-
BinaryBasicBlock::BinaryBranchInfo &BI = BB->getBranchInfo(*NextBB);
907-
BI.Count += Count;
908-
909-
if (Branches) {
910-
const MCInst *Instr = BB->getLastNonPseudoInstr();
911-
uint64_t Offset = 0;
912-
if (Instr)
913-
Offset = BC.MIB->getOffsetWithDefault(*Instr, 0);
914-
else
915-
Offset = BB->getOffset();
903+
const MCInst *Instr = BB->getLastNonPseudoInstr();
904+
uint64_t Offset = 0;
905+
if (Instr)
906+
Offset = BC.MIB->getOffsetWithDefault(*Instr, 0);
907+
else
908+
Offset = BB->getOffset();
916909

917-
Branches->emplace_back(Offset, NextBB->getOffset());
918-
}
910+
Branches.emplace_back(Offset, NextBB->getOffset());
919911

920912
BB = NextBB;
921913
}
922914

915+
// Record fall-through jumps
916+
for (const auto &[FromOffset, ToOffset] : Branches) {
917+
BinaryBasicBlock *FromBB = BF.getBasicBlockContainingOffset(FromOffset);
918+
BinaryBasicBlock *ToBB = BF.getBasicBlockAtOffset(ToOffset);
919+
assert(FromBB && ToBB);
920+
BinaryBasicBlock::BinaryBranchInfo &BI = FromBB->getBranchInfo(*ToBB);
921+
BI.Count += Count;
922+
}
923+
923924
return true;
924925
}
925926

@@ -930,7 +931,7 @@ DataAggregator::getFallthroughsInTrace(BinaryFunction &BF,
930931
uint64_t Count) const {
931932
SmallVector<std::pair<uint64_t, uint64_t>, 16> Res;
932933

933-
if (!recordTrace(BF, FirstLBR, SecondLBR, Count, &Res))
934+
if (!recordTrace(BF, FirstLBR, SecondLBR, Count, Res))
934935
return std::nullopt;
935936

936937
return Res;

bolt/lib/Rewrite/BoltDiff.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ static cl::opt<bool> NormalizeByBin1(
8383
"collection time and sampling rate for this to make sense"),
8484
cl::cat(BoltDiffCategory));
8585

86+
static cl::opt<bool>
87+
SkipNonSimple("skip-non-simple",
88+
cl::desc("skip non-simple functions in reporting"),
89+
cl::ReallyHidden, cl::cat(BoltDiffCategory));
90+
8691
} // end namespace opts
8792

8893
namespace llvm {
@@ -428,8 +433,10 @@ class RewriteInstanceDiff {
428433
llvm::make_second_range(llvm::reverse(LargestDiffs))) {
429434
const double Score2 = getNormalizedScore(*BB2, RI2);
430435
const double Score1 = getNormalizedScore(*BBMap[BB2], RI1);
431-
outs() << "BB " << BB2->getName() << " from "
432-
<< BBToFuncMap[BB2]->getDemangledName()
436+
const BinaryFunction *Func = BBToFuncMap[BB2];
437+
if (opts::SkipNonSimple && !Func->isSimple())
438+
continue;
439+
outs() << "BB " << BB2->getName() << " from " << Func->getDemangledName()
433440
<< "\n\tScore bin1 = " << format("%.4f", Score1 * 100.0)
434441
<< "%\n\tScore bin2 = " << format("%.4f", Score2 * 100.0);
435442
outs() << "%\t(Difference: ";
@@ -460,9 +467,12 @@ class RewriteInstanceDiff {
460467
EdgeTy &Edge1 = EI.second;
461468
const double Score2 = std::get<2>(Edge2);
462469
const double Score1 = std::get<2>(Edge1);
470+
const BinaryFunction *Func = BBToFuncMap[std::get<0>(Edge2)];
471+
if (opts::SkipNonSimple && !Func->isSimple())
472+
continue;
463473
outs() << "Edge (" << std::get<0>(Edge2)->getName() << " -> "
464474
<< std::get<1>(Edge2)->getName() << ") in "
465-
<< BBToFuncMap[std::get<0>(Edge2)]->getDemangledName()
475+
<< Func->getDemangledName()
466476
<< "\n\tScore bin1 = " << format("%.4f", Score1 * 100.0)
467477
<< "%\n\tScore bin2 = " << format("%.4f", Score2 * 100.0);
468478
outs() << "%\t(Difference: ";
@@ -537,6 +547,8 @@ class RewriteInstanceDiff {
537547
Score2 = LTOAggregatedScore2[Iter2->second];
538548
if (Score1 == 0.0 || Score2 == 0.0)
539549
continue;
550+
if (opts::SkipNonSimple && !Func1->isSimple() && !Func2->isSimple())
551+
continue;
540552
LargestDiffs.insert(
541553
std::make_pair<>(std::abs(Score1 - Score2), MapEntry));
542554
ScoreMap[Func2] = std::make_pair<>(Score1, Score2);

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,13 @@ void DWARFRewriter::updateUnitDebugInfo(
407407
DWARFAddressRangesVector &ModuleRanges = *ModuleRangesOrError;
408408
DebugAddressRangesVector OutputRanges =
409409
BC.translateModuleAddressRanges(ModuleRanges);
410+
std::optional<AttrInfo> LowPCAttrInfo =
411+
findAttributeInfo(DIE, dwarf::DW_AT_low_pc);
412+
// For a case where LLD GCs only function used in the CU.
413+
// If CU doesn't have DW_AT_low_pc we are not going to convert,
414+
// so don't need to do anything.
415+
if (OutputRanges.empty() && !Unit.isDWOUnit() && LowPCAttrInfo)
416+
OutputRanges.push_back({0, 0});
410417
const uint64_t RangesSectionOffset =
411418
RangesSectionWriter.addRanges(OutputRanges);
412419
if (!Unit.isDWOUnit())

bolt/test/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ list(APPEND BOLT_TEST_DEPS
3737
lld
3838
llvm-config
3939
llvm-bolt
40-
llvm-boltdiff
4140
llvm-bolt-heatmap
4241
llvm-bat-dump
4342
llvm-dwarfdump
@@ -52,7 +51,6 @@ list(APPEND BOLT_TEST_DEPS
5251
llvm-objcopy
5352
merge-fdata
5453
not
55-
perf2bolt
5654
split-file
5755
yaml2obj
5856
)

0 commit comments

Comments
 (0)