Skip to content

Commit aee3776

Browse files
committed
Merge remote-tracking branch 'origin/main' into sframe
2 parents fa55874 + 8fcbd06 commit aee3776

File tree

3,569 files changed

+90322
-52105
lines changed

Some content is hidden

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

3,569 files changed

+90322
-52105
lines changed

.ci/compute_projects_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
22
# See https://llvm.org/LICENSE.txt for license information.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4-
"""Does some stuff."""
4+
"""Tests for compute_projects.py"""
55

66
import unittest
77

.ci/metrics/metrics.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
"""Collects Github metrics and uploads them to Grafana.
5+
6+
This script contains machinery that will pull metrics periodically from Github
7+
about workflow runs. It will upload the collected metrics to the specified
8+
Grafana instance.
9+
"""
10+
111
import collections
212
import datetime
313
import github

.github/workflows/premerge.yaml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ jobs:
3434
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3535
with:
3636
fetch-depth: 2
37-
- name: Setup ccache
38-
uses: hendrikmuhs/ccache-action@a1209f81afb8c005c13b4296c32e363431bffea5 # v1.2.17
39-
with:
40-
variant: "sccache"
41-
max-size: "2000M"
4237
- name: Build and Test
4338
# Mark the job as a success even if the step fails so that people do
4439
# not get notified while the new premerge pipeline is in an
@@ -62,6 +57,13 @@ jobs:
6257
export CC=/opt/llvm/bin/clang
6358
export CXX=/opt/llvm/bin/clang++
6459
60+
# This environment variable is passes into the container through the
61+
# runner pod definition. This differs between our two clusters which
62+
# why we do not hardcode it.
63+
export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET
64+
export SCCACHE_GCS_RW_MODE=READ_WRITE
65+
sccache --start-server
66+
6567
./.ci/monolithic-linux.sh "${projects_to_build}" "${project_check_targets}" "${runtimes_to_build}" "${runtimes_check_targets}" "${runtimes_check_targets_needs_reconfig}" "${enable_cir}"
6668
- name: Upload Artifacts
6769
if: '!cancelled()'
@@ -86,11 +88,6 @@ jobs:
8688
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
8789
with:
8890
fetch-depth: 2
89-
- name: Setup ccache
90-
uses: hendrikmuhs/ccache-action@a1209f81afb8c005c13b4296c32e363431bffea5 # v1.2.17
91-
with:
92-
variant: "sccache"
93-
max-size: "2000M"
9491
- name: Compute Projects
9592
id: vars
9693
run: |
@@ -113,7 +110,7 @@ jobs:
113110
shell: cmd
114111
run: |
115112
call C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64
116-
bash .ci/monolithic-windows.sh "${{ steps.vars.outputs.windows-projects }}" "${{ steps.vars.outputs.windows-check-targets }}"
113+
bash -c "export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET; export SCCACHE_GCS_RW_MODE=READ_WRITE; sccache --start-server; .ci/monolithic-windows.sh \"${{ steps.vars.outputs.windows-projects }}\" \"${{ steps.vars.outputs.windows-check-targets }}\""
117114
- name: Upload Artifacts
118115
if: '!cancelled()'
119116
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0

bolt/utils/nfc-check-setup.py

Lines changed: 102 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import sys
88
import textwrap
99

10+
msg_prefix = "\n> NFC-Mode:"
11+
1012
def get_relevant_bolt_changes(dir: str) -> str:
1113
# Return a list of bolt source changes that are relevant to testing.
1214
all_changes = subprocess.run(
@@ -42,14 +44,32 @@ def get_git_ref_or_rev(dir: str) -> str:
4244
cmd_rev = "git rev-parse --short HEAD"
4345
return subprocess.check_output(shlex.split(cmd_rev), cwd=dir, text=True).strip()
4446

47+
def switch_back(
48+
switch_back: bool, stash: bool, source_dir: str, old_ref: str, new_ref: str
49+
):
50+
# Switch back to the current revision if needed and inform the user of where
51+
# the HEAD is. Must be called after checking out the previous commit on all
52+
# exit paths.
53+
if switch_back:
54+
print(f"{msg_prefix} Switching back to current revision..")
55+
if stash:
56+
subprocess.run(shlex.split("git stash pop"), cwd=source_dir)
57+
subprocess.run(shlex.split(f"git checkout {old_ref}"), cwd=source_dir)
58+
else:
59+
print(
60+
f"The repository {source_dir} has been switched from {old_ref} "
61+
f"to {new_ref}. Local changes were stashed. Switch back using\n\t"
62+
f"git checkout {old_ref}\n"
63+
)
4564

4665
def main():
4766
parser = argparse.ArgumentParser(
4867
description=textwrap.dedent(
4968
"""
50-
This script builds two versions of BOLT (with the current and
51-
previous revision) and sets up symlink for llvm-bolt-wrapper.
52-
Passes the options through to llvm-bolt-wrapper.
69+
This script builds two versions of BOLT:
70+
llvm-bolt.new, using the current revision, and llvm-bolt.old using
71+
the previous revision. These can be used to check whether the
72+
current revision changes BOLT's functional behavior.
5373
"""
5474
)
5575
)
@@ -59,6 +79,12 @@ def main():
5979
default=os.getcwd(),
6080
help="Path to BOLT build directory, default is current " "directory",
6181
)
82+
parser.add_argument(
83+
"--create-wrapper",
84+
default=False,
85+
action="store_true",
86+
help="Sets up llvm-bolt as a symlink to llvm-bolt-wrapper. Passes the options through to llvm-bolt-wrapper.",
87+
)
6288
parser.add_argument(
6389
"--check-bolt-sources",
6490
default=False,
@@ -76,28 +102,42 @@ def main():
76102
default="HEAD^",
77103
help="Revision to checkout to compare vs HEAD",
78104
)
105+
106+
# When creating a wrapper, pass any unknown arguments to it. Otherwise, die.
79107
args, wrapper_args = parser.parse_known_args()
80-
bolt_path = f"{args.build_dir}/bin/llvm-bolt"
108+
if not args.create_wrapper and len(wrapper_args) > 0:
109+
parser.parse_args()
81110

111+
# Find the repo directory.
82112
source_dir = None
83-
# find the repo directory
84-
with open(f"{args.build_dir}/CMakeCache.txt") as f:
85-
for line in f:
86-
m = re.match(r"LLVM_SOURCE_DIR:STATIC=(.*)", line)
87-
if m:
88-
source_dir = m.groups()[0]
89-
if not source_dir:
90-
sys.exit("Source directory is not found")
91-
92-
script_dir = os.path.dirname(os.path.abspath(__file__))
93-
wrapper_path = f"{script_dir}/llvm-bolt-wrapper.py"
94-
# build the current commit
113+
try:
114+
CMCacheFilename = f"{args.build_dir}/CMakeCache.txt"
115+
with open(CMCacheFilename) as f:
116+
for line in f:
117+
m = re.match(r"LLVM_SOURCE_DIR:STATIC=(.*)", line)
118+
if m:
119+
source_dir = m.groups()[0]
120+
if not source_dir:
121+
raise Exception(f"Source directory not found: '{CMCacheFilename}'")
122+
except Exception as e:
123+
sys.exit(e)
124+
125+
# Clean the previous llvm-bolt if it exists.
126+
bolt_path = f"{args.build_dir}/bin/llvm-bolt"
127+
if os.path.exists(bolt_path):
128+
os.remove(bolt_path)
129+
130+
# Build the current commit.
131+
print(f"{msg_prefix} Building current revision..")
95132
subprocess.run(
96133
shlex.split("cmake --build . --target llvm-bolt"), cwd=args.build_dir
97134
)
98-
# rename llvm-bolt
135+
136+
if not os.path.exists(bolt_path):
137+
sys.exit(f"Failed to build the current revision: '{bolt_path}'")
138+
139+
# Rename llvm-bolt and memorize the old hash for logging.
99140
os.replace(bolt_path, f"{bolt_path}.new")
100-
# memorize the old hash for logging
101141
old_ref = get_git_ref_or_rev(source_dir)
102142

103143
if args.check_bolt_sources:
@@ -110,7 +150,7 @@ def main():
110150
print(f"BOLT source changes were found:\n{file_changes}")
111151
open(marker, "a").close()
112152

113-
# determine whether a stash is needed
153+
# Determine whether a stash is needed.
114154
stash = subprocess.run(
115155
shlex.split("git status --porcelain"),
116156
cwd=source_dir,
@@ -119,42 +159,59 @@ def main():
119159
text=True,
120160
).stdout
121161
if stash:
122-
# save local changes before checkout
162+
# Save local changes before checkout.
123163
subprocess.run(shlex.split("git stash push -u"), cwd=source_dir)
124-
# check out the previous/cmp commit
164+
165+
# Check out the previous/cmp commit and get its commit hash for logging.
125166
subprocess.run(shlex.split(f"git checkout -f {args.cmp_rev}"), cwd=source_dir)
126-
# get the parent commit hash for logging
127167
new_ref = get_git_ref_or_rev(source_dir)
128-
# build the previous commit
168+
169+
# Build the previous commit.
170+
print(f"{msg_prefix} Building previous revision..")
129171
subprocess.run(
130172
shlex.split("cmake --build . --target llvm-bolt"), cwd=args.build_dir
131173
)
132-
# rename llvm-bolt
174+
175+
# Rename llvm-bolt.
176+
if not os.path.exists(bolt_path):
177+
print(f"Failed to build the previous revision: '{bolt_path}'")
178+
switch_back(args.switch_back, stash, source_dir, old_ref, new_ref)
179+
sys.exit(1)
133180
os.replace(bolt_path, f"{bolt_path}.old")
134-
# set up llvm-bolt-wrapper.ini
135-
ini = subprocess.check_output(
136-
shlex.split(f"{wrapper_path} {bolt_path}.old {bolt_path}.new") + wrapper_args,
137-
text=True,
181+
182+
# Symlink llvm-bolt-wrapper
183+
if args.create_wrapper:
184+
print(f"{msg_prefix} Creating llvm-bolt wrapper..")
185+
script_dir = os.path.dirname(os.path.abspath(__file__))
186+
wrapper_path = f"{script_dir}/llvm-bolt-wrapper.py"
187+
try:
188+
# Set up llvm-bolt-wrapper.ini
189+
ini = subprocess.check_output(
190+
shlex.split(f"{wrapper_path} {bolt_path}.old {bolt_path}.new")
191+
+ wrapper_args,
192+
text=True,
193+
)
194+
with open(f"{args.build_dir}/bin/llvm-bolt-wrapper.ini", "w") as f:
195+
f.write(ini)
196+
os.symlink(wrapper_path, bolt_path)
197+
except Exception as e:
198+
print("Failed to create a wrapper:\n" + str(e))
199+
switch_back(args.switch_back, stash, source_dir, old_ref, new_ref)
200+
sys.exit(1)
201+
202+
switch_back(args.switch_back, stash, source_dir, old_ref, new_ref)
203+
204+
print(
205+
f"{msg_prefix} Completed!\nBuild directory {args.build_dir} is ready for"
206+
" NFC-Mode comparison between the two revisions."
138207
)
139-
with open(f"{args.build_dir}/bin/llvm-bolt-wrapper.ini", "w") as f:
140-
f.write(ini)
141-
# symlink llvm-bolt-wrapper
142-
os.symlink(wrapper_path, bolt_path)
143-
if args.switch_back:
144-
if stash:
145-
subprocess.run(shlex.split("git stash pop"), cwd=source_dir)
146-
subprocess.run(shlex.split(f"git checkout {old_ref}"), cwd=source_dir)
147-
else:
208+
209+
if args.create_wrapper:
148210
print(
149-
f"The repository {source_dir} has been switched from {old_ref} "
150-
f"to {new_ref}. Local changes were stashed. Switch back using\n\t"
151-
f"git checkout {old_ref}\n"
211+
"Can run BOLT tests using:\n"
212+
"\tbin/llvm-lit -sv tools/bolt/test\nor\n"
213+
"\tbin/llvm-lit -sv tools/bolttests"
152214
)
153-
print(
154-
f"Build directory {args.build_dir} is ready to run BOLT tests, e.g.\n"
155-
"\tbin/llvm-lit -sv tools/bolt/test\nor\n"
156-
"\tbin/llvm-lit -sv tools/bolttests"
157-
)
158215

159216

160217
if __name__ == "__main__":

clang-tools-extra/clang-doc/BitcodeReader.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ static llvm::Error parseRecord(const Record &R, unsigned ID,
384384
return decodeRecord(R, I->Path, Blob);
385385
case REFERENCE_FIELD:
386386
return decodeRecord(R, F, Blob);
387+
case REFERENCE_FILE:
388+
return decodeRecord(R, I->DocumentationFileName, Blob);
387389
default:
388390
return llvm::createStringError(llvm::inconvertibleErrorCode(),
389391
"invalid field for Reference");

clang-tools-extra/clang-doc/BitcodeWriter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ static const llvm::IndexedMap<RecordIdDsc, RecordIdToIndexFunctor>
210210
{REFERENCE_TYPE, {"RefType", &genIntAbbrev}},
211211
{REFERENCE_PATH, {"Path", &genStringAbbrev}},
212212
{REFERENCE_FIELD, {"Field", &genIntAbbrev}},
213+
{REFERENCE_FILE, {"File", &genStringAbbrev}},
213214
{TEMPLATE_PARAM_CONTENTS, {"Contents", &genStringAbbrev}},
214215
{TEMPLATE_SPECIALIZATION_OF,
215216
{"SpecializationOf", &genSymbolIdAbbrev}},
@@ -286,7 +287,7 @@ static const std::vector<std::pair<BlockId, std::vector<RecordId>>>
286287
// Reference Block
287288
{BI_REFERENCE_BLOCK_ID,
288289
{REFERENCE_USR, REFERENCE_NAME, REFERENCE_QUAL_NAME, REFERENCE_TYPE,
289-
REFERENCE_PATH, REFERENCE_FIELD}},
290+
REFERENCE_PATH, REFERENCE_FIELD, REFERENCE_FILE}},
290291
// Template Blocks.
291292
{BI_TEMPLATE_BLOCK_ID, {}},
292293
{BI_TEMPLATE_PARAM_BLOCK_ID, {TEMPLATE_PARAM_CONTENTS}},
@@ -479,6 +480,7 @@ void ClangDocBitcodeWriter::emitBlock(const Reference &R, FieldId Field) {
479480
emitRecord((unsigned)R.RefType, REFERENCE_TYPE);
480481
emitRecord(R.Path, REFERENCE_PATH);
481482
emitRecord((unsigned)Field, REFERENCE_FIELD);
483+
emitRecord(R.DocumentationFileName, REFERENCE_FILE);
482484
}
483485

484486
void ClangDocBitcodeWriter::emitBlock(const FriendInfo &R) {

clang-tools-extra/clang-doc/BitcodeWriter.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ enum RecordId {
140140
REFERENCE_TYPE,
141141
REFERENCE_PATH,
142142
REFERENCE_FIELD,
143+
REFERENCE_FILE,
143144
TEMPLATE_PARAM_CONTENTS,
144145
TEMPLATE_SPECIALIZATION_OF,
145146
TYPEDEF_USR,

0 commit comments

Comments
 (0)