Skip to content

Commit bf9869d

Browse files
authored
merge main into amd-staging (llvm#1763)
2 parents 16a0f98 + d939e03 commit bf9869d

File tree

127 files changed

+11413
-1127
lines changed

Some content is hidden

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

127 files changed

+11413
-1127
lines changed

clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,19 +1577,21 @@ TEST(TypeHints, Aliased) {
15771577
}
15781578

15791579
TEST(TypeHints, CallingConvention) {
1580-
// Check that we don't crash for lambdas without a FunctionTypeLoc
1580+
// Check that we don't crash for lambdas with an annotation
15811581
// https://github.com/clangd/clangd/issues/2223
1582-
std::string Code = R"cpp(
1582+
Annotations Source(R"cpp(
15831583
void test() {
1584-
[]() __cdecl {};
1584+
[]($lambda[[)]]__cdecl {};
15851585
}
1586-
)cpp";
1587-
TestTU TU = TestTU::withCode(Code);
1586+
)cpp");
1587+
TestTU TU = TestTU::withCode(Source.code());
15881588
TU.ExtraArgs.push_back("--target=x86_64-w64-mingw32");
15891589
TU.PredefineMacros = true; // for the __cdecl
15901590
auto AST = TU.build();
15911591

1592-
EXPECT_THAT(hintsOfKind(AST, InlayHintKind::Type), IsEmpty());
1592+
EXPECT_THAT(
1593+
hintsOfKind(AST, InlayHintKind::Type),
1594+
ElementsAre(HintMatcher(ExpectedHint{"-> void", "lambda"}, Source)));
15931595
}
15941596

15951597
TEST(TypeHints, Decltype) {

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "")
1818
set(LLVM_ENABLE_LLD ON CACHE BOOL "")
1919
set(LLVM_ENABLE_LTO ON CACHE BOOL "")
2020
set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
21-
set(LLVM_ENABLE_PIC OFF CACHE BOOL "")
2221
set(LLVM_ENABLE_PLUGINS OFF CACHE BOOL "")
2322
set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
2423
set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "")

clang/include/clang/Basic/BuiltinHeaders.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
HEADER(NO_HEADER, nullptr)
15+
HEADER(ARMACLE_H, "arm_acle.h")
1516
HEADER(BLOCKS_H, "Blocks.h")
1617
HEADER(COMPLEX_H, "complex.h")
1718
HEADER(CTYPE_H, "ctype.h")

clang/include/clang/Basic/BuiltinsAArch64.def

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ BUILTIN(__builtin_arm_wfi, "v", "")
5050
BUILTIN(__builtin_arm_sev, "v", "")
5151
BUILTIN(__builtin_arm_sevl, "v", "")
5252
BUILTIN(__builtin_arm_chkfeat, "WUiWUi", "")
53+
TARGET_HEADER_BUILTIN(__yield, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
54+
TARGET_HEADER_BUILTIN(__wfe, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
55+
TARGET_HEADER_BUILTIN(__wfi, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
56+
TARGET_HEADER_BUILTIN(__sev, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
57+
TARGET_HEADER_BUILTIN(__sevl, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
5358

5459
// Like __builtin_trap but provide an 16-bit immediate reason code (which goes into `brk #N`).
5560
BUILTIN(__builtin_arm_trap, "vUIs", "nr")
@@ -82,6 +87,9 @@ TARGET_BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "", "mte,mops")
8287
BUILTIN(__builtin_arm_dmb, "vUi", "nc")
8388
BUILTIN(__builtin_arm_dsb, "vUi", "nc")
8489
BUILTIN(__builtin_arm_isb, "vUi", "nc")
90+
TARGET_HEADER_BUILTIN(__dmb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
91+
TARGET_HEADER_BUILTIN(__dsb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
92+
TARGET_HEADER_BUILTIN(__isb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
8593

8694
TARGET_BUILTIN(__builtin_arm_jcvt, "Zid", "nc", "v8.3a")
8795

@@ -98,16 +106,6 @@ BUILTIN(__builtin_arm_wsr64, "vcC*WUi", "nc")
98106
TARGET_BUILTIN(__builtin_arm_wsr128, "vcC*LLLUi", "nc", "d128")
99107
BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
100108

101-
// MSVC
102-
LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
103-
LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
104-
LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
105-
LANGBUILTIN(__yield, "v", "", ALL_MS_LANGUAGES)
106-
LANGBUILTIN(__wfe, "v", "", ALL_MS_LANGUAGES)
107-
LANGBUILTIN(__wfi, "v", "", ALL_MS_LANGUAGES)
108-
LANGBUILTIN(__sev, "v", "", ALL_MS_LANGUAGES)
109-
LANGBUILTIN(__sevl, "v", "", ALL_MS_LANGUAGES)
110-
111109
// Misc
112110
BUILTIN(__builtin_sponentry, "v*", "c")
113111

clang/include/clang/Basic/BuiltinsARM.def

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,19 @@ BUILTIN(__builtin_arm_wfi, "v", "")
186186
BUILTIN(__builtin_arm_sev, "v", "")
187187
BUILTIN(__builtin_arm_sevl, "v", "")
188188
BUILTIN(__builtin_arm_dbg, "vUi", "")
189+
TARGET_HEADER_BUILTIN(__yield, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
190+
TARGET_HEADER_BUILTIN(__wfe, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
191+
TARGET_HEADER_BUILTIN(__wfi, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
192+
TARGET_HEADER_BUILTIN(__sev, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
193+
TARGET_HEADER_BUILTIN(__sevl, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
189194

190195
// Data barrier
191196
BUILTIN(__builtin_arm_dmb, "vUi", "nc")
192197
BUILTIN(__builtin_arm_dsb, "vUi", "nc")
193198
BUILTIN(__builtin_arm_isb, "vUi", "nc")
199+
TARGET_HEADER_BUILTIN(__dmb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
200+
TARGET_HEADER_BUILTIN(__dsb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
201+
TARGET_HEADER_BUILTIN(__isb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
194202

195203
// Prefetch
196204
BUILTIN(__builtin_arm_prefetch, "vvC*UiUi", "nc")
@@ -209,15 +217,6 @@ BUILTIN(__builtin_sponentry, "v*", "c")
209217
// MSVC
210218
LANGBUILTIN(__emit, "vIUiC", "", ALL_MS_LANGUAGES)
211219

212-
LANGBUILTIN(__yield, "v", "", ALL_MS_LANGUAGES)
213-
LANGBUILTIN(__wfe, "v", "", ALL_MS_LANGUAGES)
214-
LANGBUILTIN(__wfi, "v", "", ALL_MS_LANGUAGES)
215-
LANGBUILTIN(__sev, "v", "", ALL_MS_LANGUAGES)
216-
LANGBUILTIN(__sevl, "v", "", ALL_MS_LANGUAGES)
217-
218-
LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
219-
LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
220-
LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
221220
LANGBUILTIN(__ldrexd, "WiWiCD*", "", ALL_MS_LANGUAGES)
222221
LANGBUILTIN(_MoveFromCoprocessor, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)
223222
LANGBUILTIN(_MoveFromCoprocessor2, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)

clang/lib/AST/Decl.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3910,8 +3910,25 @@ bool FunctionDecl::doesDeclarationForceExternallyVisibleDefinition() const {
39103910

39113911
FunctionTypeLoc FunctionDecl::getFunctionTypeLoc() const {
39123912
const TypeSourceInfo *TSI = getTypeSourceInfo();
3913-
return TSI ? TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>()
3914-
: FunctionTypeLoc();
3913+
3914+
if (!TSI)
3915+
return FunctionTypeLoc();
3916+
3917+
TypeLoc TL = TSI->getTypeLoc();
3918+
FunctionTypeLoc FTL;
3919+
3920+
while (!(FTL = TL.getAs<FunctionTypeLoc>())) {
3921+
if (const auto PTL = TL.getAs<ParenTypeLoc>())
3922+
TL = PTL.getInnerLoc();
3923+
else if (const auto ATL = TL.getAs<AttributedTypeLoc>())
3924+
TL = ATL.getEquivalentTypeLoc();
3925+
else if (const auto MQTL = TL.getAs<MacroQualifiedTypeLoc>())
3926+
TL = MQTL.getInnerLoc();
3927+
else
3928+
break;
3929+
}
3930+
3931+
return FTL;
39153932
}
39163933

39173934
SourceRange FunctionDecl::getReturnTypeSourceRange() const {

clang/lib/AST/RecordLayoutBuilder.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
15391539
uint64_t StorageUnitSize = FieldInfo.Width;
15401540
unsigned FieldAlign = FieldInfo.Align;
15411541
bool AlignIsRequired = FieldInfo.isAlignRequired();
1542+
unsigned char PaddingInLastUnit = 0;
15421543

15431544
// UnfilledBitsInLastUnit is the difference between the end of the
15441545
// last allocated bitfield (i.e. the first bit offset available for
@@ -1611,6 +1612,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
16111612
if (!LastBitfieldStorageUnitSize && !FieldSize)
16121613
FieldAlign = 1;
16131614

1615+
PaddingInLastUnit = UnfilledBitsInLastUnit;
16141616
UnfilledBitsInLastUnit = 0;
16151617
LastBitfieldStorageUnitSize = 0;
16161618
}
@@ -1707,7 +1709,7 @@ void ItaniumRecordLayoutBuilder::LayoutBitField(const FieldDecl *D) {
17071709
// For purposes of diagnostics, we're going to simultaneously
17081710
// compute the field offsets that we would have used if we weren't
17091711
// adding any alignment padding or if the field weren't packed.
1710-
uint64_t UnpaddedFieldOffset = FieldOffset;
1712+
uint64_t UnpaddedFieldOffset = FieldOffset - PaddingInLastUnit;
17111713
uint64_t UnpackedFieldOffset = FieldOffset;
17121714

17131715
// Check if we need to add padding to fit the bitfield within an

clang/lib/CIR/CodeGen/CIRGenStmtOpenACC.cpp

Lines changed: 69 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,56 @@ class OpenACCClauseCIREmitter final
8282
return conversionOp.getResult(0);
8383
}
8484

85+
mlir::acc::DeviceType decodeDeviceType(const IdentifierInfo *ii) {
86+
// '*' case leaves no identifier-info, just a nullptr.
87+
if (!ii)
88+
return mlir::acc::DeviceType::Star;
89+
return llvm::StringSwitch<mlir::acc::DeviceType>(ii->getName())
90+
.CaseLower("default", mlir::acc::DeviceType::Default)
91+
.CaseLower("host", mlir::acc::DeviceType::Host)
92+
.CaseLower("multicore", mlir::acc::DeviceType::Multicore)
93+
.CasesLower("nvidia", "acc_device_nvidia",
94+
mlir::acc::DeviceType::Nvidia)
95+
.CaseLower("radeon", mlir::acc::DeviceType::Radeon);
96+
}
97+
98+
// Handle a clause affected by the 'device-type' to the point that they need
99+
// to have the attributes added in the correct/corresponding order, such as
100+
// 'num_workers' or 'vector_length' on a compute construct.
101+
mlir::ArrayAttr
102+
handleDeviceTypeAffectedClause(mlir::ArrayAttr existingDeviceTypes,
103+
mlir::Value argument,
104+
mlir::MutableOperandRange &argCollection) {
105+
llvm::SmallVector<mlir::Attribute> deviceTypes;
106+
107+
// Collect the 'existing' device-type attributes so we can re-create them
108+
// and insert them.
109+
if (existingDeviceTypes) {
110+
for (const mlir::Attribute &Attr : existingDeviceTypes)
111+
deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
112+
builder.getContext(),
113+
cast<mlir::acc::DeviceTypeAttr>(Attr).getValue()));
114+
}
115+
116+
// Insert 1 version of the 'expr' to the NumWorkers list per-current
117+
// device type.
118+
if (lastDeviceTypeClause) {
119+
for (const DeviceTypeArgument &arch :
120+
lastDeviceTypeClause->getArchitectures()) {
121+
deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
122+
builder.getContext(), decodeDeviceType(arch.getIdentifierInfo())));
123+
argCollection.append(argument);
124+
}
125+
} else {
126+
// Else, we just add a single for 'none'.
127+
deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
128+
builder.getContext(), mlir::acc::DeviceType::None));
129+
argCollection.append(argument);
130+
}
131+
132+
return mlir::ArrayAttr::get(builder.getContext(), deviceTypes);
133+
}
134+
85135
public:
86136
OpenACCClauseCIREmitter(OpTy &operation, CIRGenFunction &cgf,
87137
CIRGenBuilderTy &builder,
@@ -112,19 +162,6 @@ class OpenACCClauseCIREmitter final
112162
}
113163
}
114164

115-
mlir::acc::DeviceType decodeDeviceType(const IdentifierInfo *ii) {
116-
// '*' case leaves no identifier-info, just a nullptr.
117-
if (!ii)
118-
return mlir::acc::DeviceType::Star;
119-
return llvm::StringSwitch<mlir::acc::DeviceType>(ii->getName())
120-
.CaseLower("default", mlir::acc::DeviceType::Default)
121-
.CaseLower("host", mlir::acc::DeviceType::Host)
122-
.CaseLower("multicore", mlir::acc::DeviceType::Multicore)
123-
.CasesLower("nvidia", "acc_device_nvidia",
124-
mlir::acc::DeviceType::Nvidia)
125-
.CaseLower("radeon", mlir::acc::DeviceType::Radeon);
126-
}
127-
128165
void VisitDeviceTypeClause(const OpenACCDeviceTypeClause &clause) {
129166
lastDeviceTypeClause = &clause;
130167
if constexpr (isOneOfTypes<OpTy, InitOp, ShutdownOp>) {
@@ -134,10 +171,10 @@ class OpenACCClauseCIREmitter final
134171

135172
// Ensure we keep the existing ones, and in the correct 'new' order.
136173
if (existingDeviceTypes) {
137-
for (mlir::Attribute Attr : *existingDeviceTypes)
174+
for (mlir::Attribute attr : *existingDeviceTypes)
138175
deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
139176
builder.getContext(),
140-
cast<mlir::acc::DeviceTypeAttr>(Attr).getValue()));
177+
cast<mlir::acc::DeviceTypeAttr>(attr).getValue()));
141178
}
142179

143180
for (const DeviceTypeArgument &arg : clause.getArchitectures()) {
@@ -165,45 +202,30 @@ class OpenACCClauseCIREmitter final
165202

166203
void VisitNumWorkersClause(const OpenACCNumWorkersClause &clause) {
167204
if constexpr (isOneOfTypes<OpTy, ParallelOp, KernelsOp>) {
168-
// Collect the 'existing' device-type attributes so we can re-create them
169-
// and insert them.
170-
llvm::SmallVector<mlir::Attribute> deviceTypes;
171-
mlir::ArrayAttr existingDeviceTypes =
172-
operation.getNumWorkersDeviceTypeAttr();
173-
174-
if (existingDeviceTypes) {
175-
for (mlir::Attribute Attr : existingDeviceTypes)
176-
deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
177-
builder.getContext(),
178-
cast<mlir::acc::DeviceTypeAttr>(Attr).getValue()));
179-
}
180-
181-
// Insert 1 version of the 'int-expr' to the NumWorkers list per-current
182-
// device type.
183-
mlir::Value intExpr = createIntExpr(clause.getIntExpr());
184-
if (lastDeviceTypeClause) {
185-
for (const DeviceTypeArgument &arg :
186-
lastDeviceTypeClause->getArchitectures()) {
187-
deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
188-
builder.getContext(), decodeDeviceType(arg.getIdentifierInfo())));
189-
operation.getNumWorkersMutable().append(intExpr);
190-
}
191-
} else {
192-
// Else, we just add a single for 'none'.
193-
deviceTypes.push_back(mlir::acc::DeviceTypeAttr::get(
194-
builder.getContext(), mlir::acc::DeviceType::None));
195-
operation.getNumWorkersMutable().append(intExpr);
196-
}
197-
198-
operation.setNumWorkersDeviceTypeAttr(
199-
mlir::ArrayAttr::get(builder.getContext(), deviceTypes));
205+
mlir::MutableOperandRange range = operation.getNumWorkersMutable();
206+
operation.setNumWorkersDeviceTypeAttr(handleDeviceTypeAffectedClause(
207+
operation.getNumWorkersDeviceTypeAttr(),
208+
createIntExpr(clause.getIntExpr()), range));
200209
} else if constexpr (isOneOfTypes<OpTy, SerialOp>) {
201210
llvm_unreachable("num_workers not valid on serial");
202211
} else {
203212
return clauseNotImplemented(clause);
204213
}
205214
}
206215

216+
void VisitVectorLengthClause(const OpenACCVectorLengthClause &clause) {
217+
if constexpr (isOneOfTypes<OpTy, ParallelOp, KernelsOp>) {
218+
mlir::MutableOperandRange range = operation.getVectorLengthMutable();
219+
operation.setVectorLengthDeviceTypeAttr(handleDeviceTypeAffectedClause(
220+
operation.getVectorLengthDeviceTypeAttr(),
221+
createIntExpr(clause.getIntExpr()), range));
222+
} else if constexpr (isOneOfTypes<OpTy, SerialOp>) {
223+
llvm_unreachable("vector_length not valid on serial");
224+
} else {
225+
return clauseNotImplemented(clause);
226+
}
227+
}
228+
207229
void VisitSelfClause(const OpenACCSelfClause &clause) {
208230
if constexpr (isOneOfTypes<OpTy, ParallelOp, SerialOp, KernelsOp>) {
209231
if (clause.isEmptySelfClause()) {

clang/lib/CodeGen/Targets/DirectX.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ llvm::Type *DirectXTargetCodeGenInfo::getHLSLType(
5252
return nullptr;
5353

5454
// convert element type
55-
llvm::Type *ElemType = CGM.getTypes().ConvertType(ContainedTy);
55+
llvm::Type *ElemType = CGM.getTypes().ConvertTypeForMem(ContainedTy);
5656

5757
llvm::StringRef TypeName =
5858
ResAttrs.RawBuffer ? "dx.RawBuffer" : "dx.TypedBuffer";

clang/lib/Headers/arm_acle.h

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -29,47 +29,16 @@ extern "C" {
2929

3030
/* 7 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */
3131
/* 7.3 Memory barriers */
32-
#if !__has_builtin(__dmb)
33-
#define __dmb(i) __builtin_arm_dmb(i)
34-
#endif
35-
#if !__has_builtin(__dsb)
36-
#define __dsb(i) __builtin_arm_dsb(i)
37-
#endif
38-
#if !__has_builtin(__isb)
39-
#define __isb(i) __builtin_arm_isb(i)
40-
#endif
32+
void __dmb(unsigned int);
33+
void __dsb(unsigned int);
34+
void __isb(unsigned int);
4135

4236
/* 7.4 Hints */
43-
44-
#if !__has_builtin(__wfi)
45-
static __inline__ void __attribute__((__always_inline__, __nodebug__)) __wfi(void) {
46-
__builtin_arm_wfi();
47-
}
48-
#endif
49-
50-
#if !__has_builtin(__wfe)
51-
static __inline__ void __attribute__((__always_inline__, __nodebug__)) __wfe(void) {
52-
__builtin_arm_wfe();
53-
}
54-
#endif
55-
56-
#if !__has_builtin(__sev)
57-
static __inline__ void __attribute__((__always_inline__, __nodebug__)) __sev(void) {
58-
__builtin_arm_sev();
59-
}
60-
#endif
61-
62-
#if !__has_builtin(__sevl)
63-
static __inline__ void __attribute__((__always_inline__, __nodebug__)) __sevl(void) {
64-
__builtin_arm_sevl();
65-
}
66-
#endif
67-
68-
#if !__has_builtin(__yield)
69-
static __inline__ void __attribute__((__always_inline__, __nodebug__)) __yield(void) {
70-
__builtin_arm_yield();
71-
}
72-
#endif
37+
void __wfi(void);
38+
void __wfe(void);
39+
void __sev(void);
40+
void __sevl(void);
41+
void __yield(void);
7342

7443
#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE
7544
#define __dbg(t) __builtin_arm_dbg(t)

0 commit comments

Comments
 (0)