Skip to content

Commit 409b18a

Browse files
authored
Merge branch 'llvm:main' into counted-by-on-struct-pointers
2 parents d753a69 + 9d5f163 commit 409b18a

File tree

1,671 files changed

+223845
-22120
lines changed

Some content is hidden

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

1,671 files changed

+223845
-22120
lines changed

.clang-format-ignore

Whitespace-only changes.

.github/workflows/libc-fullbuild-tests.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ jobs:
1919
include:
2020
- os: ubuntu-24.04
2121
ccache-variant: sccache
22-
c_compiler: clang
23-
cpp_compiler: clang++
22+
c_compiler: clang-20
23+
cpp_compiler: clang++-20
2424
# TODO: remove ccache logic when https://github.com/hendrikmuhs/ccache-action/issues/279 is resolved.
2525
- os: ubuntu-24.04-arm
2626
ccache-variant: ccache
27-
c_compiler: clang
28-
cpp_compiler: clang++
27+
c_compiler: clang-20
28+
cpp_compiler: clang++-20
2929
# TODO: add back gcc build when it is fixed
3030
# - c_compiler: gcc
3131
# cpp_compiler: g++
@@ -51,6 +51,9 @@ jobs:
5151
# For more information, see https://wiki.debian.org/Multiarch/LibraryPathOverview
5252
- name: Prepare dependencies (Ubuntu)
5353
run: |
54+
wget https://apt.llvm.org/llvm.sh
55+
chmod +x llvm.sh
56+
sudo ./llvm.sh 20
5457
sudo apt-get update
5558
sudo apt-get install -y libmpfr-dev libgmp-dev libmpc-dev ninja-build linux-libc-dev
5659
sudo ln -sf /usr/include/$(uname -p)-linux-gnu/asm /usr/include/asm

.github/workflows/premerge.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
- name: Upload Artifacts
7070
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
7171
with:
72-
name: Premerge Artifacts
72+
name: Premerge Artifacts (Linux)
7373
path: artifacts/
7474
retention-days: 5
7575
include-hidden-files: 'true'
@@ -124,7 +124,7 @@ jobs:
124124
- name: Upload Artifacts
125125
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
126126
with:
127-
name: Premerge Artifacts
127+
name: Premerge Artifacts (Windows)
128128
path: artifacts/
129129
retention-days: 5
130130
include-hidden-files: 'true'

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/BinaryFunction.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1896,6 +1896,15 @@ void BinaryFunction::postProcessEntryPoints() {
18961896
if (BC.isAArch64() && Offset == getSize())
18971897
continue;
18981898

1899+
// If we have grabbed a wrong code label which actually points to some
1900+
// constant island inside the function, ignore this label and remove it
1901+
// from the secondary entry point map.
1902+
if (isStartOfConstantIsland(Offset)) {
1903+
BC.SymbolToFunctionMap.erase(Label);
1904+
removeSymbolFromSecondaryEntryPointMap(Label);
1905+
continue;
1906+
}
1907+
18991908
BC.errs() << "BOLT-WARNING: reference in the middle of instruction "
19001909
"detected in function "
19011910
<< *this << " at offset 0x" << Twine::utohexstr(Offset) << '\n';

bolt/lib/Core/Relocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ static bool isSupportedRISCV(uint32_t Type) {
123123
case ELF::R_RISCV_LO12_S:
124124
case ELF::R_RISCV_64:
125125
case ELF::R_RISCV_TLS_GOT_HI20:
126+
case ELF::R_RISCV_TLS_GD_HI20:
126127
case ELF::R_RISCV_TPREL_HI20:
127128
case ELF::R_RISCV_TPREL_ADD:
128129
case ELF::R_RISCV_TPREL_LO12_I:
@@ -236,6 +237,7 @@ static size_t getSizeForTypeRISCV(uint32_t Type) {
236237
case ELF::R_RISCV_64:
237238
case ELF::R_RISCV_GOT_HI20:
238239
case ELF::R_RISCV_TLS_GOT_HI20:
240+
case ELF::R_RISCV_TLS_GD_HI20:
239241
// See extractValueRISCV for why this is necessary.
240242
return 8;
241243
}
@@ -491,6 +493,7 @@ static uint64_t extractValueRISCV(uint32_t Type, uint64_t Contents,
491493
return extractBImmRISCV(Contents);
492494
case ELF::R_RISCV_GOT_HI20:
493495
case ELF::R_RISCV_TLS_GOT_HI20:
496+
case ELF::R_RISCV_TLS_GD_HI20:
494497
// We need to know the exact address of the GOT entry so we extract the
495498
// value from both the AUIPC and L[D|W]. We cannot rely on the symbol in the
496499
// relocation for this since it simply refers to the object that is stored
@@ -707,6 +710,7 @@ static bool isPCRelativeRISCV(uint32_t Type) {
707710
case ELF::R_RISCV_RVC_BRANCH:
708711
case ELF::R_RISCV_32_PCREL:
709712
case ELF::R_RISCV_TLS_GOT_HI20:
713+
case ELF::R_RISCV_TLS_GD_HI20:
710714
return true;
711715
}
712716
}

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,9 @@ Error RewriteInstance::discoverStorage() {
597597

598598
// Hugify: Additional huge page from left side due to
599599
// weird ASLR mapping addresses (4KB aligned)
600-
if (opts::Hugify && !BC->HasFixedLoadAddress)
600+
if (opts::Hugify && !BC->HasFixedLoadAddress) {
601601
NextAvailableAddress += BC->PageAlign;
602+
}
602603

603604
if (!opts::UseGnuStack && !BC->IsLinuxKernel) {
604605
// This is where the black magic happens. Creating PHDR table in a segment
@@ -2925,12 +2926,12 @@ void RewriteInstance::handleRelocation(const SectionRef &RelocatedSection,
29252926

29262927
if (BinaryData *BD = BC->getBinaryDataContainingAddress(SymbolAddress)) {
29272928
// Note: this assertion is trying to check sanity of BinaryData objects
2928-
// but AArch64 has inferred and incomplete object locations coming from
2929-
// GOT/TLS or any other non-trivial relocation (that requires creation
2930-
// of sections and whose symbol address is not really what should be
2931-
// encoded in the instruction). So we essentially disabled this check
2929+
// but AArch64 and RISCV has inferred and incomplete object locations
2930+
// coming from GOT/TLS or any other non-trivial relocation (that requires
2931+
// creation of sections and whose symbol address is not really what should
2932+
// be encoded in the instruction). So we essentially disabled this check
29322933
// for AArch64 and live with bogus names for objects.
2933-
assert((IsAArch64 || IsSectionRelocation ||
2934+
assert((IsAArch64 || BC->isRISCV() || IsSectionRelocation ||
29342935
BD->nameStartsWith(SymbolName) ||
29352936
BD->nameStartsWith("PG" + SymbolName) ||
29362937
(BD->nameStartsWith("ANONYMOUS") &&
@@ -5885,17 +5886,28 @@ void RewriteInstance::rewriteFile() {
58855886

58865887
// Write all allocatable sections - reloc-mode text is written here as well
58875888
for (BinarySection &Section : BC->allocatableSections()) {
5888-
if (!Section.isFinalized() || !Section.getOutputData())
5889+
if (!Section.isFinalized() || !Section.getOutputData()) {
5890+
LLVM_DEBUG(if (opts::Verbosity > 1) {
5891+
dbgs() << "BOLT-INFO: new section is finalized or !getOutputData, skip "
5892+
<< Section.getName() << '\n';
5893+
});
58895894
continue;
5890-
if (Section.isLinkOnly())
5895+
}
5896+
if (Section.isLinkOnly()) {
5897+
LLVM_DEBUG(if (opts::Verbosity > 1) {
5898+
dbgs() << "BOLT-INFO: new section is link only, skip "
5899+
<< Section.getName() << '\n';
5900+
});
58915901
continue;
5902+
}
58925903

58935904
if (opts::Verbosity >= 1)
58945905
BC->outs() << "BOLT: writing new section " << Section.getName()
58955906
<< "\n data at 0x"
58965907
<< Twine::utohexstr(Section.getAllocAddress()) << "\n of size "
58975908
<< Section.getOutputSize() << "\n at offset "
5898-
<< Section.getOutputFileOffset() << '\n';
5909+
<< Section.getOutputFileOffset() << " with content size "
5910+
<< Section.getOutputContents().size() << '\n';
58995911
OS.seek(Section.getOutputFileOffset());
59005912
Section.write(OS);
59015913
}

0 commit comments

Comments
 (0)