Skip to content

Commit aa4395a

Browse files
authored
Merge branch 'main' into lv-NFC-ee-scalar-extract
2 parents dcaed17 + 1906c18 commit aa4395a

File tree

2,599 files changed

+263775
-47001
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,599 files changed

+263775
-47001
lines changed

.ci/monolithic-linux.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function at-exit {
3333

3434
mkdir -p artifacts
3535
ccache --print-stats > artifacts/ccache_stats.txt
36+
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
3637

3738
# If building fails there will be no results files.
3839
shopt -s nullglob

.ci/monolithic-windows.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function at-exit {
3232

3333
mkdir -p artifacts
3434
sccache --show-stats >> artifacts/sccache_stats.txt
35+
cp "${BUILD_DIR}"/.ninja_log artifacts/.ninja_log
3536

3637
# If building fails there will be no results files.
3738
shopt -s nullglob

.clang-format-ignore

Whitespace-only changes.

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ RUN cmake -B ./build -G Ninja ./llvm \
3232
-DLLVM_ENABLE_RUNTIMES="compiler-rt" \
3333
-DCMAKE_INSTALL_PREFIX="$LLVM_SYSROOT" \
3434
-DLLVM_ENABLE_PROJECTS="bolt;clang;lld;clang-tools-extra" \
35-
-DLLVM_DISTRIBUTION_COMPONENTS="lld;compiler-rt;clang-format;scan-build" \
35+
-DLLVM_DISTRIBUTION_COMPONENTS="lld;compiler-rt;clang-format;scan-build;llvm-symbolizer" \
3636
-DCLANG_DEFAULT_LINKER="lld"
3737

3838
RUN ninja -C ./build stage2-clang-bolt stage2-install-distribution && ninja -C ./build install-distribution

.github/workflows/libcxx-build-and-test.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ jobs:
216216
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
217217
- uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
218218
with:
219-
xcode-version: 'latest'
219+
# https://github.com/actions/runner-images/blob/main/images/macos/macos-15-Readme.md
220+
xcode-version: '16.3'
220221
- uses: seanmiddleditch/gha-setup-ninja@3b1f8f94a2f8254bd26914c4ab9474d4f0015f67 # v6
221222
- name: Build and test
222223
run: |

.github/workflows/premerge.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ jobs:
6565
export CXX=/opt/llvm/bin/clang++
6666
6767
./.ci/monolithic-linux.sh "${projects_to_build}" "${project_check_targets}" "${runtimes_to_build}" "${runtimes_check_targets}"
68+
- name: "Upload artifact"
69+
- name: Upload Artifacts
70+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
71+
with:
72+
name: Premerge Artifacts (Linux)
73+
path: artifacts/
74+
retention-days: 5
75+
include-hidden-files: 'true'
6876

6977
premerge-checks-windows:
7078
name: Windows Premerge Checks (Test Only - Please Ignore Results)
@@ -113,6 +121,13 @@ jobs:
113121
set MAX_PARALLEL_LINK_JOBS=64
114122
call C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64
115123
bash .ci/monolithic-windows.sh "${{ steps.vars.outputs.windows-projects }}" "${{ steps.vars.outputs.windows-check-targets }}"
124+
- name: Upload Artifacts
125+
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
126+
with:
127+
name: Premerge Artifacts (Windows)
128+
path: artifacts/
129+
retention-days: 5
130+
include-hidden-files: 'true'
116131

117132
premerge-check-macos:
118133
name: MacOS Premerge Checks

.mailmap

Lines changed: 5 additions & 4 deletions

bolt/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ endforeach()
8282

8383
set(BOLT_ENABLE_RUNTIME_default OFF)
8484
if ((CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"
85-
OR CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$")
85+
OR CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm64|aarch64)$"
86+
OR CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
8687
AND (CMAKE_SYSTEM_NAME STREQUAL "Linux"
8788
OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
8889
AND (NOT CMAKE_CROSSCOMPILING))
@@ -136,7 +137,7 @@ if (LLVM_INCLUDE_TESTS)
136137
endif()
137138

138139
if (BOLT_ENABLE_RUNTIME)
139-
message(STATUS "Building BOLT runtime libraries for X86")
140+
message(STATUS "Building BOLT runtime libraries for ${CMAKE_SYSTEM_PROCESSOR}")
140141
set(extra_args "")
141142
if(CMAKE_SYSROOT)
142143
list(APPEND extra_args -DCMAKE_SYSROOT=${CMAKE_SYSROOT})

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,11 @@ class BinaryFunction {
11741174
return getSecondaryEntryPointSymbol(BB.getLabel());
11751175
}
11761176

1177+
/// Remove a label from the secondary entry point map.
1178+
void removeSymbolFromSecondaryEntryPointMap(const MCSymbol *Label) {
1179+
SecondaryEntryPoints.erase(Label);
1180+
}
1181+
11771182
/// Return true if the basic block is an entry point into the function
11781183
/// (either primary or secondary).
11791184
bool isEntryPoint(const BinaryBasicBlock &BB) const {
@@ -2126,6 +2131,10 @@ class BinaryFunction {
21262131
return Islands && !Islands->DataOffsets.empty();
21272132
}
21282133

2134+
bool isStartOfConstantIsland(uint64_t Offset) const {
2135+
return hasConstantIsland() && Islands->DataOffsets.count(Offset);
2136+
}
2137+
21292138
/// Return true iff the symbol could be seen inside this function otherwise
21302139
/// it is probably another function.
21312140
bool isSymbolValidInScope(const SymbolRef &Symbol, uint64_t SymbolSize) const;

bolt/lib/Core/BinaryContext.cpp

Lines changed: 37 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,21 @@ bool BinaryContext::analyzeJumpTable(const uint64_t Address,
579579
TrimmedSize = EntriesAsAddress->size();
580580
};
581581

582+
auto printEntryDiagnostics = [&](raw_ostream &OS,
583+
const BinaryFunction *TargetBF) {
584+
OS << "FAIL: function doesn't contain this address\n";
585+
if (!TargetBF)
586+
return;
587+
OS << " ! function containing this address: " << *TargetBF << '\n';
588+
if (!TargetBF->isFragment())
589+
return;
590+
OS << " ! is a fragment with parents: ";
591+
ListSeparator LS;
592+
for (BinaryFunction *Parent : TargetBF->ParentFragments)
593+
OS << LS << *Parent;
594+
OS << '\n';
595+
};
596+
582597
ErrorOr<const BinarySection &> Section = getSectionForAddress(Address);
583598
if (!Section)
584599
return false;
@@ -646,25 +661,9 @@ bool BinaryContext::analyzeJumpTable(const uint64_t Address,
646661

647662
// Function or one of its fragments.
648663
const BinaryFunction *TargetBF = getBinaryFunctionContainingAddress(Value);
649-
const bool DoesBelongToFunction =
650-
BF.containsAddress(Value) ||
651-
(TargetBF && areRelatedFragments(TargetBF, &BF));
652-
if (!DoesBelongToFunction) {
653-
LLVM_DEBUG({
654-
if (!BF.containsAddress(Value)) {
655-
dbgs() << "FAIL: function doesn't contain this address\n";
656-
if (TargetBF) {
657-
dbgs() << " ! function containing this address: "
658-
<< TargetBF->getPrintName() << '\n';
659-
if (TargetBF->isFragment()) {
660-
dbgs() << " ! is a fragment";
661-
for (BinaryFunction *Parent : TargetBF->ParentFragments)
662-
dbgs() << ", parent: " << Parent->getPrintName();
663-
dbgs() << '\n';
664-
}
665-
}
666-
}
667-
});
664+
if (!TargetBF || !areRelatedFragments(TargetBF, &BF)) {
665+
LLVM_DEBUG(printEntryDiagnostics(dbgs(), TargetBF));
666+
(void)printEntryDiagnostics;
668667
break;
669668
}
670669

@@ -703,10 +702,7 @@ void BinaryContext::populateJumpTables() {
703702
++JTI) {
704703
JumpTable *JT = JTI->second;
705704

706-
bool NonSimpleParent = false;
707-
for (BinaryFunction *BF : JT->Parents)
708-
NonSimpleParent |= !BF->isSimple();
709-
if (NonSimpleParent)
705+
if (!llvm::all_of(JT->Parents, std::mem_fn(&BinaryFunction::isSimple)))
710706
continue;
711707

712708
uint64_t NextJTAddress = 0;
@@ -840,33 +836,26 @@ BinaryContext::getOrCreateJumpTable(BinaryFunction &Function, uint64_t Address,
840836
assert(JT->Type == Type && "jump table types have to match");
841837
assert(Address == JT->getAddress() && "unexpected non-empty jump table");
842838

843-
// Prevent associating a jump table to a specific fragment twice.
844-
if (!llvm::is_contained(JT->Parents, &Function)) {
845-
assert(llvm::all_of(JT->Parents,
846-
[&](const BinaryFunction *BF) {
847-
return areRelatedFragments(&Function, BF);
848-
}) &&
849-
"cannot re-use jump table of a different function");
850-
// Duplicate the entry for the parent function for easy access
851-
JT->Parents.push_back(&Function);
852-
if (opts::Verbosity > 2) {
853-
this->outs() << "BOLT-INFO: Multiple fragments access same jump table: "
854-
<< JT->Parents[0]->getPrintName() << "; "
855-
<< Function.getPrintName() << "\n";
856-
JT->print(this->outs());
857-
}
858-
Function.JumpTables.emplace(Address, JT);
859-
for (BinaryFunction *Parent : JT->Parents)
860-
Parent->setHasIndirectTargetToSplitFragment(true);
861-
}
839+
if (llvm::is_contained(JT->Parents, &Function))
840+
return JT->getFirstLabel();
862841

863-
bool IsJumpTableParent = false;
864-
(void)IsJumpTableParent;
865-
for (BinaryFunction *Frag : JT->Parents)
866-
if (Frag == &Function)
867-
IsJumpTableParent = true;
868-
assert(IsJumpTableParent &&
842+
// Prevent associating a jump table to a specific fragment twice.
843+
auto isSibling = std::bind(&BinaryContext::areRelatedFragments, this,
844+
&Function, std::placeholders::_1);
845+
assert(llvm::all_of(JT->Parents, isSibling) &&
869846
"cannot re-use jump table of a different function");
847+
(void)isSibling;
848+
if (opts::Verbosity > 2) {
849+
this->outs() << "BOLT-INFO: multiple fragments access the same jump table"
850+
<< ": " << *JT->Parents[0] << "; " << Function << '\n';
851+
JT->print(this->outs());
852+
}
853+
if (JT->Parents.size() == 1)
854+
JT->Parents.front()->setHasIndirectTargetToSplitFragment(true);
855+
Function.setHasIndirectTargetToSplitFragment(true);
856+
// Duplicate the entry for the parent function for easy access
857+
JT->Parents.push_back(&Function);
858+
Function.JumpTables.emplace(Address, JT);
870859
return JT->getFirstLabel();
871860
}
872861

0 commit comments

Comments
 (0)