Skip to content

Commit 8d1f307

Browse files
committed
Merge remote-tracking branch 'origin/main' into mlir-llvm-indirect-br
* origin/main: (199 commits) [NFC][AsmPrinter] Refactor AsmPrinter and AArch64AsmPrinter to prepare for jump table partitions on aarch64 (llvm#125993) [HEXAGON] Fix corner cases for hwloops pass (llvm#135439) [flang] Handle volatility in lowering and codegen (llvm#135311) [MLIR][Shape] Support >2 args in `shape.broadcast` folder (llvm#126808) [DirectX] Use scalar arguments for @llvm.dx.dot intrinsics (llvm#134570) Remove the redundant check for "WeakPtr" in isSmartPtrClass to fix the issue 135612. (llvm#135629) [BOLT] Support relative vtable (llvm#135449) [flang] Fix linking to libMLIR (llvm#135483) [AsmPrinter] Link .section_sizes to the correct section (llvm#135583) [ctxprof] Handle instrumenting functions with `musttail` calls (llvm#135121) [SystemZ] Consider VST/VL as SimpleBDXStore/Load (llvm#135623) [libc++][CI] Pin the XCode version. (llvm#135412) [lldb-dap] Fix win32 build. (llvm#135638) [Interp] Mark inline-virtual.cpp as unsupported with ASan (llvm#135402) [libc++] Removes the _LIBCPP_VERBOSE_ABORT_NOT_NOEXCEPT macro. (llvm#135494) [CVP] Add tests for ucmp/scmp with switch (NFC) [mlir][tosa] Align AbsOp example variable names (llvm#135268) [mlir][tosa] Align AddOp examples to spec (llvm#135266) [mlir][tosa] Align RFFT2d and FFT2d operator examples (llvm#135261) [flang][OpenMP][HLFIR] Support vector subscripted array sections for DEPEND (llvm#133892) ...
2 parents 9ccd96b + c766d0c commit 8d1f307

File tree

938 files changed

+34916
-27117
lines changed

Some content is hidden

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

938 files changed

+34916
-27117
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

.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
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
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/lib/Core/BinaryContext.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ bool BinaryContext::analyzeJumpTable(const uint64_t Address,
663663
const BinaryFunction *TargetBF = getBinaryFunctionContainingAddress(Value);
664664
if (!TargetBF || !areRelatedFragments(TargetBF, &BF)) {
665665
LLVM_DEBUG(printEntryDiagnostics(dbgs(), TargetBF));
666+
(void)printEntryDiagnostics;
666667
break;
667668
}
668669

@@ -843,6 +844,7 @@ BinaryContext::getOrCreateJumpTable(BinaryFunction &Function, uint64_t Address,
843844
&Function, std::placeholders::_1);
844845
assert(llvm::all_of(JT->Parents, isSibling) &&
845846
"cannot re-use jump table of a different function");
847+
(void)isSibling;
846848
if (opts::Verbosity > 2) {
847849
this->outs() << "BOLT-INFO: multiple fragments access the same jump table"
848850
<< ": " << *JT->Parents[0] << "; " << Function << '\n';

bolt/lib/Core/Relocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static bool isSupportedAArch64(uint32_t Type) {
9696
case ELF::R_AARCH64_MOVW_UABS_G2:
9797
case ELF::R_AARCH64_MOVW_UABS_G2_NC:
9898
case ELF::R_AARCH64_MOVW_UABS_G3:
99+
case ELF::R_AARCH64_PLT32:
99100
return true;
100101
}
101102
}
@@ -202,6 +203,7 @@ static size_t getSizeForTypeAArch64(uint32_t Type) {
202203
case ELF::R_AARCH64_MOVW_UABS_G2_NC:
203204
case ELF::R_AARCH64_MOVW_UABS_G3:
204205
case ELF::R_AARCH64_ABS32:
206+
case ELF::R_AARCH64_PLT32:
205207
return 4;
206208
case ELF::R_AARCH64_ABS64:
207209
case ELF::R_AARCH64_PREL64:
@@ -354,6 +356,7 @@ static uint64_t extractValueAArch64(uint32_t Type, uint64_t Contents,
354356
case ELF::R_AARCH64_PREL16:
355357
return static_cast<int64_t>(PC) + SignExtend64<16>(Contents & 0xffff);
356358
case ELF::R_AARCH64_PREL32:
359+
case ELF::R_AARCH64_PLT32:
357360
return static_cast<int64_t>(PC) + SignExtend64<32>(Contents & 0xffffffff);
358361
case ELF::R_AARCH64_PREL64:
359362
return static_cast<int64_t>(PC) + Contents;
@@ -676,6 +679,7 @@ static bool isPCRelativeAArch64(uint32_t Type) {
676679
case ELF::R_AARCH64_PREL16:
677680
case ELF::R_AARCH64_PREL32:
678681
case ELF::R_AARCH64_PREL64:
682+
case ELF::R_AARCH64_PLT32:
679683
return true;
680684
}
681685
}

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -871,18 +871,27 @@ DataAggregator::getFallthroughsInTrace(BinaryFunction &BF,
871871

872872
BinaryContext &BC = BF.getBinaryContext();
873873

874-
if (!BF.isSimple())
875-
return std::nullopt;
876-
877-
assert(BF.hasCFG() && "can only record traces in CFG state");
878-
879874
// Offsets of the trace within this function.
880875
const uint64_t From = FirstLBR.To - BF.getAddress();
881876
const uint64_t To = SecondLBR.From - BF.getAddress();
882877

883878
if (From > To)
884879
return std::nullopt;
885880

881+
// Accept fall-throughs inside pseudo functions (PLT/thunks).
882+
// This check has to be above BF.empty as pseudo functions would pass it:
883+
// pseudo => ignored => CFG not built => empty.
884+
// If we return nullopt, trace would be reported as mismatching disassembled
885+
// function contents which it is not. To avoid this, return an empty
886+
// fall-through list instead.
887+
if (BF.isPseudo())
888+
return Branches;
889+
890+
if (!BF.isSimple())
891+
return std::nullopt;
892+
893+
assert(BF.hasCFG() && "can only record traces in CFG state");
894+
886895
const BinaryBasicBlock *FromBB = BF.getBasicBlockContainingOffset(From);
887896
const BinaryBasicBlock *ToBB = BF.getBasicBlockContainingOffset(To);
888897

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,7 +2603,9 @@ void RewriteInstance::readRelocations(const SectionRef &Section) {
26032603
void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
26042604
const RelocationRef &Rel) {
26052605
const bool IsAArch64 = BC->isAArch64();
2606+
const bool IsX86 = BC->isX86();
26062607
const bool IsFromCode = RelocatedSection.isText();
2608+
const bool IsWritable = BinarySection(*BC, RelocatedSection).isWritable();
26072609

26082610
SmallString<16> TypeName;
26092611
Rel.getTypeName(TypeName);
@@ -2612,15 +2614,15 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
26122614
return;
26132615

26142616
// Adjust the relocation type as the linker might have skewed it.
2615-
if (BC->isX86() && (RType & ELF::R_X86_64_converted_reloc_bit)) {
2617+
if (IsX86 && (RType & ELF::R_X86_64_converted_reloc_bit)) {
26162618
if (opts::Verbosity >= 1)
26172619
dbgs() << "BOLT-WARNING: ignoring R_X86_64_converted_reloc_bit\n";
26182620
RType &= ~ELF::R_X86_64_converted_reloc_bit;
26192621
}
26202622

26212623
if (Relocation::isTLS(RType)) {
26222624
// No special handling required for TLS relocations on X86.
2623-
if (BC->isX86())
2625+
if (IsX86)
26242626
return;
26252627

26262628
// The non-got related TLS relocations on AArch64 and RISC-V also could be
@@ -2661,6 +2663,30 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
26612663
return;
26622664
}
26632665

2666+
if (!IsFromCode && !IsWritable && (IsX86 || IsAArch64) &&
2667+
Relocation::isPCRelative(RType)) {
2668+
BinaryData *BD = BC->getBinaryDataContainingAddress(Rel.getOffset());
2669+
if (BD && (BD->nameStartsWith("_ZTV") || // vtable
2670+
BD->nameStartsWith("_ZTCN"))) { // construction vtable
2671+
BinaryFunction *BF = BC->getBinaryFunctionContainingAddress(
2672+
SymbolAddress, /*CheckPastEnd*/ false, /*UseMaxSize*/ true);
2673+
if (!BF || BF->getAddress() != SymbolAddress) {
2674+
BC->errs()
2675+
<< "BOLT-ERROR: the virtual function table entry at offset 0x"
2676+
<< Twine::utohexstr(Rel.getOffset());
2677+
if (BF)
2678+
BC->errs() << " points to the middle of a function @ 0x"
2679+
<< Twine::utohexstr(BF->getAddress()) << "\n";
2680+
else
2681+
BC->errs() << " does not point to any function\n";
2682+
exit(1);
2683+
}
2684+
BC->addRelocation(Rel.getOffset(), BF->getSymbol(), RType, Addend,
2685+
ExtractedValue);
2686+
return;
2687+
}
2688+
}
2689+
26642690
const uint64_t Address = SymbolAddress + Addend;
26652691

26662692
LLVM_DEBUG({
@@ -2724,7 +2750,7 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
27242750
const bool IsToCode = ReferencedSection && ReferencedSection->isText();
27252751

27262752
// Special handling of PC-relative relocations.
2727-
if (BC->isX86() && Relocation::isPCRelative(RType)) {
2753+
if (IsX86 && Relocation::isPCRelative(RType)) {
27282754
if (!IsFromCode && IsToCode) {
27292755
// PC-relative relocations from data to code are tricky since the
27302756
// original information is typically lost after linking, even with

0 commit comments

Comments
 (0)