Skip to content

Commit 4edb159

Browse files
committed
Merge branch 'amd-staging' into amd/dev/dpalermo/frt-abort-fix
2 parents 6a76a3c + e2563db commit 4edb159

File tree

1,676 files changed

+13354
-6473
lines changed

Some content is hidden

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

1,676 files changed

+13354
-6473
lines changed

clang-tools-extra/clang-tidy/misc/HeaderIncludeCycleCheck.cpp

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include "clang/Lex/Preprocessor.h"
1414
#include "llvm/Support/Regex.h"
1515
#include <algorithm>
16-
#include <deque>
1716
#include <optional>
17+
#include <vector>
1818

1919
using namespace clang::ast_matchers;
2020

@@ -23,8 +23,8 @@ namespace clang::tidy::misc {
2323
namespace {
2424

2525
struct Include {
26-
FileID Id;
27-
llvm::StringRef Name;
26+
const FileEntry *File;
27+
StringRef Name;
2828
SourceLocation Loc;
2929
};
3030

@@ -50,31 +50,27 @@ class CyclicDependencyCallbacks : public PPCallbacks {
5050
if (Reason != EnterFile && Reason != ExitFile)
5151
return;
5252

53-
FileID Id = SM.getFileID(Loc);
53+
const FileID Id = SM.getFileID(Loc);
5454
if (Id.isInvalid())
5555
return;
5656

57+
const FileEntry *NewFile = SM.getFileEntryForID(Id);
58+
const FileEntry *PrevFile = SM.getFileEntryForID(PrevFID);
59+
5760
if (Reason == ExitFile) {
58-
if ((Files.size() > 1U) && (Files.back().Id == PrevFID) &&
59-
(Files[Files.size() - 2U].Id == Id))
61+
if ((Files.size() > 1U) && (Files.back().File == PrevFile) &&
62+
(Files[Files.size() - 2U].File == NewFile))
6063
Files.pop_back();
6164
return;
6265
}
6366

64-
if (!Files.empty() && Files.back().Id == Id)
67+
if (!Files.empty() && Files.back().File == NewFile)
6568
return;
6669

67-
std::optional<llvm::StringRef> FilePath = SM.getNonBuiltinFilenameForID(Id);
68-
llvm::StringRef FileName =
69-
FilePath ? llvm::sys::path::filename(*FilePath) : llvm::StringRef();
70-
71-
if (!NextToEnter)
72-
NextToEnter = Include{Id, FileName, SourceLocation()};
73-
74-
assert(NextToEnter->Name == FileName);
75-
NextToEnter->Id = Id;
76-
Files.emplace_back(*NextToEnter);
77-
NextToEnter.reset();
70+
const std::optional<StringRef> FilePath = SM.getNonBuiltinFilenameForID(Id);
71+
const StringRef FileName =
72+
FilePath ? llvm::sys::path::filename(*FilePath) : StringRef();
73+
Files.push_back({NewFile, FileName, std::exchange(NextToEnter, {})});
7874
}
7975

8076
void InclusionDirective(SourceLocation, const Token &, StringRef FilePath,
@@ -85,36 +81,26 @@ class CyclicDependencyCallbacks : public PPCallbacks {
8581
if (FileType != clang::SrcMgr::C_User)
8682
return;
8783

88-
llvm::StringRef FileName = llvm::sys::path::filename(FilePath);
89-
NextToEnter = {FileID(), FileName, Range.getBegin()};
84+
NextToEnter = Range.getBegin();
9085

9186
if (!File)
9287
return;
9388

94-
FileID Id = SM.translateFile(*File);
95-
if (Id.isInvalid())
96-
return;
97-
98-
checkForDoubleInclude(Id, FileName, Range.getBegin());
99-
}
100-
101-
void EndOfMainFile() override {
102-
if (!Files.empty() && Files.back().Id == SM.getMainFileID())
103-
Files.pop_back();
104-
105-
assert(Files.empty());
89+
checkForDoubleInclude(&File->getFileEntry(),
90+
llvm::sys::path::filename(FilePath),
91+
Range.getBegin());
10692
}
10793

108-
void checkForDoubleInclude(FileID Id, llvm::StringRef FileName,
94+
void checkForDoubleInclude(const FileEntry *File, StringRef FileName,
10995
SourceLocation Loc) {
110-
auto It =
111-
std::find_if(Files.rbegin(), Files.rend(),
112-
[&](const Include &Entry) { return Entry.Id == Id; });
96+
const auto It =
97+
llvm::find_if(llvm::reverse(Files),
98+
[&](const Include &Entry) { return Entry.File == File; });
11399
if (It == Files.rend())
114100
return;
115101

116-
const std::optional<StringRef> FilePath = SM.getNonBuiltinFilenameForID(Id);
117-
if (!FilePath || isFileIgnored(*FilePath))
102+
const StringRef FilePath = File->tryGetRealPathName();
103+
if (FilePath.empty() || isFileIgnored(FilePath))
118104
return;
119105

120106
if (It == Files.rbegin()) {
@@ -144,9 +130,19 @@ class CyclicDependencyCallbacks : public PPCallbacks {
144130
});
145131
}
146132

133+
#ifndef NDEBUG
134+
void EndOfMainFile() override {
135+
if (!Files.empty() &&
136+
Files.back().File == SM.getFileEntryForID(SM.getMainFileID()))
137+
Files.pop_back();
138+
139+
assert(Files.empty());
140+
}
141+
#endif
142+
147143
private:
148-
std::deque<Include> Files;
149-
std::optional<Include> NextToEnter;
144+
std::vector<Include> Files;
145+
SourceLocation NextToEnter;
150146
HeaderIncludeCycleCheck &Check;
151147
const SourceManager &SM;
152148
std::vector<llvm::Regex> IgnoredFilesRegexes;

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ Changes in existing checks
118118
<clang-tidy/checks/bugprone/unhandled-self-assignment>` check by adding
119119
an additional matcher that generalizes the copy-and-swap idiom pattern
120120
detection.
121+
122+
- Improved :doc:`misc-header-include-cycle
123+
<clang-tidy/checks/misc/header-include-cycle>` check performance.
121124

122125
Removed checks
123126
^^^^^^^^^^^^^^

clang/docs/OpenMPSupport.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ implementation.
443443
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
444444
| Traits for default device envirable | :none:`unclaimed` | :none:`unclaimed` | |
445445
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
446-
| Optionally omit array length expression | :none:`unclaimed` | :none:`unclaimed` | |
446+
| Optionally omit array length expression | :good:`done` | :none:`unclaimed` | https://github.com/llvm/llvm-project/pull/148048 |
447447
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
448448
| Canonical loop sequences | :none:`unclaimed` | :none:`unclaimed` | |
449449
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
@@ -467,6 +467,9 @@ implementation.
467467
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
468468
| Non-const do_not_sync for nowait/nogroup | :none:`unclaimed` | :none:`unclaimed` | |
469469
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
470+
| need_device_addr modifier for adjust_args clause | :part:`partial` | :none:`unclaimed` | Parsing/Sema: https://github.com/llvm/llvm-project/pull/143442 |
471+
| | | | https://github.com/llvm/llvm-project/pull/149586 |
472+
+-------------------------------------------------------------+---------------------------+---------------------------+--------------------------------------------------------------------------+
470473

471474
OpenMP Extensions
472475
=================

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,9 @@ OpenMP Support
13341334
mappers, by using compiler-generated default mappers for the outer structs for
13351335
such maps.
13361336
- Deprecation warning has been emitted for deprecated delimited form of ``declare target``.
1337+
- Added parsing and semantic analysis support for the 'need_device_addr'
1338+
modifier in the 'adjust_args' clause.
1339+
- Allow array length to be omitted in array section subscript expression.
13371340

13381341
Improvements
13391342
^^^^^^^^^^^^

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,9 @@ def err_omp_unknown_adjust_args_op
15941594
def err_omp_declare_variant_wrong_clause : Error<
15951595
"expected %select{'match'|'match', 'adjust_args', or 'append_args'}0 clause "
15961596
"on 'omp declare variant' directive">;
1597+
def err_omp_non_by_ref_need_device_addr_modifier_argument
1598+
: Error<"expected reference type argument on 'adjust_args' clause with "
1599+
"'need_device_addr' modifier">;
15971600
def err_omp_declare_variant_duplicate_nested_trait : Error<
15981601
"nested OpenMP context selector contains duplicated trait '%0'"
15991602
" in selector '%1' and set '%2' with different score">;

clang/include/clang/Basic/arm_neon.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -964,11 +964,11 @@ def SLI_N : WInst<"vsli_n", "...I", "PlQPl", [ImmCheck<2, ImmCheckShiftLeft, 0>]
964964
// Right shift narrow high
965965
def SHRN_HIGH_N : IOpInst<"vshrn_high_n", "<(<q).I",
966966
"HsHiHlHUsHUiHUl", OP_NARROW_HI>;
967-
def QSHRUN_HIGH_N : SOpInst<"vqshrun_high_n", "<(<q).I",
967+
def QSHRUN_HIGH_N : SOpInst<"vqshrun_high_n", "(<U)(<Uq).I",
968968
"HsHiHl", OP_NARROW_HI>;
969969
def RSHRN_HIGH_N : IOpInst<"vrshrn_high_n", "<(<q).I",
970970
"HsHiHlHUsHUiHUl", OP_NARROW_HI>;
971-
def QRSHRUN_HIGH_N : SOpInst<"vqrshrun_high_n", "<(<q).I",
971+
def QRSHRUN_HIGH_N : SOpInst<"vqrshrun_high_n", "(<U)(<Uq).I",
972972
"HsHiHl", OP_NARROW_HI>;
973973
def QSHRN_HIGH_N : SOpInst<"vqshrn_high_n", "<(<q).I",
974974
"HsHiHlHUsHUiHUl", OP_NARROW_HI>;

clang/include/clang/CIR/Dialect/IR/CIROps.td

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ def CIR_CastKind : CIR_I32EnumAttr<"CastKind", "cast kind", [
128128
// CK_BlockPointerToObjCPointerCast
129129
// CK_AnyPointerToBlockPointerCast
130130
// CK_ObjCObjectLValueCast
131-
// I32EnumAttrCase<"float_to_complex", 44>,
132-
// I32EnumAttrCase<"float_complex_to_real", 45>,
133-
// I32EnumAttrCase<"float_complex_to_bool", 46>,
131+
I32EnumAttrCase<"float_to_complex", 44>,
132+
I32EnumAttrCase<"float_complex_to_real", 45>,
133+
I32EnumAttrCase<"float_complex_to_bool", 46>,
134134
I32EnumAttrCase<"float_complex", 47>,
135-
// I32EnumAttrCase<"float_complex_to_int_complex", 48>,
136-
// I32EnumAttrCase<"int_to_complex", 49>,
135+
I32EnumAttrCase<"float_complex_to_int_complex", 48>,
136+
I32EnumAttrCase<"int_to_complex", 49>,
137137
I32EnumAttrCase<"int_complex_to_real", 50>,
138138
I32EnumAttrCase<"int_complex_to_bool", 51>,
139139
I32EnumAttrCase<"int_complex", 52>,

clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp

Lines changed: 148 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,20 @@ class ComplexExprEmitter : public StmtVisitor<ComplexExprEmitter, mlir::Value> {
3434
}
3535

3636
mlir::Value emitLoadOfLValue(LValue lv, SourceLocation loc);
37+
3738
/// Store the specified real/imag parts into the
3839
/// specified value pointer.
3940
void emitStoreOfComplex(mlir::Location loc, mlir::Value val, LValue lv,
4041
bool isInit);
4142

43+
/// Emit a cast from complex value Val to DestType.
44+
mlir::Value emitComplexToComplexCast(mlir::Value value, QualType srcType,
45+
QualType destType, SourceLocation loc);
46+
47+
/// Emit a cast from scalar value Val to DestType.
48+
mlir::Value emitScalarToComplexCast(mlir::Value value, QualType srcType,
49+
QualType destType, SourceLocation loc);
50+
4251
mlir::Value
4352
VisitAbstractConditionalOperator(const AbstractConditionalOperator *e);
4453
mlir::Value VisitArraySubscriptExpr(Expr *e);
@@ -164,14 +173,106 @@ LValue ComplexExprEmitter::emitBinAssignLValue(const BinaryOperator *e,
164173
mlir::Value ComplexExprEmitter::emitCast(CastKind ck, Expr *op,
165174
QualType destTy) {
166175
switch (ck) {
176+
case CK_Dependent:
177+
llvm_unreachable("dependent type must be resolved before the CIR codegen");
178+
167179
case CK_NoOp:
168180
case CK_LValueToRValue:
169181
return Visit(op);
170-
default:
171-
break;
182+
183+
case CK_AtomicToNonAtomic:
184+
case CK_NonAtomicToAtomic:
185+
case CK_UserDefinedConversion: {
186+
cgf.cgm.errorNYI(
187+
"ComplexExprEmitter::emitCast Atmoic & UserDefinedConversion");
188+
return {};
172189
}
173-
cgf.cgm.errorNYI("ComplexType Cast");
174-
return {};
190+
191+
case CK_LValueBitCast: {
192+
cgf.cgm.errorNYI("ComplexExprEmitter::emitCast CK_LValueBitCast");
193+
return {};
194+
}
195+
196+
case CK_LValueToRValueBitCast: {
197+
cgf.cgm.errorNYI("ComplexExprEmitter::emitCast CK_LValueToRValueBitCast");
198+
return {};
199+
}
200+
201+
case CK_BitCast:
202+
case CK_BaseToDerived:
203+
case CK_DerivedToBase:
204+
case CK_UncheckedDerivedToBase:
205+
case CK_Dynamic:
206+
case CK_ToUnion:
207+
case CK_ArrayToPointerDecay:
208+
case CK_FunctionToPointerDecay:
209+
case CK_NullToPointer:
210+
case CK_NullToMemberPointer:
211+
case CK_BaseToDerivedMemberPointer:
212+
case CK_DerivedToBaseMemberPointer:
213+
case CK_MemberPointerToBoolean:
214+
case CK_ReinterpretMemberPointer:
215+
case CK_ConstructorConversion:
216+
case CK_IntegralToPointer:
217+
case CK_PointerToIntegral:
218+
case CK_PointerToBoolean:
219+
case CK_ToVoid:
220+
case CK_VectorSplat:
221+
case CK_IntegralCast:
222+
case CK_BooleanToSignedIntegral:
223+
case CK_IntegralToBoolean:
224+
case CK_IntegralToFloating:
225+
case CK_FloatingToIntegral:
226+
case CK_FloatingToBoolean:
227+
case CK_FloatingCast:
228+
case CK_CPointerToObjCPointerCast:
229+
case CK_BlockPointerToObjCPointerCast:
230+
case CK_AnyPointerToBlockPointerCast:
231+
case CK_ObjCObjectLValueCast:
232+
case CK_FloatingComplexToReal:
233+
case CK_FloatingComplexToBoolean:
234+
case CK_IntegralComplexToReal:
235+
case CK_IntegralComplexToBoolean:
236+
case CK_ARCProduceObject:
237+
case CK_ARCConsumeObject:
238+
case CK_ARCReclaimReturnedObject:
239+
case CK_ARCExtendBlockObject:
240+
case CK_CopyAndAutoreleaseBlockObject:
241+
case CK_BuiltinFnToFnPtr:
242+
case CK_ZeroToOCLOpaqueType:
243+
case CK_AddressSpaceConversion:
244+
case CK_IntToOCLSampler:
245+
case CK_FloatingToFixedPoint:
246+
case CK_FixedPointToFloating:
247+
case CK_FixedPointCast:
248+
case CK_FixedPointToBoolean:
249+
case CK_FixedPointToIntegral:
250+
case CK_IntegralToFixedPoint:
251+
case CK_MatrixCast:
252+
case CK_HLSLVectorTruncation:
253+
case CK_HLSLArrayRValue:
254+
case CK_HLSLElementwiseCast:
255+
case CK_HLSLAggregateSplatCast:
256+
llvm_unreachable("invalid cast kind for complex value");
257+
258+
case CK_FloatingRealToComplex:
259+
case CK_IntegralRealToComplex: {
260+
assert(!cir::MissingFeatures::cgFPOptionsRAII());
261+
return emitScalarToComplexCast(cgf.emitScalarExpr(op), op->getType(),
262+
destTy, op->getExprLoc());
263+
}
264+
265+
case CK_FloatingComplexCast:
266+
case CK_FloatingComplexToIntegralComplex:
267+
case CK_IntegralComplexCast:
268+
case CK_IntegralComplexToFloatingComplex: {
269+
assert(!cir::MissingFeatures::cgFPOptionsRAII());
270+
return emitComplexToComplexCast(Visit(op), op->getType(), destTy,
271+
op->getExprLoc());
272+
}
273+
}
274+
275+
llvm_unreachable("unknown cast resulting in complex value");
175276
}
176277

177278
mlir::Value ComplexExprEmitter::emitConstant(
@@ -207,6 +308,49 @@ void ComplexExprEmitter::emitStoreOfComplex(mlir::Location loc, mlir::Value val,
207308
builder.createStore(loc, val, destAddr);
208309
}
209310

311+
mlir::Value ComplexExprEmitter::emitComplexToComplexCast(mlir::Value val,
312+
QualType srcType,
313+
QualType destType,
314+
SourceLocation loc) {
315+
if (srcType == destType)
316+
return val;
317+
318+
// Get the src/dest element type.
319+
QualType srcElemTy = srcType->castAs<ComplexType>()->getElementType();
320+
QualType destElemTy = destType->castAs<ComplexType>()->getElementType();
321+
322+
cir::CastKind castOpKind;
323+
if (srcElemTy->isFloatingType() && destElemTy->isFloatingType())
324+
castOpKind = cir::CastKind::float_complex;
325+
else if (srcElemTy->isFloatingType() && destElemTy->isIntegerType())
326+
castOpKind = cir::CastKind::float_complex_to_int_complex;
327+
else if (srcElemTy->isIntegerType() && destElemTy->isFloatingType())
328+
castOpKind = cir::CastKind::int_complex_to_float_complex;
329+
else if (srcElemTy->isIntegerType() && destElemTy->isIntegerType())
330+
castOpKind = cir::CastKind::int_complex;
331+
else
332+
llvm_unreachable("unexpected src type or dest type");
333+
334+
return builder.createCast(cgf.getLoc(loc), castOpKind, val,
335+
cgf.convertType(destType));
336+
}
337+
338+
mlir::Value ComplexExprEmitter::emitScalarToComplexCast(mlir::Value val,
339+
QualType srcType,
340+
QualType destType,
341+
SourceLocation loc) {
342+
cir::CastKind castOpKind;
343+
if (srcType->isFloatingType())
344+
castOpKind = cir::CastKind::float_to_complex;
345+
else if (srcType->isIntegerType())
346+
castOpKind = cir::CastKind::int_to_complex;
347+
else
348+
llvm_unreachable("unexpected src type");
349+
350+
return builder.createCast(cgf.getLoc(loc), castOpKind, val,
351+
cgf.convertType(destType));
352+
}
353+
210354
mlir::Value ComplexExprEmitter::VisitAbstractConditionalOperator(
211355
const AbstractConditionalOperator *e) {
212356
mlir::Value condValue = Visit(e->getCond());

0 commit comments

Comments
 (0)