Skip to content

Commit 320164a

Browse files
committed
Merge remote-tracking branch 'origin/main' into vplan-caniv-defined-by-region-dont-reset-start-value
Conflicts: llvm/lib/Transforms/Vectorize/VPlan.cpp
2 parents 102396a + 0767c64 commit 320164a

File tree

532 files changed

+22863
-20147
lines changed

Some content is hidden

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

532 files changed

+22863
-20147
lines changed

.ci/all_requirements.txt

Lines changed: 192 additions & 2 deletions
Large diffs are not rendered by default.

.ci/premerge_advisor_explain.py

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,90 @@
44
"""Script for getting explanations from the premerge advisor."""
55

66
import argparse
7-
import os
87
import platform
98
import sys
9+
import json
10+
11+
# TODO(boomanaiden154): Remove the optional call once we can require Python
12+
# 3.10.
13+
from typing import Optional
1014

1115
import requests
16+
import github
17+
import github.PullRequest
1218

1319
import generate_test_report_lib
1420

1521
PREMERGE_ADVISOR_URL = (
1622
"http://premerge-advisor.premerge-advisor.svc.cluster.local:5000/explain"
1723
)
24+
COMMENT_TAG = "<!--PREMERGE ADVISOR COMMENT: {platform}-->"
25+
26+
27+
def get_comment_id(platform: str, pr: github.PullRequest.PullRequest) -> Optional[int]:
28+
platform_comment_tag = COMMENT_TAG.format(platform=platform)
29+
for comment in pr.as_issue().get_comments():
30+
if platform_comment_tag in comment.body:
31+
return comment.id
32+
return None
33+
34+
35+
def get_comment(
36+
github_token: str,
37+
pr_number: int,
38+
body: str,
39+
) -> dict[str, str]:
40+
repo = github.Github(github_token).get_repo("llvm/llvm-project")
41+
pr = repo.get_issue(pr_number).as_pull_request()
42+
comment = {"body": body}
43+
comment_id = get_comment_id(platform.system(), pr)
44+
if comment_id:
45+
comment["id"] = comment_id
46+
return comment
1847

1948

20-
def main(commit_sha: str, build_log_files: list[str]):
49+
def main(
50+
commit_sha: str,
51+
build_log_files: list[str],
52+
github_token: str,
53+
pr_number: int,
54+
return_code: int,
55+
):
56+
"""The main entrypoint for the script.
57+
58+
This function parses failures from files, requests information from the
59+
premerge advisor, and may write a Github comment depending upon the output.
60+
There are four different scenarios:
61+
1. There has never been a previous failure and the job passes - We do not
62+
create a comment. We write out an empty file to the comment path so the
63+
issue-write workflow knows not to create anything.
64+
2. There has never been a previous failure and the job fails - We create a
65+
new comment containing the failure information and any possible premerge
66+
advisor findings.
67+
3. There has been a previous failure and the job passes - We update the
68+
existing comment by passing its ID and a passed message to the
69+
issue-write workflow.
70+
4. There has been a previous failure and the job fails - We update the
71+
existing comment in the same manner as above, but generate the comment
72+
as if we have a failure.
73+
74+
Args:
75+
commit_sha: The base commit SHA for this PR run.
76+
build_log_files: The list of JUnit XML files and ninja logs.
77+
github_token: The token to use to access the Github API.
78+
pr_number: The number of the PR associated with this run.
79+
return_code: The numerical return code of ninja/CMake.
80+
"""
81+
if return_code == 0:
82+
with open("comment", "w") as comment_file_handle:
83+
comment = get_comment(
84+
github_token,
85+
pr_number,
86+
":white_check_mark: With the latest revision this PR passed "
87+
"the premerge checks.",
88+
)
89+
if "id" in comment:
90+
json.dump([comment], comment_file_handle)
2191
junit_objects, ninja_logs = generate_test_report_lib.load_info_from_files(
2292
build_log_files
2393
)
@@ -45,13 +115,31 @@ def main(commit_sha: str, build_log_files: list[str]):
45115
)
46116
if advisor_response.status_code == 200:
47117
print(advisor_response.json())
118+
comments = [
119+
get_comment(
120+
github_token,
121+
pr_number,
122+
generate_test_report_lib.generate_report(
123+
generate_test_report_lib.compute_platform_title(),
124+
return_code,
125+
junit_objects,
126+
ninja_logs,
127+
failure_explanations_list=advisor_response.json(),
128+
),
129+
)
130+
]
131+
with open("comment", "w") as comment_file_handle:
132+
json.dump(comments, comment_file_handle)
48133
else:
49134
print(advisor_response.reason)
50135

51136

52137
if __name__ == "__main__":
53138
parser = argparse.ArgumentParser()
54139
parser.add_argument("commit_sha", help="The base commit SHA for the test.")
140+
parser.add_argument("return_code", help="The build's return code", type=int)
141+
parser.add_argument("github_token", help="Github authentication token", type=str)
142+
parser.add_argument("pr_number", help="The PR number", type=int)
55143
parser.add_argument(
56144
"build_log_files", help="Paths to JUnit report files and ninja logs.", nargs="*"
57145
)
@@ -62,4 +150,10 @@ def main(commit_sha: str, build_log_files: list[str]):
62150
if platform.machine() == "arm64":
63151
sys.exit(0)
64152

65-
main(args.commit_sha, args.build_log_files)
153+
main(
154+
args.commit_sha,
155+
args.build_log_files,
156+
args.github_token,
157+
args.pr_number,
158+
args.return_code,
159+
)

.ci/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
junitparser==3.2.0
22
google-cloud-storage==3.3.0
3+
PyGithub==2.8.1

.ci/utils.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,18 @@ function at-exit {
3333
# If building fails there will be no results files.
3434
shopt -s nullglob
3535

36-
if [[ "$GITHUB_STEP_SUMMARY" != "" ]]; then
36+
if [[ "$GITHUB_ACTIONS" != "" ]]; then
3737
python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py \
3838
$retcode "${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log \
3939
>> $GITHUB_STEP_SUMMARY
40+
python "${MONOREPO_ROOT}"/.ci/premerge_advisor_explain.py \
41+
$(git rev-parse HEAD~1) $retcode "${GITHUB_TOKEN}" \
42+
$GITHUB_PR_NUMBER "${BUILD_DIR}"/test-results.*.xml \
43+
"${MONOREPO_ROOT}"/ninja*.log
4044
fi
4145

4246
if [[ "$retcode" != "0" ]]; then
4347
if [[ "$GITHUB_ACTIONS" != "" ]]; then
44-
python "${MONOREPO_ROOT}"/.ci/premerge_advisor_explain.py \
45-
$(git rev-parse HEAD~1) "${BUILD_DIR}"/test-results.*.xml \
46-
"${MONOREPO_ROOT}"/ninja*.log
4748
python "${MONOREPO_ROOT}"/.ci/premerge_advisor_upload.py \
4849
$(git rev-parse HEAD~1) $GITHUB_RUN_NUMBER \
4950
"${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ jobs:
3636
test-command: 'cd $HOME && clang-format --version | grep version && git-clang-format -h | grep usage && black --version | grep black'
3737
- container-name: lint
3838
test-command: 'cd $HOME && clang-tidy --version | grep version && clang-tidy-diff.py -h | grep usage'
39+
- container-name: abi-tests
40+
test-command: 'cd $HOME && abi-compliance-checker --help'
41+
target: abi-tests
3942
steps:
4043
- name: Checkout LLVM
4144
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -52,7 +55,7 @@ jobs:
5255
with:
5356
container-name: ci-ubuntu-24.04-${{ matrix.container-name }}
5457
dockerfile: .github/workflows/containers/github-action-ci-tooling/Dockerfile
55-
target: ci-container-code-${{ matrix.container-name }}
58+
target: ci-container-${{ matrix.target || format('code-{0}', matrix.container-name) }}
5659
test-command: ${{ matrix.test-command }}
5760

5861
push-ci-container:

.github/workflows/containers/github-action-ci-tooling/Dockerfile

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,28 @@ RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
4747
# as root in 'ci-container-code-format' and 'ci-container-code-lint' containers
4848

4949

50+
FROM base AS ci-container-build-tools
51+
ARG LLVM_VERSION
52+
ARG LLVM_VERSION_MAJOR
53+
54+
COPY --from=llvm-downloader /llvm-extract/LLVM-${LLVM_VERSION}-Linux-X64/bin/clang-${LLVM_VERSION_MAJOR} \
55+
${LLVM_SYSROOT}/bin/
56+
COPY --from=llvm-downloader /llvm-extract/LLVM-${LLVM_VERSION}-Linux-X64/lib/clang/${LLVM_VERSION_MAJOR}/include \
57+
${LLVM_SYSROOT}/lib/clang/${LLVM_VERSION_MAJOR}/include
58+
RUN ln -s ${LLVM_SYSROOT}/bin/clang-${LLVM_VERSION_MAJOR} ${LLVM_SYSROOT}/bin/clang && \
59+
ln -s ${LLVM_SYSROOT}/bin/clang ${LLVM_SYSROOT}/bin/clang++
60+
61+
RUN apt-get update && \
62+
DEBIAN_FRONTEND=noninteractive apt-get install -y \
63+
cmake \
64+
ninja-build && \
65+
apt-get clean && \
66+
rm -rf /var/lib/apt/lists/*
67+
68+
ENV CC=${LLVM_SYSROOT}/bin/clang
69+
ENV CXX=${LLVM_SYSROOT}/bin/clang++
70+
71+
5072
FROM base AS ci-container-code-format
5173
ARG LLVM_VERSION
5274

@@ -63,31 +85,37 @@ USER gha
6385
WORKDIR /home/gha
6486

6587

66-
FROM base AS ci-container-code-lint
88+
FROM ci-container-build-tools AS ci-container-code-lint
6789
ARG LLVM_VERSION
6890
ARG LLVM_VERSION_MAJOR
6991

7092
COPY --from=llvm-downloader /llvm-extract/LLVM-${LLVM_VERSION}-Linux-X64/bin/clang-tidy \
71-
/llvm-extract/LLVM-${LLVM_VERSION}-Linux-X64/bin/clang-${LLVM_VERSION_MAJOR} \
7293
${LLVM_SYSROOT}/bin/
73-
COPY --from=llvm-downloader /llvm-extract/LLVM-${LLVM_VERSION}-Linux-X64/lib/clang/${LLVM_VERSION_MAJOR}/include \
74-
${LLVM_SYSROOT}/lib/clang/${LLVM_VERSION_MAJOR}/include
7594
COPY clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py ${LLVM_SYSROOT}/bin/clang-tidy-diff.py
7695

77-
RUN ln -s ${LLVM_SYSROOT}/bin/clang-${LLVM_VERSION_MAJOR} ${LLVM_SYSROOT}/bin/clang && \
78-
ln -s ${LLVM_SYSROOT}/bin/clang ${LLVM_SYSROOT}/bin/clang++
96+
# Install dependencies for 'pr-code-lint.yml' job
97+
COPY llvm/utils/git/requirements_linting.txt requirements_linting.txt
98+
RUN pip install -r requirements_linting.txt --break-system-packages && \
99+
rm requirements_linting.txt
100+
USER gha
101+
WORKDIR /home/gha
102+
79103

104+
FROM ci-container-build-tools as ci-container-abi-tests
80105

81106
RUN apt-get update && \
82107
DEBIAN_FRONTEND=noninteractive apt-get install -y \
83-
cmake \
84-
ninja-build && \
108+
abi-compliance-checker \
109+
abi-dumper \
110+
autoconf \
111+
pkg-config && \
85112
apt-get clean && \
86113
rm -rf /var/lib/apt/lists/*
87114

88-
# Install dependencies for 'pr-code-lint.yml' job
89-
COPY llvm/utils/git/requirements_linting.txt requirements_linting.txt
90-
RUN pip install -r requirements_linting.txt --break-system-packages && \
91-
rm requirements_linting.txt
92-
USER gha
93-
WORKDIR /home/gha
115+
RUN git clone https://github.com/universal-ctags/ctags.git && \
116+
cd ctags && \
117+
./autogen.sh && \
118+
./configure && \
119+
sudo make install && \
120+
rm -Rf ../ctags
121+

.github/workflows/premerge.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ jobs:
6464
- name: Build and Test
6565
timeout-minutes: 120
6666
continue-on-error: ${{ runner.arch == 'ARM64' }}
67+
env:
68+
GITHUB_TOKEN: ${{ github.token }}
69+
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
6770
run: |
6871
git config --global --add safe.directory '*'
6972
@@ -153,6 +156,9 @@ jobs:
153156
timeout-minutes: 180
154157
if: ${{ steps.vars.outputs.windows-projects != '' }}
155158
shell: cmd
159+
env:
160+
GITHUB_TOKEN: ${{ github.token }}
161+
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
156162
run: |
157163
call C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64
158164
# See the comments above in the Linux job for why we define each of

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,11 @@ class MCPlusBuilder {
784784

785785
virtual bool isPop(const MCInst &Inst) const { return false; }
786786

787+
/// Determine if a basic block looks like an epilogue. For now it is only
788+
/// called at the final stage of building CFG to check basic block ending
789+
/// with an indirect call that has unknown control flow attribute.
790+
virtual bool isEpilogue(const BinaryBasicBlock &BB) const { return false; }
791+
787792
/// Return true if the instruction is used to terminate an indirect branch.
788793
virtual bool isTerminateBranch(const MCInst &Inst) const {
789794
llvm_unreachable("not implemented");
@@ -1371,20 +1376,13 @@ class MCPlusBuilder {
13711376
/// Return true if \p Inst has RestoreState annotation.
13721377
bool hasRestoreState(const MCInst &Inst) const;
13731378

1374-
/// Stores RA Signed annotation on \p Inst.
1375-
void setRASigned(MCInst &Inst) const;
1376-
1377-
/// Return true if \p Inst has Signed RA annotation.
1378-
bool isRASigned(const MCInst &Inst) const;
1379-
1380-
/// Stores RA Unsigned annotation on \p Inst.
1381-
void setRAUnsigned(MCInst &Inst) const;
1382-
1383-
/// Return true if \p Inst has Unsigned RA annotation.
1384-
bool isRAUnsigned(const MCInst &Inst) const;
1379+
/// Sets kRASigned or kRAUnsigned annotation on \p Inst.
1380+
/// Fails if \p Inst has either annotation already set.
1381+
void setRAState(MCInst &Inst, bool State) const;
13851382

1386-
/// Return true if \p Inst doesn't have any annotation related to RA state.
1387-
bool isRAStateUnknown(const MCInst &Inst) const;
1383+
/// Return true if \p Inst has kRASigned annotation, false if it has
1384+
/// kRAUnsigned annotation, and std::nullopt if neither annotation is set.
1385+
std::optional<bool> getRAState(const MCInst &Inst) const;
13881386

13891387
/// Return true if the instruction is a call with an exception handling info.
13901388
virtual bool isInvoke(const MCInst &Inst) const {

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,13 +2167,10 @@ bool BinaryFunction::postProcessIndirectBranches(
21672167
continue;
21682168
}
21692169

2170-
// If this block contains an epilogue code and has an indirect branch,
2171-
// then most likely it's a tail call. Otherwise, we cannot tell for sure
2172-
// what it is and conservatively reject the function's CFG.
2173-
bool IsEpilogue = llvm::any_of(BB, [&](const MCInst &Instr) {
2174-
return BC.MIB->isLeave(Instr) || BC.MIB->isPop(Instr);
2175-
});
2176-
if (IsEpilogue) {
2170+
// If this block contains epilogue code and has an indirect branch,
2171+
// then most likely it's a tail call. Otherwise, we cannot tell for
2172+
// sure what it is and conservatively reject the function's CFG.
2173+
if (BC.MIB->isEpilogue(BB)) {
21772174
BC.MIB->convertJmpToTailCall(Instr);
21782175
BB.removeAllSuccessors();
21792176
continue;

bolt/lib/Core/MCPlusBuilder.cpp

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -186,26 +186,21 @@ bool MCPlusBuilder::hasRestoreState(const MCInst &Inst) const {
186186
return hasAnnotation(Inst, MCAnnotation::kRestoreState);
187187
}
188188

189-
void MCPlusBuilder::setRASigned(MCInst &Inst) const {
189+
void MCPlusBuilder::setRAState(MCInst &Inst, bool State) const {
190190
assert(!hasAnnotation(Inst, MCAnnotation::kRASigned));
191-
setAnnotationOpValue(Inst, MCAnnotation::kRASigned, true);
192-
}
193-
194-
bool MCPlusBuilder::isRASigned(const MCInst &Inst) const {
195-
return hasAnnotation(Inst, MCAnnotation::kRASigned);
196-
}
197-
198-
void MCPlusBuilder::setRAUnsigned(MCInst &Inst) const {
199191
assert(!hasAnnotation(Inst, MCAnnotation::kRAUnsigned));
200-
setAnnotationOpValue(Inst, MCAnnotation::kRAUnsigned, true);
192+
if (State)
193+
setAnnotationOpValue(Inst, MCAnnotation::kRASigned, true);
194+
else
195+
setAnnotationOpValue(Inst, MCAnnotation::kRAUnsigned, true);
201196
}
202197

203-
bool MCPlusBuilder::isRAUnsigned(const MCInst &Inst) const {
204-
return hasAnnotation(Inst, MCAnnotation::kRAUnsigned);
205-
}
206-
207-
bool MCPlusBuilder::isRAStateUnknown(const MCInst &Inst) const {
208-
return !(isRAUnsigned(Inst) || isRASigned(Inst));
198+
std::optional<bool> MCPlusBuilder::getRAState(const MCInst &Inst) const {
199+
if (hasAnnotation(Inst, MCAnnotation::kRASigned))
200+
return true;
201+
if (hasAnnotation(Inst, MCAnnotation::kRAUnsigned))
202+
return false;
203+
return std::nullopt;
209204
}
210205

211206
std::optional<MCLandingPad> MCPlusBuilder::getEHInfo(const MCInst &Inst) const {

0 commit comments

Comments
 (0)