Skip to content

Commit 646aace

Browse files
committed
Merge remote-tracking branch 'upstream/main' into uefi_x86_64_backend_support
2 parents 07417dd + 3b19e78 commit 646aace

File tree

2,176 files changed

+101448
-44145
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,176 files changed

+101448
-44145
lines changed

.github/new-prs-labeler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,11 @@ backend:DirectX:
661661

662662
backend:SPIR-V:
663663
- clang/lib/Driver/ToolChains/SPIRV.*
664+
- clang/lib/Sema/SemaSPIRV.cpp
665+
- clang/include/clang/Sema/SemaSPIRV.h
666+
- clang/include/clang/Basic/BuiltinsSPIRV.td
667+
- clang/test/CodeGenSPIRV/**
668+
- clang/test/SemaSPIRV/**
664669
- llvm/lib/Target/SPIRV/**
665670
- llvm/test/CodeGen/SPIRV/**
666671
- llvm/test/Frontend/HLSL/**

.github/workflows/build-ci-container.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ jobs:
5959

6060
- name: Test Container
6161
run: |
62-
for image in ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}; do
63-
podman run --rm -it $image /usr/bin/bash -x -c 'cd $HOME && printf '\''#include <iostream>\nint main(int argc, char **argv) { std::cout << "Hello\\n"; }'\'' | clang++ -x c++ - && ./a.out | grep Hello'
62+
for image in ${{ steps.vars.outputs.container-name-tag }}; do
63+
# Use --pull=never to ensure we are testing the just built image.
64+
podman run --pull=never --rm -it $image /usr/bin/bash -x -c 'cd $HOME && printf '\''#include <iostream>\nint main(int argc, char **argv) { std::cout << "Hello\\n"; }'\'' | clang++ -x c++ - && ./a.out | grep Hello'
6465
done
6566
6667
push-ci-container:

.github/workflows/new-issues.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
steps:
1616
- uses: llvm/actions/issue-labeler@main
1717
with:
18-
repo-token: ${{ secrets.GITHUB_TOKEN }}
18+
repo-token: ${{ secrets.ISSUE_SUBSCRIBER_TOKEN }}
1919
configuration-path: .github/new-issues-labeler.yml
2020
include-title: 1
2121
include-body: 0

.github/workflows/release-binaries.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
8484
shell: bash
8585
run: |
86-
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user ${{ github.actor }} --user-token "$USER_TOKEN" check-permissions
86+
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --user "$GITHUB_ACTOR" --user-token "$USER_TOKEN" check-permissions
8787
8888
- name: Collect Variables
8989
id: vars
@@ -102,8 +102,8 @@ jobs:
102102
release_version="$trimmed"
103103
ref="llvmorg-$release_version"
104104
else
105-
release_version="${{ (github.event_name == 'pull_request' && format('PR{0}', github.event.pull_request.number)) || 'CI'}}-${{ github.sha }}"
106-
ref=${{ github.sha }}
105+
release_version="${{ (github.event_name == 'pull_request' && format('PR{0}', github.event.pull_request.number)) || 'CI'}}-$GITHUB_SHA"
106+
ref="$GITHUB_SHA"
107107
fi
108108
if [ -n "${{ inputs.upload }}" ]; then
109109
upload="${{ inputs.upload }}"
@@ -114,20 +114,20 @@ jobs:
114114
echo "ref=$ref" >> $GITHUB_OUTPUT
115115
echo "upload=$upload" >> $GITHUB_OUTPUT
116116
117-
release_binary_basename="LLVM-$release_version-${{ runner.os }}-${{ runner.arch }}"
117+
release_binary_basename="LLVM-$release_version-$RUNNER_OS-$RUNNER_ARCH"
118118
echo "release-binary-basename=$release_binary_basename" >> $GITHUB_OUTPUT
119119
echo "release-binary-filename=$release_binary_basename.tar.xz" >> $GITHUB_OUTPUT
120120
121121
# Detect necessary CMake flags
122-
target="${{ runner.os }}-${{ runner.arch }}"
122+
target="$RUNNER_OS-$RUNNER_ARCH"
123123
echo "enable-pgo=false" >> $GITHUB_OUTPUT
124124
target_cmake_flags="-DLLVM_RELEASE_ENABLE_PGO=OFF"
125125
# The macOS builds try to cross compile some libraries so we need to
126126
# add extra CMake args to disable them.
127127
# See https://github.com/llvm/llvm-project/issues/99767
128-
if [ "${{ runner.os }}" = "macOS" ]; then
128+
if [ "$RUNNER_OS" = "macOS" ]; then
129129
target_cmake_flags="$target_cmake_flags -DBOOTSTRAP_COMPILER_RT_ENABLE_IOS=OFF"
130-
if [ "${{ runner.arch }}" = "ARM64" ]; then
130+
if [ "$RUNNER_ARCH" = "ARM64" ]; then
131131
arches=arm64
132132
else
133133
arches=x86_64
@@ -137,7 +137,7 @@ jobs:
137137
138138
build_flang="true"
139139
140-
if [ "${{ runner.os }}" = "Windows" ]; then
140+
if [ "$RUNNER_OS" = "Windows" ]; then
141141
# The build times out on Windows, so we need to disable LTO.
142142
target_cmake_flags="$target_cmake_flags -DLLVM_RELEASE_ENABLE_LTO=OFF"
143143
fi

bolt/docs/CommandLineArgumentReference.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -931,15 +931,6 @@
931931

932932
Remove redundant Address-Size override prefix
933933

934-
### BOLT options in relocation mode:
935-
936-
- `--align-macro-fusion=<value>`
937-
938-
Fix instruction alignment for macro-fusion (x86 relocation mode)
939-
- `none`: do not insert alignment no-ops for macro-fusion
940-
- `hot`: only insert alignment no-ops on hot execution paths (default)
941-
- `all`: always align instructions to allow macro-fusion
942-
943934
### BOLT instrumentation options:
944935

945936
`llvm-bolt <executable> -instrument [-o outputfile] <instrumented-executable>`

bolt/include/bolt/Core/BinaryData.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ class BinaryData {
169169
return Parent && (Parent == BD || Parent->isAncestorOf(BD));
170170
}
171171

172+
void updateSize(uint64_t N) {
173+
if (N > Size)
174+
Size = N;
175+
}
176+
172177
void setIsMoveable(bool Flag) { IsMoveable = Flag; }
173178
void setSection(BinarySection &NewSection);
174179
void setOutputSection(BinarySection &NewSection) {

bolt/lib/Core/BinaryContext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,7 @@ MCSymbol *BinaryContext::registerNameAtAddress(StringRef Name, uint64_t Address,
10761076
BD = GAI->second;
10771077
if (!BD->hasName(Name)) {
10781078
GlobalSymbols[Name] = BD;
1079+
BD->updateSize(Size);
10791080
BD->Symbols.push_back(Symbol);
10801081
}
10811082
}

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ BreakFunctionNames("break-funcs",
4646
cl::Hidden,
4747
cl::cat(BoltCategory));
4848

49-
cl::list<std::string>
49+
static cl::list<std::string>
5050
FunctionPadSpec("pad-funcs", cl::CommaSeparated,
5151
cl::desc("list of functions to pad with amount of bytes"),
5252
cl::value_desc("func1:pad1,func2:pad2,func3:pad3,..."),
5353
cl::Hidden, cl::cat(BoltCategory));
5454

55-
cl::list<std::string> FunctionPadBeforeSpec(
55+
static cl::list<std::string> FunctionPadBeforeSpec(
5656
"pad-funcs-before", cl::CommaSeparated,
5757
cl::desc("list of functions to pad with amount of bytes"),
5858
cl::value_desc("func1:pad1,func2:pad2,func3:pad3,..."), cl::Hidden,
@@ -74,10 +74,9 @@ X86AlignBranchBoundaryHotOnly("x86-align-branch-boundary-hot-only",
7474
cl::init(true),
7575
cl::cat(BoltOptCategory));
7676

77-
size_t padFunction(const cl::list<std::string> &Spec,
77+
size_t padFunction(std::map<std::string, size_t> &FunctionPadding,
78+
const cl::list<std::string> &Spec,
7879
const BinaryFunction &Function) {
79-
static std::map<std::string, size_t> FunctionPadding;
80-
8180
if (FunctionPadding.empty() && !Spec.empty()) {
8281
for (const std::string &Spec : Spec) {
8382
size_t N = Spec.find(':');
@@ -99,6 +98,15 @@ size_t padFunction(const cl::list<std::string> &Spec,
9998
return 0;
10099
}
101100

101+
size_t padFunctionBefore(const BinaryFunction &Function) {
102+
static std::map<std::string, size_t> CacheFunctionPadding;
103+
return padFunction(CacheFunctionPadding, FunctionPadBeforeSpec, Function);
104+
}
105+
size_t padFunctionAfter(const BinaryFunction &Function) {
106+
static std::map<std::string, size_t> CacheFunctionPadding;
107+
return padFunction(CacheFunctionPadding, FunctionPadSpec, Function);
108+
}
109+
102110
} // namespace opts
103111

104112
namespace {
@@ -324,8 +332,7 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function,
324332
Streamer.emitCodeAlignment(Function.getAlign(), &*BC.STI);
325333
}
326334

327-
if (size_t Padding =
328-
opts::padFunction(opts::FunctionPadBeforeSpec, Function)) {
335+
if (size_t Padding = opts::padFunctionBefore(Function)) {
329336
// Handle padFuncsBefore after the above alignment logic but before
330337
// symbol addresses are decided.
331338
if (!BC.HasRelocations) {
@@ -404,7 +411,7 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function,
404411
emitFunctionBody(Function, FF, /*EmitCodeOnly=*/false);
405412

406413
// Emit padding if requested.
407-
if (size_t Padding = opts::padFunction(opts::FunctionPadSpec, Function)) {
414+
if (size_t Padding = opts::padFunctionAfter(Function)) {
408415
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: padding function " << Function << " with "
409416
<< Padding << " bytes\n");
410417
Streamer.emitFill(Padding, MAI->getTextAlignFillValue());

bolt/lib/Passes/ReorderFunctions.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ extern cl::OptionCategory BoltOptCategory;
2828
extern cl::opt<unsigned> Verbosity;
2929
extern cl::opt<uint32_t> RandomSeed;
3030

31-
extern size_t padFunction(const cl::list<std::string> &Spec,
32-
const bolt::BinaryFunction &Function);
33-
extern cl::list<std::string> FunctionPadSpec, FunctionPadBeforeSpec;
31+
extern size_t padFunctionBefore(const bolt::BinaryFunction &Function);
32+
extern size_t padFunctionAfter(const bolt::BinaryFunction &Function);
3433

3534
extern cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions;
3635
cl::opt<bolt::ReorderFunctions::ReorderType> ReorderFunctions(
@@ -306,12 +305,10 @@ Error ReorderFunctions::runOnFunctions(BinaryContext &BC) {
306305
return false;
307306
if (B->isIgnored())
308307
return true;
309-
const size_t PadA =
310-
opts::padFunction(opts::FunctionPadSpec, *A) +
311-
opts::padFunction(opts::FunctionPadBeforeSpec, *A);
312-
const size_t PadB =
313-
opts::padFunction(opts::FunctionPadSpec, *B) +
314-
opts::padFunction(opts::FunctionPadBeforeSpec, *B);
308+
const size_t PadA = opts::padFunctionBefore(*A) +
309+
opts::padFunctionAfter(*A);
310+
const size_t PadB = opts::padFunctionBefore(*B) +
311+
opts::padFunctionAfter(*B);
315312
if (!PadA || !PadB) {
316313
if (PadA)
317314
return true;

bolt/lib/Rewrite/LinuxKernelRewriter.cpp

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
#include "llvm/Support/CommandLine.h"
2222
#include "llvm/Support/Debug.h"
2323
#include "llvm/Support/Errc.h"
24+
#include "llvm/Support/ErrorOr.h"
25+
#include <regex>
2426

2527
#define DEBUG_TYPE "bolt-linux"
2628

@@ -89,6 +91,34 @@ static cl::opt<bool>
8991

9092
} // namespace opts
9193

94+
/// Linux kernel version
95+
struct LKVersion {
96+
LKVersion() {}
97+
LKVersion(unsigned Major, unsigned Minor, unsigned Rev)
98+
: Major(Major), Minor(Minor), Rev(Rev) {}
99+
100+
bool operator<(const LKVersion &Other) const {
101+
return std::make_tuple(Major, Minor, Rev) <
102+
std::make_tuple(Other.Major, Other.Minor, Other.Rev);
103+
}
104+
105+
bool operator>(const LKVersion &Other) const { return Other < *this; }
106+
107+
bool operator<=(const LKVersion &Other) const { return !(*this > Other); }
108+
109+
bool operator>=(const LKVersion &Other) const { return !(*this < Other); }
110+
111+
bool operator==(const LKVersion &Other) const {
112+
return Major == Other.Major && Minor == Other.Minor && Rev == Other.Rev;
113+
}
114+
115+
bool operator!=(const LKVersion &Other) const { return !(*this == Other); }
116+
117+
unsigned Major{0};
118+
unsigned Minor{0};
119+
unsigned Rev{0};
120+
};
121+
92122
/// Linux Kernel supports stack unwinding using ORC (oops rewind capability).
93123
/// ORC state at every IP can be described by the following data structure.
94124
struct ORCState {
@@ -148,6 +178,8 @@ class AddressExtractor : public DataExtractor {
148178
};
149179

150180
class LinuxKernelRewriter final : public MetadataRewriter {
181+
LKVersion LinuxKernelVersion;
182+
151183
/// Information required for updating metadata referencing an instruction.
152184
struct InstructionFixup {
153185
BinarySection &Section; // Section referencing the instruction.
@@ -249,6 +281,8 @@ class LinuxKernelRewriter final : public MetadataRewriter {
249281
ErrorOr<BinarySection &> PCIFixupSection = std::errc::bad_address;
250282
static constexpr size_t PCI_FIXUP_ENTRY_SIZE = 16;
251283

284+
Error detectLinuxKernelVersion();
285+
252286
/// Process linux kernel special sections and their relocations.
253287
void processLKSections();
254288

@@ -314,6 +348,9 @@ class LinuxKernelRewriter final : public MetadataRewriter {
314348
: MetadataRewriter("linux-kernel-rewriter", BC) {}
315349

316350
Error preCFGInitializer() override {
351+
if (Error E = detectLinuxKernelVersion())
352+
return E;
353+
317354
processLKSections();
318355

319356
if (Error E = processSMPLocks())
@@ -394,6 +431,28 @@ class LinuxKernelRewriter final : public MetadataRewriter {
394431
}
395432
};
396433

434+
Error LinuxKernelRewriter::detectLinuxKernelVersion() {
435+
if (BinaryData *BD = BC.getBinaryDataByName("linux_banner")) {
436+
const BinarySection &Section = BD->getSection();
437+
const std::string S =
438+
Section.getContents().substr(BD->getOffset(), BD->getSize()).str();
439+
440+
const std::regex Re(R"---(Linux version ((\d+)\.(\d+)(\.(\d+))?))---");
441+
std::smatch Match;
442+
if (std::regex_search(S, Match, Re)) {
443+
const unsigned Major = std::stoi(Match[2].str());
444+
const unsigned Minor = std::stoi(Match[3].str());
445+
const unsigned Rev = Match[5].matched ? std::stoi(Match[5].str()) : 0;
446+
LinuxKernelVersion = LKVersion(Major, Minor, Rev);
447+
BC.outs() << "BOLT-INFO: Linux kernel version is " << Match[1].str()
448+
<< "\n";
449+
return Error::success();
450+
}
451+
}
452+
return createStringError(errc::executable_format_error,
453+
"Linux kernel version is unknown");
454+
}
455+
397456
void LinuxKernelRewriter::processLKSections() {
398457
processLKKSymtab();
399458
processLKKSymtab(true);

0 commit comments

Comments
 (0)