Skip to content

Commit 58eed9d

Browse files
committed
Merge from 'main' to 'sycl-web' (319 commits)
CONFLICT (content): Merge conflict in clang/tools/CMakeLists.txt
2 parents 05152a2 + 0a518db commit 58eed9d

File tree

1,108 files changed

+61300
-31339
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,108 files changed

+61300
-31339
lines changed

.ci/generate-buildkite-pipeline-premerge

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,7 @@ linux_projects=$(add-dependencies ${linux_projects_to_test} | sort | uniq)
233233

234234
windows_projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects}))
235235
windows_check_targets=$(check-targets ${windows_projects_to_test} | sort | uniq)
236-
# Temporary disable the windows job.
237-
# See https://discourse.llvm.org/t/rfc-future-of-windows-pre-commit-ci/76840
238-
#windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
239-
windows_projects=""
236+
windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
240237

241238
# Generate the appropriate pipeline
242239
if [[ "${linux_projects}" != "" ]]; then

.ci/monolithic-windows.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ targets="${2}"
3838

3939
echo "--- cmake"
4040
pip install -q -r ${MONOREPO_ROOT}/mlir/python/requirements.txt
41+
42+
# The CMAKE_*_LINKER_FLAGS to disable the manifest come from research
43+
# on fixing a build reliability issue on the build server, please
44+
# see https://github.com/llvm/llvm-project/pull/82393 and
45+
# https://discourse.llvm.org/t/rfc-future-of-windows-pre-commit-ci/76840/40
46+
# for further information.
4147
cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \
4248
-D LLVM_ENABLE_PROJECTS="${projects}" \
4349
-G Ninja \
@@ -49,7 +55,10 @@ cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \
4955
-D COMPILER_RT_BUILD_ORC=OFF \
5056
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
5157
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
52-
-D MLIR_ENABLE_BINDINGS_PYTHON=ON
58+
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
59+
-D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \
60+
-D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \
61+
-D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO"
5362

5463
echo "--- ninja"
5564
# Targets are not escaped as they are passed as separate arguments.

.github/new-prs-labeler.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,30 @@ backend:X86:
822822
- llvm/lib/TargetParser/X86*
823823
- llvm/utils/TableGen/X86*
824824

825+
backend:PowerPC:
826+
- llvm/include/llvm/BinaryFormat/ELFRelocs/PowerPC*
827+
- llvm/include/llvm/BinaryFormat/XCOFF.h
828+
- llvm/include/llvm/IR/IntrinsicsPowerPC.td
829+
- llvm/lib/CodeGen/AsmPrinter/AIXException.cpp
830+
- llvm/lib/Target/PowerPC/**
831+
- llvm/test/Analysis/**/PowerPC/**
832+
- llvm/test/CodeGen/PowerPC/**
833+
- llvm/test/CodeGen/MIR/PowerPC/**
834+
- llvm/test/DebugInfo/XCOFF/**
835+
- llvm/test/DebugInfo/PowerPC/**
836+
- llvm/test/LTO/PowerPC/**
837+
- llvm/test/MC/Disassembler/PowerPC/**
838+
- llvm/test/MC/PowerPC/**
839+
- llvm/test/MC/XCOFF/**
840+
- llvm/test/Transforms/**/PowerPC/**
841+
- clang/include/clang/Basic/BuiltinsPPC.*
842+
- clang/lib/Basic/Targets/PPC.*
843+
- clang/lib/CodeGen/Targets/PPC.cpp
844+
- clang/lib/Driver/ToolChains/PPC*
845+
- clang/lib/Driver/ToolChains/AIX*
846+
- clang/lib/Driver/ToolChains/Arch/PPC.*
847+
- clang/test/CodeGen/PowerPC/**
848+
825849
third-party:unittests:
826850
- third-party/unittests/**
827851

.github/workflows/release-tasks.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
name: Create a New Release
2929
runs-on: ubuntu-latest
3030
needs: validate-tag
31+
3132
steps:
3233
- name: Install Dependencies
3334
run: |
@@ -40,8 +41,9 @@ jobs:
4041
- name: Create Release
4142
env:
4243
GITHUB_TOKEN: ${{ github.token }}
44+
USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
4345
run: |
44-
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --release ${{ needs.validate-tag.outputs.release-version }} --user ${{ github.actor }} create
46+
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --release ${{ needs.validate-tag.outputs.release-version }} --user ${{ github.actor }} --user-token "$USER_TOKEN" create
4547
release-documentation:
4648
name: Build and Upload Release Documentation
4749
needs:

bolt/lib/Rewrite/LinuxKernelRewriter.cpp

Lines changed: 175 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ static cl::opt<bool>
3535
DumpORC("dump-orc", cl::desc("dump raw ORC unwind information (sorted)"),
3636
cl::init(false), cl::Hidden, cl::cat(BoltCategory));
3737

38+
static cl::opt<bool> DumpStaticCalls("dump-static-calls",
39+
cl::desc("dump Linux kernel static calls"),
40+
cl::init(false), cl::Hidden,
41+
cl::cat(BoltCategory));
42+
3843
} // namespace opts
3944

4045
/// Linux Kernel supports stack unwinding using ORC (oops rewind capability).
@@ -116,6 +121,19 @@ class LinuxKernelRewriter final : public MetadataRewriter {
116121
/// Number of entries in the input file ORC sections.
117122
uint64_t NumORCEntries = 0;
118123

124+
/// Section containing static call table.
125+
ErrorOr<BinarySection &> StaticCallSection = std::errc::bad_address;
126+
uint64_t StaticCallTableAddress = 0;
127+
static constexpr size_t STATIC_CALL_ENTRY_SIZE = 8;
128+
129+
struct StaticCallInfo {
130+
uint32_t ID; /// Identifier of the entry in the table.
131+
BinaryFunction *Function; /// Function containing associated call.
132+
MCSymbol *Label; /// Label attached to the call.
133+
};
134+
using StaticCallListType = std::vector<StaticCallInfo>;
135+
StaticCallListType StaticCallEntries;
136+
119137
/// Insert an LKMarker for a given code pointer \p PC from a non-code section
120138
/// \p SectionName.
121139
void insertLKMarker(uint64_t PC, uint64_t SectionOffset,
@@ -152,6 +170,10 @@ class LinuxKernelRewriter final : public MetadataRewriter {
152170
/// Update ORC data in the binary.
153171
Error rewriteORCTables();
154172

173+
/// Static call table handling.
174+
Error readStaticCalls();
175+
Error rewriteStaticCalls();
176+
155177
/// Mark instructions referenced by kernel metadata.
156178
Error markInstructions();
157179

@@ -167,6 +189,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
167189
if (Error E = readORCTables())
168190
return E;
169191

192+
if (Error E = readStaticCalls())
193+
return E;
194+
170195
return Error::success();
171196
}
172197

@@ -181,6 +206,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
181206
if (Error E = rewriteORCTables())
182207
return E;
183208

209+
if (Error E = rewriteStaticCalls())
210+
return E;
211+
184212
return Error::success();
185213
}
186214

@@ -456,11 +484,11 @@ void LinuxKernelRewriter::updateLKMarkers() {
456484
LKPatcher->addLE64Patch(LKMarkerInfo.SectionOffset, NewAddress);
457485
}
458486
}
459-
outs() << "BOLT-INFO: patching linux kernel sections. Total patches per "
460-
"section are as follows:\n";
487+
BC.outs() << "BOLT-INFO: patching linux kernel sections. Total patches per "
488+
"section are as follows:\n";
461489
for (const std::pair<const std::string, uint64_t> &KV : PatchCounts)
462-
outs() << " Section: " << KV.first << ", patch-counts: " << KV.second
463-
<< '\n';
490+
BC.outs() << " Section: " << KV.first << ", patch-counts: " << KV.second
491+
<< '\n';
464492
}
465493

466494
Error LinuxKernelRewriter::readORCTables() {
@@ -502,8 +530,8 @@ Error LinuxKernelRewriter::readORCTables() {
502530
"out of bounds while reading ORC IP table");
503531

504532
if (IP < PrevIP && opts::Verbosity)
505-
errs() << "BOLT-WARNING: out of order IP 0x" << Twine::utohexstr(IP)
506-
<< " detected while reading ORC\n";
533+
BC.errs() << "BOLT-WARNING: out of order IP 0x" << Twine::utohexstr(IP)
534+
<< " detected while reading ORC\n";
507535

508536
PrevIP = IP;
509537

@@ -536,8 +564,8 @@ Error LinuxKernelRewriter::readORCTables() {
536564

537565
if (!BF) {
538566
if (opts::Verbosity)
539-
errs() << "BOLT-WARNING: no binary function found matching ORC 0x"
540-
<< Twine::utohexstr(IP) << ": " << Entry.ORC << '\n';
567+
BC.errs() << "BOLT-WARNING: no binary function found matching ORC 0x"
568+
<< Twine::utohexstr(IP) << ": " << Entry.ORC << '\n';
541569
continue;
542570
}
543571

@@ -563,15 +591,15 @@ Error LinuxKernelRewriter::readORCTables() {
563591
BC.MIB->addAnnotation(*Inst, "ORC", Entry.ORC);
564592
}
565593

566-
outs() << "BOLT-INFO: parsed " << NumORCEntries << " ORC entries\n";
594+
BC.outs() << "BOLT-INFO: parsed " << NumORCEntries << " ORC entries\n";
567595

568596
if (opts::DumpORC) {
569-
outs() << "BOLT-INFO: ORC unwind information:\n";
597+
BC.outs() << "BOLT-INFO: ORC unwind information:\n";
570598
for (const ORCListEntry &E : ORCEntries) {
571-
outs() << "0x" << Twine::utohexstr(E.IP) << ": " << E.ORC;
599+
BC.outs() << "0x" << Twine::utohexstr(E.IP) << ": " << E.ORC;
572600
if (E.BF)
573-
outs() << ": " << *E.BF;
574-
outs() << '\n';
601+
BC.outs() << ": " << *E.BF;
602+
BC.outs() << '\n';
575603
}
576604
}
577605

@@ -604,12 +632,12 @@ Error LinuxKernelRewriter::readORCTables() {
604632
llvm::sort(ORCEntries);
605633

606634
if (opts::DumpORC) {
607-
outs() << "BOLT-INFO: amended ORC unwind information:\n";
635+
BC.outs() << "BOLT-INFO: amended ORC unwind information:\n";
608636
for (const ORCListEntry &E : ORCEntries) {
609-
outs() << "0x" << Twine::utohexstr(E.IP) << ": " << E.ORC;
637+
BC.outs() << "0x" << Twine::utohexstr(E.IP) << ": " << E.ORC;
610638
if (E.BF)
611-
outs() << ": " << *E.BF;
612-
outs() << '\n';
639+
BC.outs() << ": " << *E.BF;
640+
BC.outs() << '\n';
613641
}
614642
}
615643

@@ -656,8 +684,8 @@ Error LinuxKernelRewriter::processORCPostCFG() {
656684
"ORC info at function entry expected.");
657685

658686
if (It->ORC == NullORC && BF.hasORC()) {
659-
errs() << "BOLT-WARNING: ORC unwind info excludes prologue for "
660-
<< BF << '\n';
687+
BC.errs() << "BOLT-WARNING: ORC unwind info excludes prologue for "
688+
<< BF << '\n';
661689
}
662690

663691
It->BF = &BF;
@@ -793,6 +821,134 @@ Error LinuxKernelRewriter::rewriteORCTables() {
793821
return Error::success();
794822
}
795823

824+
/// The static call site table is created by objtool and contains entries in the
825+
/// following format:
826+
///
827+
/// struct static_call_site {
828+
/// s32 addr;
829+
/// s32 key;
830+
/// };
831+
///
832+
Error LinuxKernelRewriter::readStaticCalls() {
833+
const BinaryData *StaticCallTable =
834+
BC.getBinaryDataByName("__start_static_call_sites");
835+
if (!StaticCallTable)
836+
return Error::success();
837+
838+
StaticCallTableAddress = StaticCallTable->getAddress();
839+
840+
const BinaryData *Stop = BC.getBinaryDataByName("__stop_static_call_sites");
841+
if (!Stop)
842+
return createStringError(errc::executable_format_error,
843+
"missing __stop_static_call_sites symbol");
844+
845+
ErrorOr<BinarySection &> ErrorOrSection =
846+
BC.getSectionForAddress(StaticCallTableAddress);
847+
if (!ErrorOrSection)
848+
return createStringError(errc::executable_format_error,
849+
"no section matching __start_static_call_sites");
850+
851+
StaticCallSection = *ErrorOrSection;
852+
if (!StaticCallSection->containsAddress(Stop->getAddress() - 1))
853+
return createStringError(errc::executable_format_error,
854+
"__stop_static_call_sites not in the same section "
855+
"as __start_static_call_sites");
856+
857+
if ((Stop->getAddress() - StaticCallTableAddress) % STATIC_CALL_ENTRY_SIZE)
858+
return createStringError(errc::executable_format_error,
859+
"static call table size error");
860+
861+
const uint64_t SectionAddress = StaticCallSection->getAddress();
862+
DataExtractor DE(StaticCallSection->getContents(),
863+
BC.AsmInfo->isLittleEndian(),
864+
BC.AsmInfo->getCodePointerSize());
865+
DataExtractor::Cursor Cursor(StaticCallTableAddress - SectionAddress);
866+
uint32_t EntryID = 0;
867+
while (Cursor && Cursor.tell() < Stop->getAddress() - SectionAddress) {
868+
const uint64_t CallAddress =
869+
SectionAddress + Cursor.tell() + (int32_t)DE.getU32(Cursor);
870+
const uint64_t KeyAddress =
871+
SectionAddress + Cursor.tell() + (int32_t)DE.getU32(Cursor);
872+
873+
// Consume the status of the cursor.
874+
if (!Cursor)
875+
return createStringError(errc::executable_format_error,
876+
"out of bounds while reading static calls");
877+
878+
++EntryID;
879+
880+
if (opts::DumpStaticCalls) {
881+
BC.outs() << "Static Call Site: " << EntryID << '\n';
882+
BC.outs() << "\tCallAddress: 0x" << Twine::utohexstr(CallAddress)
883+
<< "\n\tKeyAddress: 0x" << Twine::utohexstr(KeyAddress)
884+
<< '\n';
885+
}
886+
887+
BinaryFunction *BF = BC.getBinaryFunctionContainingAddress(CallAddress);
888+
if (!BF)
889+
continue;
890+
891+
if (!BC.shouldEmit(*BF))
892+
continue;
893+
894+
if (!BF->hasInstructions())
895+
continue;
896+
897+
MCInst *Inst = BF->getInstructionAtOffset(CallAddress - BF->getAddress());
898+
if (!Inst)
899+
return createStringError(errc::executable_format_error,
900+
"no instruction at call site address 0x%" PRIx64,
901+
CallAddress);
902+
903+
// Check for duplicate entries.
904+
if (BC.MIB->hasAnnotation(*Inst, "StaticCall"))
905+
return createStringError(errc::executable_format_error,
906+
"duplicate static call site at 0x%" PRIx64,
907+
CallAddress);
908+
909+
BC.MIB->addAnnotation(*Inst, "StaticCall", EntryID);
910+
911+
MCSymbol *Label = BC.MIB->getLabel(*Inst);
912+
if (!Label) {
913+
Label = BC.Ctx->createTempSymbol("__SC_");
914+
BC.MIB->setLabel(*Inst, Label);
915+
}
916+
917+
StaticCallEntries.push_back({EntryID, BF, Label});
918+
}
919+
920+
BC.outs() << "BOLT-INFO: parsed " << StaticCallEntries.size()
921+
<< " static call entries\n";
922+
923+
return Error::success();
924+
}
925+
926+
/// The static call table is sorted during boot time in
927+
/// static_call_sort_entries(). This makes it possible to update existing
928+
/// entries in-place ignoring their relative order.
929+
Error LinuxKernelRewriter::rewriteStaticCalls() {
930+
if (!StaticCallTableAddress || !StaticCallSection)
931+
return Error::success();
932+
933+
for (auto &Entry : StaticCallEntries) {
934+
if (!Entry.Function)
935+
continue;
936+
937+
BinaryFunction &BF = *Entry.Function;
938+
if (!BC.shouldEmit(BF))
939+
continue;
940+
941+
// Create a relocation against the label.
942+
const uint64_t EntryOffset = StaticCallTableAddress -
943+
StaticCallSection->getAddress() +
944+
(Entry.ID - 1) * STATIC_CALL_ENTRY_SIZE;
945+
StaticCallSection->addRelocation(EntryOffset, Entry.Label,
946+
ELF::R_X86_64_PC32, /*Addend*/ 0);
947+
}
948+
949+
return Error::success();
950+
}
951+
796952
} // namespace
797953

798954
std::unique_ptr<MetadataRewriter>

0 commit comments

Comments
 (0)