Skip to content

Commit 54b23ba

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into fix/163090
2 parents f3f09ab + f7e9968 commit 54b23ba

File tree

218 files changed

+8373
-1855
lines changed

Some content is hidden

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

218 files changed

+8373
-1855
lines changed

.ci/premerge_advisor_upload.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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+
"""Script for uploading results to the premerge advisor."""
5+
6+
import argparse
7+
import os
8+
import platform
9+
import sys
10+
11+
import requests
12+
13+
import generate_test_report_lib
14+
15+
PREMERGE_ADVISOR_URL = (
16+
"http://premerge-advisor.premerge-advisor.svc.cluster.local:5000/upload"
17+
)
18+
19+
20+
def main(commit_sha, workflow_run_number, build_log_files):
21+
junit_objects, ninja_logs = generate_test_report_lib.load_info_from_files(
22+
build_log_files
23+
)
24+
test_failures = generate_test_report_lib.get_failures(junit_objects)
25+
source = "pull_request" if "GITHUB_ACTIONS" in os.environ else "postcommit"
26+
failure_info = {
27+
"source_type": source,
28+
"base_commit_sha": commit_sha,
29+
"source_id": workflow_run_number,
30+
"failures": [],
31+
}
32+
if test_failures:
33+
for name, failure_message in test_failures:
34+
failure_info["failures"].append({"name": name, "message": failure_message})
35+
else:
36+
ninja_failures = generate_test_report_lib.find_failure_in_ninja_logs(ninja_logs)
37+
for name, failure_message in ninja_failures:
38+
failure_info["failures"].append({"name": name, "message": failure_message})
39+
requests.post(PREMERGE_ADVISOR_URL, json=failure_info)
40+
41+
42+
if __name__ == "__main__":
43+
parser = argparse.ArgumentParser()
44+
parser.add_argument("commit_sha", help="The base commit SHA for the test.")
45+
parser.add_argument("workflow_run_number", help="The run number from GHA.")
46+
parser.add_argument(
47+
"build_log_files", help="Paths to JUnit report files and ninja logs.", nargs="*"
48+
)
49+
args = parser.parse_args()
50+
51+
# Skip uploading results on AArch64 for now because the premerge advisor
52+
# service is not available on AWS currently.
53+
if platform.machine() == "arm64":
54+
sys.exit(0)
55+
56+
main(args.commit_sha, args.workflow_run_number, args.build_log_files)

.ci/utils.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ function at-exit {
3838
$retcode "${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log \
3939
>> $GITHUB_STEP_SUMMARY
4040
fi
41+
42+
if [[ "$retcode" != "0" ]]; then
43+
python "${MONOREPO_ROOT}"/.ci/premerge_advisor_upload.py \
44+
$(git rev-parse HEAD~1) $GITHUB_RUN_NUMBER \
45+
"${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log
46+
fi
4147
}
4248
trap at-exit EXIT
4349

bolt/unittests/Core/MCPlusBuilder.cpp

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,82 @@ TEST_P(MCPlusBuilderTester, testAccessedRegsMultipleDefs) {
261261
{AArch64::W5, AArch64::X5, AArch64::W5_HI});
262262
}
263263

264+
TEST_P(MCPlusBuilderTester, AArch64_Psign_Pauth_variants) {
265+
if (GetParam() != Triple::aarch64)
266+
GTEST_SKIP();
267+
268+
MCInst Paciasp = MCInstBuilder(AArch64::PACIASP);
269+
MCInst Pacibsp = MCInstBuilder(AArch64::PACIBSP);
270+
ASSERT_TRUE(BC->MIB->isPSignOnLR(Paciasp));
271+
ASSERT_TRUE(BC->MIB->isPSignOnLR(Pacibsp));
272+
273+
MCInst PaciaSPLR =
274+
MCInstBuilder(AArch64::PACIA).addReg(AArch64::LR).addReg(AArch64::SP);
275+
MCInst PacibSPLR =
276+
MCInstBuilder(AArch64::PACIB).addReg(AArch64::LR).addReg(AArch64::SP);
277+
ASSERT_TRUE(BC->MIB->isPSignOnLR(PaciaSPLR));
278+
ASSERT_TRUE(BC->MIB->isPSignOnLR(PacibSPLR));
279+
280+
MCInst PacizaX5 = MCInstBuilder(AArch64::PACIZA).addReg(AArch64::X5);
281+
MCInst PacizbX5 = MCInstBuilder(AArch64::PACIZB).addReg(AArch64::X5);
282+
ASSERT_FALSE(BC->MIB->isPSignOnLR(PacizaX5));
283+
ASSERT_FALSE(BC->MIB->isPSignOnLR(PacizbX5));
284+
285+
MCInst Paciaz = MCInstBuilder(AArch64::PACIZA).addReg(AArch64::LR);
286+
MCInst Pacibz = MCInstBuilder(AArch64::PACIZB).addReg(AArch64::LR);
287+
ASSERT_TRUE(BC->MIB->isPSignOnLR(Paciaz));
288+
ASSERT_TRUE(BC->MIB->isPSignOnLR(Pacibz));
289+
290+
MCInst Pacia1716 = MCInstBuilder(AArch64::PACIA1716);
291+
MCInst Pacib1716 = MCInstBuilder(AArch64::PACIB1716);
292+
ASSERT_FALSE(BC->MIB->isPSignOnLR(Pacia1716));
293+
ASSERT_FALSE(BC->MIB->isPSignOnLR(Pacib1716));
294+
295+
MCInst Pacia171615 = MCInstBuilder(AArch64::PACIA171615);
296+
MCInst Pacib171615 = MCInstBuilder(AArch64::PACIB171615);
297+
ASSERT_FALSE(BC->MIB->isPSignOnLR(Pacia171615));
298+
ASSERT_FALSE(BC->MIB->isPSignOnLR(Pacib171615));
299+
300+
MCInst Autiasp = MCInstBuilder(AArch64::AUTIASP);
301+
MCInst Autibsp = MCInstBuilder(AArch64::AUTIBSP);
302+
ASSERT_TRUE(BC->MIB->isPAuthOnLR(Autiasp));
303+
ASSERT_TRUE(BC->MIB->isPAuthOnLR(Autibsp));
304+
305+
MCInst AutiaSPLR =
306+
MCInstBuilder(AArch64::AUTIA).addReg(AArch64::LR).addReg(AArch64::SP);
307+
MCInst AutibSPLR =
308+
MCInstBuilder(AArch64::AUTIB).addReg(AArch64::LR).addReg(AArch64::SP);
309+
ASSERT_TRUE(BC->MIB->isPAuthOnLR(AutiaSPLR));
310+
ASSERT_TRUE(BC->MIB->isPAuthOnLR(AutibSPLR));
311+
312+
MCInst AutizaX5 = MCInstBuilder(AArch64::AUTIZA).addReg(AArch64::X5);
313+
MCInst AutizbX5 = MCInstBuilder(AArch64::AUTIZB).addReg(AArch64::X5);
314+
ASSERT_FALSE(BC->MIB->isPAuthOnLR(AutizaX5));
315+
ASSERT_FALSE(BC->MIB->isPAuthOnLR(AutizbX5));
316+
317+
MCInst Autiaz = MCInstBuilder(AArch64::AUTIZA).addReg(AArch64::LR);
318+
MCInst Autibz = MCInstBuilder(AArch64::AUTIZB).addReg(AArch64::LR);
319+
ASSERT_TRUE(BC->MIB->isPAuthOnLR(Autiaz));
320+
ASSERT_TRUE(BC->MIB->isPAuthOnLR(Autibz));
321+
322+
MCInst Autia1716 = MCInstBuilder(AArch64::AUTIA1716);
323+
MCInst Autib1716 = MCInstBuilder(AArch64::AUTIB1716);
324+
ASSERT_FALSE(BC->MIB->isPAuthOnLR(Autia1716));
325+
ASSERT_FALSE(BC->MIB->isPAuthOnLR(Autib1716));
326+
327+
MCInst Autia171615 = MCInstBuilder(AArch64::AUTIA171615);
328+
MCInst Autib171615 = MCInstBuilder(AArch64::AUTIB171615);
329+
ASSERT_FALSE(BC->MIB->isPAuthOnLR(Autia171615));
330+
ASSERT_FALSE(BC->MIB->isPAuthOnLR(Autib171615));
331+
332+
MCInst Retaa = MCInstBuilder(AArch64::RETAA);
333+
MCInst Retab = MCInstBuilder(AArch64::RETAB);
334+
ASSERT_FALSE(BC->MIB->isPAuthOnLR(Retaa));
335+
ASSERT_FALSE(BC->MIB->isPAuthOnLR(Retab));
336+
ASSERT_TRUE(BC->MIB->isPAuthAndRet(Retaa));
337+
ASSERT_TRUE(BC->MIB->isPAuthAndRet(Retab));
338+
}
339+
264340
#endif // AARCH64_AVAILABLE
265341

266342
#ifdef X86_AVAILABLE
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
BasedOnStyle: LLVM
22
QualifierAlignment: Left
3+
LineEnding: LF

clang/docs/analyzer/checkers.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,50 @@ pointers with a specified address space. If the option is set to false, then
205205
reports from the specific x86 address spaces 256, 257 and 258 are still
206206
suppressed, but null dereferences from other address spaces are reported.
207207
208+
.. _core-NullPointerArithm:
209+
210+
core.NullPointerArithm (C, C++)
211+
"""""""""""""""""""""""""""""""
212+
Check for undefined arithmetic operations with null pointers.
213+
214+
The checker can detect the following cases:
215+
216+
- ``p + x`` and ``x + p`` where ``p`` is a null pointer and ``x`` is a nonzero
217+
integer value.
218+
- ``p - x`` where ``p`` is a null pointer and ``x`` is a nonzero integer
219+
value.
220+
- ``p1 - p2`` where one of ``p1`` and ``p2`` is null and the other a
221+
non-null pointer.
222+
223+
Result of these operations is undefined according to the standard.
224+
In the above listed cases, the checker will warn even if the expression
225+
described to be "nonzero" or "non-null" has unknown value, because it is likely
226+
that it can have non-zero value during the program execution.
227+
228+
.. code-block:: c
229+
230+
void test1(int *p, int offset) {
231+
if (p)
232+
return;
233+
234+
int *p1 = p + offset; // warn: 'p' is null, 'offset' is unknown but likely non-zero
235+
}
236+
237+
void test2(int *p, int offset) {
238+
if (p) { } // this indicates that it is possible for 'p' to be null
239+
if (offset == 0)
240+
return;
241+
242+
int *p1 = p - offset; // warn: 'p' is null, 'offset' is known to be non-zero
243+
}
244+
245+
void test3(char *p1, char *p2) {
246+
if (p1)
247+
return;
248+
249+
int a = p1 - p2; // warn: 'p1' is null, 'p2' can be likely non-null
250+
}
251+
208252
.. _core-StackAddressEscape:
209253
210254
core.StackAddressEscape (C)

clang/include/clang/Basic/LangOptions.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ ENUM_LANGOPT(HLSLVersion, HLSLLangStd, 16, HLSL_Unset, NotCompatible, "HLSL Vers
243243
LANGOPT(HLSLStrictAvailability, 1, 0, NotCompatible,
244244
"Strict availability diagnostic mode for HLSL built-in functions.")
245245
LANGOPT(HLSLSpvUseUnknownImageFormat, 1, 0, NotCompatible, "For storage images and texel buffers, sets the default format to 'Unknown' when not specified via the `vk::image_format` attribute. If this option is not used, the format is inferred from the resource's data type.")
246+
LANGOPT(HLSLSpvEnableMaximalReconvergence, 1, 0, NotCompatible, "Enables the MaximallyReconvergesKHR execution mode for this module. This ensures that control flow reconverges at well-defined merge points as defined by the Vulkan spec.")
246247

247248
LANGOPT(CUDAIsDevice , 1, 0, NotCompatible, "compiling for CUDA device")
248249
LANGOPT(CUDAHostDeviceConstexpr, 1, 1, NotCompatible, "treating unattributed constexpr functions as __host__ __device__")

clang/include/clang/Driver/Options.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9601,6 +9601,15 @@ def fhlsl_spv_use_unknown_image_format
96019601
"from the resource's data type.">,
96029602
MarshallingInfoFlag<LangOpts<"HLSLSpvUseUnknownImageFormat">>;
96039603

9604+
def fhlsl_spv_enable_maximal_reconvergence
9605+
: Flag<["-"], "fspv-enable-maximal-reconvergence">,
9606+
Group<dxc_Group>,
9607+
Visibility<[CC1Option, DXCOption]>,
9608+
HelpText<"Enables the MaximallyReconvergesKHR execution mode for this "
9609+
"module. This ensures that control flow reconverges at "
9610+
"well-defined merge points as defined by the Vulkan spec.">,
9611+
MarshallingInfoFlag<LangOpts<"HLSLSpvEnableMaximalReconvergence">>;
9612+
96049613
def no_wasm_opt : Flag<["--"], "no-wasm-opt">,
96059614
Group<m_Group>,
96069615
HelpText<"Disable the wasm-opt optimizer">,

clang/include/clang/StaticAnalyzer/Checkers/Checkers.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ def NullDereferenceChecker
195195
HelpText<"Check for dereferences of null pointers">,
196196
Documentation<HasDocumentation>;
197197

198+
def NullPointerArithmChecker
199+
: Checker<"NullPointerArithm">,
200+
HelpText<"Check for undefined arithmetic operations on null pointers">,
201+
Documentation<HasDocumentation>;
202+
198203
def NonNullParamChecker : Checker<"NonNullParamChecker">,
199204
HelpText<"Check for null pointers passed as arguments to a function whose "
200205
"arguments are references or marked with the 'nonnull' attribute">,

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,9 +1358,6 @@ bool Free(InterpState &S, CodePtr OpPC, bool DeleteIsArrayForm,
13581358

13591359
void diagnoseEnumValue(InterpState &S, CodePtr OpPC, const EnumDecl *ED,
13601360
const APSInt &Value) {
1361-
if (S.EvaluatingDecl && !S.EvaluatingDecl->isConstexpr())
1362-
return;
1363-
13641361
llvm::APInt Min;
13651362
llvm::APInt Max;
13661363
ED->getValueRange(Max, Min);

clang/lib/AST/ByteCode/Interp.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3096,7 +3096,8 @@ inline bool ArrayElemPtr(InterpState &S, CodePtr OpPC) {
30963096
}
30973097

30983098
if (Offset.isZero()) {
3099-
if (Ptr.getFieldDesc()->isArray() && Ptr.getIndex() == 0) {
3099+
if (const Descriptor *Desc = Ptr.getFieldDesc();
3100+
Desc && Desc->isArray() && Ptr.getIndex() == 0) {
31003101
S.Stk.push<Pointer>(Ptr.atIndex(0).narrow());
31013102
return true;
31023103
}
@@ -3126,7 +3127,8 @@ inline bool ArrayElemPtrPop(InterpState &S, CodePtr OpPC) {
31263127
}
31273128

31283129
if (Offset.isZero()) {
3129-
if (Ptr.getFieldDesc()->isArray() && Ptr.getIndex() == 0) {
3130+
if (const Descriptor *Desc = Ptr.getFieldDesc();
3131+
Desc && Desc->isArray() && Ptr.getIndex() == 0) {
31303132
S.Stk.push<Pointer>(Ptr.atIndex(0).narrow());
31313133
return true;
31323134
}

0 commit comments

Comments
 (0)