Skip to content

Commit 8073f82

Browse files
ronliebanimeshk-amd
authored andcommitted
merge main into amd-staging
Change-Id: I5a73a052c536d71b74786c373a67f71e4d489413
2 parents 630d35f + 5e4b41c commit 8073f82

File tree

28 files changed

+292
-64
lines changed

28 files changed

+292
-64
lines changed

.ci/metrics/metrics.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ def get_metrics(github_repo: github.Repository, workflows_to_track: dict[str, in
8080
completed_at = workflow_jobs[0].completed_at
8181

8282
job_result = int(workflow_jobs[0].conclusion == "success")
83+
if job_result:
84+
# We still might want to mark the job as a failure if one of the steps
85+
# failed. This is required due to use setting continue-on-error in
86+
# the premerge pipeline to prevent sending emails while we are
87+
# testing the infrastructure.
88+
# TODO(boomanaiden154): Remove this once the premerge pipeline is no
89+
# longer in a testing state and we can directly assert the workflow
90+
# result.
91+
for step in workflow_jobs[0].steps:
92+
if step.conclusion != "success":
93+
job_result = 0
94+
break
8395

8496
queue_time = started_at - created_at
8597
run_time = completed_at - started_at

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -108,22 +108,19 @@ Improvements to clang-query
108108
Improvements to clang-tidy
109109
--------------------------
110110

111-
- Improved :program:`clang-tidy`'s `--verify-config` flag by adding support for
112-
the configuration options of the `Clang Static Analyzer Checks
113-
<https://clang.llvm.org/docs/analyzer/checkers.html>`_.
114-
115-
- Improved :program:`clang-tidy` by accepting parameters file in command line.
116-
117111
- Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
118112
happening on certain platforms when interrupting the script.
119113

120-
- Improved :program:`clang-tidy` by fixing incorrect configuration file path
121-
resolving when file paths contain ``..``.
114+
- Improved :program:`clang-tidy`:
122115

123-
- Removed :program:`clang-tidy`'s global options for most of checks. All options
124-
are changed to local options except `IncludeStyle`, `StrictMode` and
125-
`IgnoreMacros`. Global scoped `StrictMode` and `IgnoreMacros` are deprecated
126-
and will be removed in further releases.
116+
- add support for `--verify-config` flag to check the configuration options of
117+
the `Clang Static Analyzer Checks <https://clang.llvm.org/docs/analyzer/checkers.html>`_.
118+
- accept parameters file in command line.
119+
- fix incorrect configuration file path resolving when file paths contain ``..``.
120+
- remove global options for most of checks. All options are changed to local
121+
options except `IncludeStyle`, `StrictMode` and `IgnoreMacros`. Global scoped
122+
`StrictMode` and `IgnoreMacros` are deprecated and will be removed in further
123+
releases.
127124

128125
.. csv-table::
129126
:header: "Check", "Options removed from global option"

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15855,8 +15855,8 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) {
1585515855
llvm::DenseMap<const BlockDecl *, bool> EscapeInfo;
1585615856

1585715857
auto IsOrNestedInEscapingBlock = [&](const BlockDecl *BD) {
15858-
if (EscapeInfo.count(BD))
15859-
return EscapeInfo[BD];
15858+
if (auto It = EscapeInfo.find(BD); It != EscapeInfo.end())
15859+
return It->second;
1586015860

1586115861
bool R = false;
1586215862
const BlockDecl *CurBD = BD;

clang/lib/Sema/SemaOpenMP.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5400,11 +5400,13 @@ static bool checkNestingOfRegions(Sema &SemaRef, const DSAStackTy *Stack,
54005400
Recommend = ShouldBeInTargetRegion;
54015401
} else if (CurrentRegion == OMPD_scan) {
54025402
if (SemaRef.LangOpts.OpenMP >= 50) {
5403-
// Make sure that the '-fopenmp-target-xteam-scan' flag is passed to
5404-
// enable the Xteam-Scan Codegen, if the 'scan' directive is found to be
5405-
// nested inside the 'target teams distribute parallel for' directive
5403+
// Make sure that one of the flags - '-fopenmp-target-xteam-scan' or
5404+
// '-fopenmp-target-xteam-no-loop-scan' flag is passed to enable the
5405+
// Xteam-Scan Codegen, if the 'scan' directive is found to be nested
5406+
// inside the 'target teams distribute parallel for' directive
54065407
if (ParentRegion == OMPD_target_teams_distribute_parallel_for &&
5407-
!SemaRef.getLangOpts().OpenMPTargetXteamScan)
5408+
!(SemaRef.getLangOpts().OpenMPTargetXteamScan ||
5409+
SemaRef.getLangOpts().OpenMPTargetXteamNoLoopScan))
54085410
SemaRef.Diag(StartLoc, diag::err_omp_xteam_scan_prohibited)
54095411
<< getOpenMPDirectiveName(CurrentRegion) << Recommend;
54105412
// OpenMP spec 5.0 and 5.1 require scan to be directly enclosed by for,

clang/test/OpenMP/xteam_scan_codegen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
/*---------------------------------------- Test Xteam NoLoop Scan -----------------------------------------*/
44

5-
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -fopenmp-target-ignore-env-vars -fopenmp-assume-no-nested-parallelism -fopenmp-assume-no-thread-state -fopenmp-target-xteam-no-loop-scan -emit-llvm-bc %s -o %t-ppc-host1.bc
6-
// RUN: %clang_cc1 -target-cpu gfx90a -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -fopenmp-target-ignore-env-vars -fopenmp-assume-no-nested-parallelism -fopenmp-assume-no-thread-state -fopenmp-target-xteam-no-loop-scan -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host1.bc -o - | FileCheck %s --check-prefix=CHECK-64WAVE
5+
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -fopenmp-target-ignore-env-vars -fopenmp-assume-no-nested-parallelism -fopenmp-assume-no-thread-state -fopenmp-target-xteam-no-loop-scan -emit-llvm-bc %s -o %t-ppc-host1.bc
6+
// RUN: %clang_cc1 -target-cpu gfx90a -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -fopenmp-target-ignore-env-vars -fopenmp-assume-no-nested-parallelism -fopenmp-assume-no-thread-state -fopenmp-target-xteam-no-loop-scan -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host1.bc -o - | FileCheck %s --check-prefix=CHECK-64WAVE
77

88
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -fopenmp-target-ignore-env-vars -fopenmp-assume-no-nested-parallelism -fopenmp-assume-no-thread-state -fopenmp-target-xteam-no-loop-scan -emit-llvm-bc %s -DNUM_THREADS=512 -o %t-ppc-host2.bc
99
// RUN: %clang_cc1 -target-cpu gfx90a -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -fopenmp-target-ignore-env-vars -fopenmp-assume-no-nested-parallelism -fopenmp-assume-no-thread-state -fopenmp-target-xteam-no-loop-scan -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host2.bc -DNUM_THREADS=512 -o - | FileCheck %s --check-prefix=CHECK-64WAVE-512WGSize

libc/cmake/modules/LLVMLibCHeaderRules.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ function(add_header target_name)
6666
set_target_properties(
6767
${fq_target_name}
6868
PROPERTIES
69+
HEADER_NAME ${dest_leaf_filename}
6970
HEADER_FILE_PATH ${dest_file}
7071
DEPS "${fq_deps_list}"
7172
)
@@ -164,6 +165,7 @@ function(add_gen_header target_name)
164165
set_target_properties(
165166
${fq_target_name}
166167
PROPERTIES
168+
HEADER_NAME ${ADD_GEN_HDR_GEN_HDR}
167169
HEADER_FILE_PATH ${out_file}
168170
DECLS_FILE_PATH "${decl_out_file}"
169171
DEPS "${fq_deps_list}"

libc/test/include/CMakeLists.txt

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ add_libc_test(
422422
-Werror
423423
DEPENDS
424424
libc.include.llvm-libc-macros.math_function_macros
425-
)
425+
)
426426

427427
add_libc_test(
428428
isfinite_c_test
@@ -483,3 +483,70 @@ add_libc_test(
483483
DEPENDS
484484
libc.include.llvm-libc-macros.math_function_macros
485485
)
486+
487+
# Test `#include <...>` of each header in each available language mode.
488+
# This is gated on -DLLVM_LIBC_BUILD_HEADER_TESTS=ON until all the bugs
489+
# in headers are fixed so the tests all compile.
490+
set(TEST_STDC_VERSIONS 89;99;11;17;23)
491+
set(TEST_STDCXX_VERSIONS 03;11;14;17;20;23;26)
492+
493+
function(add_header_test target_name source_file deps std_mode)
494+
if(LLVM_LIBC_BUILD_HEADER_TESTS)
495+
add_libc_test(
496+
${target_name}
497+
C_TEST
498+
HERMETIC_TEST_ONLY
499+
SUITE
500+
libc_include_tests
501+
SRCS
502+
${source_file}
503+
COMPILE_OPTIONS
504+
-Werror
505+
-Wsystem-headers
506+
-Wall
507+
-Wextra
508+
-std=${std_mode}
509+
DEPENDS
510+
${deps}
511+
)
512+
endif()
513+
endfunction()
514+
515+
foreach(target ${TARGET_PUBLIC_HEADERS})
516+
string(REPLACE "libc.include." "" header ${target})
517+
get_target_property(HEADER_NAME ${target} HEADER_NAME)
518+
519+
set(test_stdc_file "${CMAKE_CURRENT_BINARY_DIR}/${header}_test.c")
520+
configure_file(header-test-template.c ${test_stdc_file} @ONLY)
521+
foreach(stdc_version ${TEST_STDC_VERSIONS})
522+
add_header_test(
523+
"${header}_c${stdc_version}_test"
524+
${test_stdc_file}
525+
${target}
526+
"c${stdc_version}"
527+
)
528+
add_header_test(
529+
"${header}_gnu${stdc_version}_test"
530+
${test_stdc_file}
531+
${target}
532+
"gnu${stdc_version}"
533+
)
534+
endforeach()
535+
536+
set(test_stdcxx_file "${CMAKE_CURRENT_BINARY_DIR}/${header}_test.cpp")
537+
configure_file(header-test-template.c ${test_stdcxx_file} @ONLY)
538+
foreach(stdcxx_version ${TEST_STDCXX_VERSIONS})
539+
add_header_test(
540+
"${header}_cpp${stdcxx_version}_test"
541+
${test_stdcxx_file}
542+
${target}
543+
"c++${stdcxx_version}"
544+
)
545+
add_header_test(
546+
"${header}_gnucpp${stdcxx_version}_test"
547+
${test_stdcxx_file}
548+
${target}
549+
"gnu++${stdcxx_version}"
550+
)
551+
endforeach()
552+
endforeach()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*===-- Test for <@HEADER_NAME@> ----------------------------------------===
2+
*
3+
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
* See https://llvm.org/LICENSE.txt for license information.
5+
* SPDXList-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
*/
7+
8+
#include <@HEADER_NAME@>
9+
10+
int main(int argc, char **argv) {
11+
(void)argc;
12+
(void)argv;
13+
return 0;
14+
}

llvm/lib/Analysis/InstructionSimplify.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,14 @@ static Value *simplifySubInst(Value *Op0, Value *Op1, bool IsNSW, bool IsNUW,
871871
if (Value *V = simplifyByDomEq(Instruction::Sub, Op0, Op1, Q, MaxRecurse))
872872
return V;
873873

874+
// (sub nuw C_Mask, (xor X, C_Mask)) -> X
875+
if (IsNUW) {
876+
Value *X;
877+
if (match(Op1, m_Xor(m_Value(X), m_Specific(Op0))) &&
878+
match(Op0, m_LowBitMask()))
879+
return X;
880+
}
881+
874882
return nullptr;
875883
}
876884

@@ -2540,6 +2548,14 @@ static Value *simplifyXorInst(Value *Op0, Value *Op1, const SimplifyQuery &Q,
25402548
if (Value *V = simplifyByDomEq(Instruction::Xor, Op0, Op1, Q, MaxRecurse))
25412549
return V;
25422550

2551+
// (xor (sub nuw C_Mask, X), C_Mask) -> X
2552+
{
2553+
Value *X;
2554+
if (match(Op0, m_NUWSub(m_Specific(Op1), m_Value(X))) &&
2555+
match(Op1, m_LowBitMask()))
2556+
return X;
2557+
}
2558+
25432559
return nullptr;
25442560
}
25452561

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9897,13 +9897,20 @@ static void setLimitsForBinOp(const BinaryOperator &BO, APInt &Lower,
98979897
}
98989898
}
98999899

9900-
static ConstantRange getRangeForIntrinsic(const IntrinsicInst &II) {
9900+
static ConstantRange getRangeForIntrinsic(const IntrinsicInst &II,
9901+
bool UseInstrInfo) {
99019902
unsigned Width = II.getType()->getScalarSizeInBits();
99029903
const APInt *C;
99039904
switch (II.getIntrinsicID()) {
9904-
case Intrinsic::ctpop:
99059905
case Intrinsic::ctlz:
9906-
case Intrinsic::cttz:
9906+
case Intrinsic::cttz: {
9907+
APInt Upper(Width, Width);
9908+
if (!UseInstrInfo || !match(II.getArgOperand(1), m_One()))
9909+
Upper += 1;
9910+
// Maximum of set/clear bits is the bit width.
9911+
return ConstantRange::getNonEmpty(APInt::getZero(Width), Upper);
9912+
}
9913+
case Intrinsic::ctpop:
99079914
// Maximum of set/clear bits is the bit width.
99089915
return ConstantRange::getNonEmpty(APInt::getZero(Width),
99099916
APInt(Width, Width) + 1);
@@ -10094,7 +10101,7 @@ ConstantRange llvm::computeConstantRange(const Value *V, bool ForSigned,
1009410101
setLimitsForBinOp(*BO, Lower, Upper, IIQ, ForSigned);
1009510102
CR = ConstantRange::getNonEmpty(Lower, Upper);
1009610103
} else if (auto *II = dyn_cast<IntrinsicInst>(V))
10097-
CR = getRangeForIntrinsic(*II);
10104+
CR = getRangeForIntrinsic(*II, UseInstrInfo);
1009810105
else if (auto *SI = dyn_cast<SelectInst>(V)) {
1009910106
ConstantRange CRTrue = computeConstantRange(
1010010107
SI->getTrueValue(), ForSigned, UseInstrInfo, AC, CtxI, DT, Depth + 1);

0 commit comments

Comments
 (0)