Skip to content

Commit 9c2387b

Browse files
author
Pavel V Chupin
committed
Merge from 'main' to 'sycl-web' (intel#67)
CONFLICT (content): Merge conflict in clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
2 parents bea9b4d + 4fd05e0 commit 9c2387b

File tree

295 files changed

+5636
-1570
lines changed

Some content is hidden

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

295 files changed

+5636
-1570
lines changed

clang-tools-extra/clang-tidy/utils/Matchers.h

Lines changed: 69 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,76 @@ AST_MATCHER_FUNCTION(ast_matchers::TypeMatcher, isPointerToConst) {
4949
return pointerType(pointee(qualType(isConstQualified())));
5050
}
5151

52-
AST_MATCHER_P(NamedDecl, matchesAnyListedName, std::vector<std::string>,
53-
NameList) {
54-
return llvm::any_of(NameList, [&Node](const std::string &Name) {
55-
return llvm::Regex(Name).match(Node.getName());
52+
// A matcher implementation that matches a list of type name regular expressions
53+
// against a NamedDecl. If a regular expression contains the substring "::"
54+
// matching will occur against the qualified name, otherwise only the typename.
55+
class MatchesAnyListedNameMatcher
56+
: public ast_matchers::internal::MatcherInterface<NamedDecl> {
57+
public:
58+
explicit MatchesAnyListedNameMatcher(llvm::ArrayRef<std::string> NameList) {
59+
std::transform(
60+
NameList.begin(), NameList.end(), std::back_inserter(NameMatchers),
61+
[](const llvm::StringRef Name) { return NameMatcher(Name); });
62+
}
63+
bool matches(
64+
const NamedDecl &Node, ast_matchers::internal::ASTMatchFinder *Finder,
65+
ast_matchers::internal::BoundNodesTreeBuilder *Builder) const override {
66+
return llvm::any_of(NameMatchers, [&Node](const NameMatcher &NM) {
67+
return NM.match(Node);
5668
});
69+
}
70+
71+
private:
72+
class NameMatcher {
73+
llvm::Regex Regex;
74+
enum class MatchMode {
75+
// Match against the unqualified name because the regular expression
76+
// does not contain ":".
77+
MatchUnqualified,
78+
// Match against the qualified name because the regular expression
79+
// contains ":" suggesting name and namespace should be matched.
80+
MatchQualified,
81+
// Match against the fully qualified name because the regular expression
82+
// starts with ":".
83+
MatchFullyQualified,
84+
};
85+
MatchMode Mode;
86+
87+
public:
88+
NameMatcher(const llvm::StringRef Regex)
89+
: Regex(Regex), Mode(determineMatchMode(Regex)) {}
90+
91+
bool match(const NamedDecl &ND) const {
92+
switch (Mode) {
93+
case MatchMode::MatchQualified:
94+
return Regex.match(ND.getQualifiedNameAsString());
95+
case MatchMode::MatchFullyQualified:
96+
return Regex.match("::" + ND.getQualifiedNameAsString());
97+
default:
98+
return Regex.match(ND.getName());
99+
}
100+
}
101+
102+
private:
103+
MatchMode determineMatchMode(llvm::StringRef Regex) {
104+
if (Regex.startswith(":") || Regex.startswith("^:")) {
105+
return MatchMode::MatchFullyQualified;
106+
}
107+
return Regex.contains(":") ? MatchMode::MatchQualified
108+
: MatchMode::MatchUnqualified;
109+
}
110+
};
111+
112+
std::vector<NameMatcher> NameMatchers;
113+
};
114+
115+
// Returns a matcher that matches NamedDecl's against a list of provided regular
116+
// expressions. If a regular expression contains starts ':' the NamedDecl's
117+
// qualified name will be used for matching, otherwise its name will be used.
118+
inline ::clang::ast_matchers::internal::Matcher<NamedDecl>
119+
matchesAnyListedName(llvm::ArrayRef<std::string> NameList) {
120+
return ::clang::ast_matchers::internal::makeMatcher(
121+
new MatchesAnyListedNameMatcher(NameList));
57122
}
58123

59124
} // namespace matchers

clang-tools-extra/clangd/Compiler.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ prepareCompilerInstance(std::unique_ptr<clang::CompilerInvocation> CI,
118118
VFS = VFSWithRemapping;
119119
Clang->createFileManager(VFS);
120120

121-
Clang->setTarget(TargetInfo::CreateTargetInfo(
122-
Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
123-
if (!Clang->hasTarget())
121+
if (!Clang->createTarget())
124122
return nullptr;
125123

126124
// RemappedFileBuffers will handle the lifetime of the Buffer pointer,

clang-tools-extra/docs/clang-tidy/checks/bugprone-misplaced-widening-cast.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ Options
6262

6363
.. option:: CheckImplicitCasts
6464

65-
If `true`, enables detection of implicit casts. Default is `true`.
65+
If `true`, enables detection of implicit casts. Default is `false`.

clang-tools-extra/docs/clang-tidy/checks/performance-for-range-copy.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,6 @@ Options
3131
A semicolon-separated list of names of types allowed to be copied in each
3232
iteration. Regular expressions are accepted, e.g. `[Rr]ef(erence)?$` matches
3333
every type with suffix `Ref`, `ref`, `Reference` and `reference`. The default
34-
is empty.
34+
is empty. If a name in the list contains the sequence `::` it is matched
35+
against the qualified typename (i.e. `namespace::Type`, otherwise it is
36+
matched against only the type name (i.e. `Type`).

clang-tools-extra/docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,7 @@ Options
4343

4444
A semicolon-separated list of names of types allowed to be initialized by
4545
copying. Regular expressions are accepted, e.g. `[Rr]ef(erence)?$` matches
46-
every type with suffix `Ref`, `ref`, `Reference` and `reference`. The
47-
default is empty.
46+
every type with suffix `Ref`, `ref`, `Reference` and `reference`. The default
47+
is empty. If a name in the list contains the sequence `::` it is matched
48+
against the qualified typename (i.e. `namespace::Type`, otherwise it is
49+
matched against only the type name (i.e. `Type`).

clang-tools-extra/docs/clang-tidy/checks/performance-unnecessary-value-param.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,7 @@ Options
6666

6767
A semicolon-separated list of names of types allowed to be passed by value.
6868
Regular expressions are accepted, e.g. `[Rr]ef(erence)?$` matches every type
69-
with suffix `Ref`, `ref`, `Reference` and `reference`. The default is empty.
69+
with suffix `Ref`, `ref`, `Reference` and `reference`. The default is
70+
empty. If a name in the list contains the sequence `::` it is matched against
71+
the qualified typename (i.e. `namespace::Type`, otherwise it is matched
72+
against only the type name (i.e. `Type`).

clang-tools-extra/test/clang-tidy/checkers/performance-for-range-copy-allowed-types.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %check_clang_tidy %s performance-for-range-copy %t -- \
2-
// RUN: -config="{CheckOptions: [{key: performance-for-range-copy.AllowedTypes, value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$'}]}" \
2+
// RUN: -config="{CheckOptions: [{key: performance-for-range-copy.AllowedTypes, value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$;qualified::Type;::fully::QualifiedType'}]}" \
33
// RUN: -- -fno-delayed-template-parsing
44

55
template <typename T>
@@ -63,6 +63,18 @@ template <typename T> struct SomeComplexTemplate {
6363

6464
typedef SomeComplexTemplate<int> NotTooComplexRef;
6565

66+
namespace qualified {
67+
struct Type {
68+
~Type();
69+
};
70+
} // namespace qualified
71+
72+
namespace fully {
73+
struct QualifiedType {
74+
~QualifiedType();
75+
};
76+
} // namespace fully
77+
6678
void negativeSmartPointer() {
6779
for (auto P : View<Iterator<SmartPointer>>()) {
6880
auto P2 = P;
@@ -124,3 +136,23 @@ void negativeNotTooComplexRef() {
124136
auto R2 = R;
125137
}
126138
}
139+
140+
void negativeQualified() {
141+
for (auto Q : View<Iterator<qualified::Type>>()) {
142+
auto Q2 = Q;
143+
}
144+
using qualified::Type;
145+
for (auto Q : View<Iterator<Type>>()) {
146+
auto Q2 = Q;
147+
}
148+
}
149+
150+
void negativeFullyQualified() {
151+
for (auto Q : View<Iterator<fully::QualifiedType>>()) {
152+
auto Q2 = Q;
153+
}
154+
using fully::QualifiedType;
155+
for (auto Q : View<Iterator<QualifiedType>>()) {
156+
auto Q2 = Q;
157+
}
158+
}

clang/include/clang/Basic/Builtins.def

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,9 +1636,6 @@ LANGBUILTIN(__builtin_load_halff, "fhC*", "nc", ALL_OCLC_LANGUAGES)
16361636
BUILTIN(__builtin_os_log_format_buffer_size, "zcC*.", "p:0:nut")
16371637
BUILTIN(__builtin_os_log_format, "v*v*cC*.", "p:0:nt")
16381638

1639-
// OpenMP 4.0
1640-
LANGBUILTIN(omp_is_initial_device, "i", "nc", OMP_LANG)
1641-
16421639
// CUDA/HIP
16431640
LANGBUILTIN(__builtin_get_device_side_mangled_name, "cC*.", "ncT", CUDA_LANG)
16441641

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8232,6 +8232,9 @@ def err_atomic_op_needs_non_const_pointer : Error<
82328232
def err_atomic_op_needs_trivial_copy : Error<
82338233
"address argument to atomic operation must be a pointer to a "
82348234
"trivially-copyable type (%0 invalid)">;
8235+
def err_atomic_op_needs_atomic_int_ptr_or_fp : Error<
8236+
"address argument to atomic operation must be a pointer to %select{|atomic }0"
8237+
"integer, pointer or supported floating point type (%1 invalid)">;
82358238
def err_atomic_op_needs_atomic_int_or_ptr : Error<
82368239
"address argument to atomic operation must be a pointer to %select{|atomic }0"
82378240
"integer or pointer (%1 invalid)">;

clang/include/clang/Index/DeclOccurrence.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,31 @@
99
#ifndef LLVM_CLANG_INDEX_DECLOCCURRENCE_H
1010
#define LLVM_CLANG_INDEX_DECLOCCURRENCE_H
1111

12+
#include "clang/AST/DeclBase.h"
1213
#include "clang/Basic/LLVM.h"
1314
#include "clang/Index/IndexSymbol.h"
15+
#include "clang/Lex/MacroInfo.h"
1416
#include "llvm/ADT/ArrayRef.h"
17+
#include "llvm/ADT/PointerUnion.h"
1518
#include "llvm/ADT/SmallVector.h"
1619

1720
namespace clang {
18-
class Decl;
19-
2021
namespace index {
2122

2223
struct DeclOccurrence {
2324
SymbolRoleSet Roles;
2425
unsigned Offset;
25-
const Decl *Dcl;
26+
llvm::PointerUnion<const Decl *, const MacroInfo *> DeclOrMacro;
27+
const IdentifierInfo *MacroName = nullptr;
2628
SmallVector<SymbolRelation, 3> Relations;
2729

2830
DeclOccurrence(SymbolRoleSet R, unsigned Offset, const Decl *D,
2931
ArrayRef<SymbolRelation> Relations)
30-
: Roles(R), Offset(Offset), Dcl(D),
32+
: Roles(R), Offset(Offset), DeclOrMacro(D),
3133
Relations(Relations.begin(), Relations.end()) {}
34+
DeclOccurrence(SymbolRoleSet R, unsigned Offset, const IdentifierInfo *Name,
35+
const MacroInfo *MI)
36+
: Roles(R), Offset(Offset), DeclOrMacro(MI), MacroName(Name) {}
3237

3338
friend bool operator<(const DeclOccurrence &LHS, const DeclOccurrence &RHS) {
3439
return LHS.Offset < RHS.Offset;

clang/include/clang/Index/IndexingOptions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ struct IndexingOptions {
2828
SystemSymbolFilterKind::DeclarationsOnly;
2929
bool IndexFunctionLocals = false;
3030
bool IndexImplicitInstantiation = false;
31+
bool IndexMacros = true;
3132
// Whether to index macro definitions in the Preprocesor when preprocessor
3233
// callback is not available (e.g. after parsing has finished). Note that
3334
// macro references are not available in Proprocessor.

clang/lib/AST/ExprConstant.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12015,9 +12015,6 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E,
1201512015
return BuiltinOp == Builtin::BI__atomic_always_lock_free ?
1201612016
Success(0, E) : Error(E);
1201712017
}
12018-
case Builtin::BIomp_is_initial_device:
12019-
// We can decide statically which value the runtime would return if called.
12020-
return Success(Info.getLangOpts().OpenMPIsDevice ? 0 : 1, E);
1202112018
case Builtin::BI__builtin_add_overflow:
1202212019
case Builtin::BI__builtin_sub_overflow:
1202312020
case Builtin::BI__builtin_mul_overflow:

clang/lib/Analysis/ThreadSafety.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ class ScopedLockableFactEntry : public FactEntry {
983983
} else {
984984
FSet.removeLock(FactMan, !Cp);
985985
FSet.addLock(FactMan,
986-
std::make_unique<LockableFactEntry>(Cp, kind, loc));
986+
std::make_unique<LockableFactEntry>(Cp, kind, loc, true));
987987
}
988988
}
989989

clang/lib/CodeGen/CGAtomic.cpp

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -602,21 +602,25 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *E, Address Dest,
602602
break;
603603

604604
case AtomicExpr::AO__atomic_add_fetch:
605-
PostOp = llvm::Instruction::Add;
605+
PostOp = E->getValueType()->isFloatingType() ? llvm::Instruction::FAdd
606+
: llvm::Instruction::Add;
606607
LLVM_FALLTHROUGH;
607608
case AtomicExpr::AO__c11_atomic_fetch_add:
608609
case AtomicExpr::AO__opencl_atomic_fetch_add:
609610
case AtomicExpr::AO__atomic_fetch_add:
610-
Op = llvm::AtomicRMWInst::Add;
611+
Op = E->getValueType()->isFloatingType() ? llvm::AtomicRMWInst::FAdd
612+
: llvm::AtomicRMWInst::Add;
611613
break;
612614

613615
case AtomicExpr::AO__atomic_sub_fetch:
614-
PostOp = llvm::Instruction::Sub;
616+
PostOp = E->getValueType()->isFloatingType() ? llvm::Instruction::FSub
617+
: llvm::Instruction::Sub;
615618
LLVM_FALLTHROUGH;
616619
case AtomicExpr::AO__c11_atomic_fetch_sub:
617620
case AtomicExpr::AO__opencl_atomic_fetch_sub:
618621
case AtomicExpr::AO__atomic_fetch_sub:
619-
Op = llvm::AtomicRMWInst::Sub;
622+
Op = E->getValueType()->isFloatingType() ? llvm::AtomicRMWInst::FSub
623+
: llvm::AtomicRMWInst::Sub;
620624
break;
621625

622626
case AtomicExpr::AO__atomic_min_fetch:
@@ -813,6 +817,8 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
813817
bool Oversized = getContext().toBits(TInfo.Width) > MaxInlineWidthInBits;
814818
bool Misaligned = (Ptr.getAlignment() % TInfo.Width) != 0;
815819
bool UseLibcall = Misaligned | Oversized;
820+
bool ShouldCastToIntPtrTy = true;
821+
816822
CharUnits MaxInlineWidth =
817823
getContext().toCharUnitsFromBits(MaxInlineWidthInBits);
818824

@@ -892,11 +898,14 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
892898
EmitStoreOfScalar(Val1Scalar, MakeAddrLValue(Temp, Val1Ty));
893899
break;
894900
}
895-
LLVM_FALLTHROUGH;
901+
LLVM_FALLTHROUGH;
896902
case AtomicExpr::AO__atomic_fetch_add:
897903
case AtomicExpr::AO__atomic_fetch_sub:
898904
case AtomicExpr::AO__atomic_add_fetch:
899905
case AtomicExpr::AO__atomic_sub_fetch:
906+
ShouldCastToIntPtrTy = !MemTy->isFloatingType();
907+
LLVM_FALLTHROUGH;
908+
900909
case AtomicExpr::AO__c11_atomic_store:
901910
case AtomicExpr::AO__c11_atomic_exchange:
902911
case AtomicExpr::AO__opencl_atomic_store:
@@ -937,15 +946,23 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
937946
LValue AtomicVal = MakeAddrLValue(Ptr, AtomicTy);
938947
AtomicInfo Atomics(*this, AtomicVal);
939948

940-
Ptr = Atomics.emitCastToAtomicIntPointer(Ptr);
941-
if (Val1.isValid()) Val1 = Atomics.convertToAtomicIntPointer(Val1);
942-
if (Val2.isValid()) Val2 = Atomics.convertToAtomicIntPointer(Val2);
943-
if (Dest.isValid())
944-
Dest = Atomics.emitCastToAtomicIntPointer(Dest);
945-
else if (E->isCmpXChg())
949+
if (ShouldCastToIntPtrTy) {
950+
Ptr = Atomics.emitCastToAtomicIntPointer(Ptr);
951+
if (Val1.isValid())
952+
Val1 = Atomics.convertToAtomicIntPointer(Val1);
953+
if (Val2.isValid())
954+
Val2 = Atomics.convertToAtomicIntPointer(Val2);
955+
}
956+
if (Dest.isValid()) {
957+
if (ShouldCastToIntPtrTy)
958+
Dest = Atomics.emitCastToAtomicIntPointer(Dest);
959+
} else if (E->isCmpXChg())
946960
Dest = CreateMemTemp(RValTy, "cmpxchg.bool");
947-
else if (!RValTy->isVoidType())
948-
Dest = Atomics.emitCastToAtomicIntPointer(Atomics.CreateTempAlloca());
961+
else if (!RValTy->isVoidType()) {
962+
Dest = Atomics.CreateTempAlloca();
963+
if (ShouldCastToIntPtrTy)
964+
Dest = Atomics.emitCastToAtomicIntPointer(Dest);
965+
}
949966

950967
// Use a library call. See: http://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary .
951968
if (UseLibcall) {

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5315,6 +5315,14 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
53155315
if (D.CCGenDiagnostics)
53165316
CmdArgs.push_back("-disable-pragma-debug-crash");
53175317

5318+
// Allow backend to put its diagnostic files in the same place as frontend
5319+
// crash diagnostics files.
5320+
if (Args.hasArg(options::OPT_fcrash_diagnostics_dir)) {
5321+
StringRef Dir = Args.getLastArgValue(options::OPT_fcrash_diagnostics_dir);
5322+
CmdArgs.push_back("-mllvm");
5323+
CmdArgs.push_back(Args.MakeArgString("-crash-diagnostics-dir=" + Dir));
5324+
}
5325+
53185326
bool UseSeparateSections = isUseSeparateSections(Triple);
53195327

53205328
if (Args.hasFlag(options::OPT_ffunction_sections,

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,7 @@ unsigned tools::getOrCheckAMDGPUCodeObjectVersion(
15851585
const Driver &D, const llvm::opt::ArgList &Args, bool Diagnose) {
15861586
const unsigned MinCodeObjVer = 2;
15871587
const unsigned MaxCodeObjVer = 4;
1588-
unsigned CodeObjVer = 3;
1588+
unsigned CodeObjVer = 4;
15891589

15901590
// Emit warnings for legacy options even if they are overridden.
15911591
if (Diagnose) {

clang/lib/Driver/ToolChains/HIP.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,12 @@ void AMDGCN::constructHIPFatbinCommand(Compilation &C, const JobAction &JA,
108108
std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux";
109109
std::string BundlerInputArg = "-inputs=" NULL_FILE;
110110

111-
// TODO: Change the bundle ID as requested by HIP runtime.
112111
// For code object version 2 and 3, the offload kind in bundle ID is 'hip'
113112
// for backward compatibility. For code object version 4 and greater, the
114113
// offload kind in bundle ID is 'hipv4'.
115114
std::string OffloadKind = "hip";
115+
if (getOrCheckAMDGPUCodeObjectVersion(C.getDriver(), Args) >= 4)
116+
OffloadKind = OffloadKind + "v4";
116117
for (const auto &II : Inputs) {
117118
const auto* A = II.getAction();
118119
BundlerTargetArg = BundlerTargetArg + "," + OffloadKind +

0 commit comments

Comments
 (0)