Skip to content

Commit bbe4357

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#2915)
2 parents d3cc259 + 4e1a978 commit bbe4357

File tree

94 files changed

+2930
-598
lines changed

Some content is hidden

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

94 files changed

+2930
-598
lines changed

clang/include/clang/Tooling/Transformer/Transformer.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ class TransformerImpl {
4242
virtual void
4343
onMatchImpl(const ast_matchers::MatchFinder::MatchResult &Result) = 0;
4444
};
45-
46-
// FIXME: Use std::type_identity or backport when available.
47-
template <class T> struct type_identity {
48-
using type = T;
49-
};
5045
} // namespace detail
5146

5247
template <typename T> struct TransformerResult {
@@ -95,8 +90,8 @@ class Transformer : public ast_matchers::MatchFinder::MatchCallback {
9590
template <typename MetadataT>
9691
explicit Transformer(
9792
transformer::RewriteRuleWith<MetadataT> Rule,
98-
std::function<void(llvm::Expected<TransformerResult<
99-
typename detail::type_identity<MetadataT>::type>>)>
93+
std::function<void(
94+
llvm::Expected<TransformerResult<llvm::type_identity_t<MetadataT>>>)>
10095
Consumer);
10196

10297
/// N.B. Passes `this` pointer to `MatchFinder`. So, this object should not
@@ -200,8 +195,8 @@ template <typename T> class WithMetadataImpl final : public TransformerImpl {
200195
template <typename MetadataT>
201196
Transformer::Transformer(
202197
transformer::RewriteRuleWith<MetadataT> Rule,
203-
std::function<void(llvm::Expected<TransformerResult<
204-
typename detail::type_identity<MetadataT>::type>>)>
198+
std::function<void(
199+
llvm::Expected<TransformerResult<llvm::type_identity_t<MetadataT>>>)>
205200
Consumer)
206201
: Impl(std::make_unique<detail::WithMetadataImpl<MetadataT>>(
207202
std::move(Rule), std::move(Consumer))) {}

clang/lib/CIR/CodeGen/CIRGenExprComplex.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ComplexExprEmitter : public StmtVisitor<ComplexExprEmitter, mlir::Value> {
4343
mlir::Value VisitCallExpr(const CallExpr *e);
4444
mlir::Value VisitChooseExpr(ChooseExpr *e);
4545
mlir::Value VisitDeclRefExpr(DeclRefExpr *e);
46+
mlir::Value VisitGenericSelectionExpr(GenericSelectionExpr *e);
4647
mlir::Value VisitImplicitCastExpr(ImplicitCastExpr *e);
4748
mlir::Value VisitInitListExpr(const InitListExpr *e);
4849
mlir::Value VisitImaginaryLiteral(const ImaginaryLiteral *il);
@@ -151,6 +152,11 @@ mlir::Value ComplexExprEmitter::VisitDeclRefExpr(DeclRefExpr *e) {
151152
return emitLoadOfLValue(e);
152153
}
153154

155+
mlir::Value
156+
ComplexExprEmitter::VisitGenericSelectionExpr(GenericSelectionExpr *e) {
157+
return Visit(e->getResultExpr());
158+
}
159+
154160
mlir::Value ComplexExprEmitter::VisitImplicitCastExpr(ImplicitCastExpr *e) {
155161
// Unlike for scalars, we don't have to worry about function->ptr demotion
156162
// here.

clang/test/CIR/CodeGen/complex.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,34 @@ bool foo19(double _Complex a, double _Complex b) {
442442
// OGCG: %[[CMP_IMAG:.*]] = fcmp oeq double %[[A_IMAG]], %[[B_IMAG]]
443443
// OGCG: %[[RESULT:.*]] = and i1 %[[CMP_REAL]], %[[CMP_IMAG]]
444444

445+
void foo23(int _Complex a, int _Complex b) {
446+
float _Complex f;
447+
int _Complex c = _Generic(a, int _Complex: b, default: f);
448+
}
449+
450+
// CIR: %[[COMPLEX_A:.*]] = cir.alloca !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>, ["a", init]
451+
// CIR: %[[COMPLEX_B:.*]] = cir.alloca !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>, ["b", init]
452+
// CIR: %[[COMPLEX_F:.*]] = cir.alloca !cir.complex<!cir.float>, !cir.ptr<!cir.complex<!cir.float>>, ["f"]
453+
// CIR: %[[RESULT:.*]] = cir.alloca !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>, ["c", init]
454+
// CIR: %[[TMP:.*]] = cir.load{{.*}} %[[COMPLEX_B]] : !cir.ptr<!cir.complex<!s32i>>, !cir.complex<!s32i>
455+
// CIR: cir.store{{.*}} %[[TMP]], %[[RESULT]] : !cir.complex<!s32i>, !cir.ptr<!cir.complex<!s32i>>
456+
457+
// LLVM: %[[COMPLEX_A:.*]] = alloca { i32, i32 }, i64 1, align 4
458+
// LLVM: %[[COMPLEX_B:.*]] = alloca { i32, i32 }, i64 1, align 4
459+
// LLVM: %[[COMPLEX_F:.*]] = alloca { float, float }, i64 1, align 4
460+
// LLVM: %[[RESULT:.*]] = alloca { i32, i32 }, i64 1, align 4
461+
// LLVM: %[[TMP:.*]] = load { i32, i32 }, ptr %[[COMPLEX_B]], align 4
462+
// LLVM: store { i32, i32 } %[[TMP]], ptr %[[RESULT]], align 4
463+
464+
// OGCG: %[[COMPLEX_A:.*]] = alloca { i32, i32 }, align 4
465+
// OGCG: %[[COMPLEX_B:.*]] = alloca { i32, i32 }, align 4
466+
// OGCG: %[[COMPLEX_F:.*]] = alloca { float, float }, align 4
467+
// OGCG: %[[RESULT:.*]] = alloca { i32, i32 }, align 4
468+
// OGCG: %[[B_REAL_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[COMPLEX_B]], i32 0, i32 0
469+
// OGCG: %[[B_REAL:.*]] = load i32, ptr %[[B_REAL_PTR]], align 4
470+
// OGCG: %[[B_IMAG_PTR:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[COMPLEX_B]], i32 0, i32 1
471+
// OGCG: %[[B_IMAG:.*]] = load i32, ptr %[[B_IMAG_PTR]], align 4
472+
// OGCG: %[[RESULT_REAL_PT:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[RESULT]], i32 0, i32 0
473+
// OGCG: %[[RESULT_IMAG_PT:.*]] = getelementptr inbounds nuw { i32, i32 }, ptr %[[RESULT]], i32 0, i32 1
474+
// OGCG: store i32 %[[B_REAL]], ptr %[[RESULT_REAL_PT]], align 4
475+
// OGCG: store i32 %[[B_IMAG]], ptr %[[RESULT_IMAG_PT]], align 4

flang/lib/Optimizer/OpenACC/FIROpenACCTypeInterfaces.cpp

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,10 @@ static bool isArrayLike(mlir::Type type) {
306306
}
307307

308308
static bool isCompositeLike(mlir::Type type) {
309+
// class(*) is not a composite type since it does not have a determined type.
310+
if (fir::isUnlimitedPolymorphicType(type))
311+
return false;
312+
309313
return mlir::isa<fir::RecordType, fir::ClassType, mlir::TupleType>(type);
310314
}
311315

@@ -320,8 +324,18 @@ template <>
320324
mlir::acc::VariableTypeCategory
321325
OpenACCMappableModel<fir::BaseBoxType>::getTypeCategory(mlir::Type type,
322326
mlir::Value var) const {
327+
// Class-type does not behave like a normal box because it does not hold an
328+
// element type. Thus special handle it here.
329+
if (mlir::isa<fir::ClassType>(type)) {
330+
// class(*) is not a composite type since it does not have a determined
331+
// type.
332+
if (fir::isUnlimitedPolymorphicType(type))
333+
return mlir::acc::VariableTypeCategory::uncategorized;
334+
return mlir::acc::VariableTypeCategory::composite;
335+
}
323336

324337
mlir::Type eleTy = fir::dyn_cast_ptrOrBoxEleTy(type);
338+
assert(eleTy && "expect to be able to unwrap the element type");
325339

326340
// If the type enclosed by the box is a mappable type, then have it
327341
// provide the type category.
@@ -346,7 +360,7 @@ OpenACCMappableModel<fir::BaseBoxType>::getTypeCategory(mlir::Type type,
346360
return mlir::acc::VariableTypeCategory::nonscalar;
347361
}
348362

349-
static mlir::TypedValue<mlir::acc::PointerLikeType>
363+
static mlir::Value
350364
getBaseRef(mlir::TypedValue<mlir::acc::PointerLikeType> varPtr) {
351365
// If there is no defining op - the unwrapped reference is the base one.
352366
mlir::Operation *op = varPtr.getDefiningOp();
@@ -372,7 +386,7 @@ getBaseRef(mlir::TypedValue<mlir::acc::PointerLikeType> varPtr) {
372386
})
373387
.Default([&](mlir::Operation *) { return varPtr; });
374388

375-
return mlir::cast<mlir::TypedValue<mlir::acc::PointerLikeType>>(baseRef);
389+
return baseRef;
376390
}
377391

378392
static mlir::acc::VariableTypeCategory
@@ -384,10 +398,17 @@ categorizePointee(mlir::Type pointer,
384398
// value would both be represented as !fir.ref<f32>. We do not want to treat
385399
// such a reference as a scalar. Thus unwrap interior pointer calculations.
386400
auto baseRef = getBaseRef(varPtr);
387-
mlir::Type eleTy = baseRef.getType().getElementType();
388401

389-
if (auto mappableTy = mlir::dyn_cast<mlir::acc::MappableType>(eleTy))
390-
return mappableTy.getTypeCategory(varPtr);
402+
if (auto mappableTy =
403+
mlir::dyn_cast<mlir::acc::MappableType>(baseRef.getType()))
404+
return mappableTy.getTypeCategory(baseRef);
405+
406+
// It must be a pointer-like type since it is not a MappableType.
407+
auto ptrLikeTy = mlir::cast<mlir::acc::PointerLikeType>(baseRef.getType());
408+
mlir::Type eleTy = ptrLikeTy.getElementType();
409+
410+
if (auto mappableEleTy = mlir::dyn_cast<mlir::acc::MappableType>(eleTy))
411+
return mappableEleTy.getTypeCategory(varPtr);
391412

392413
if (isScalarLike(eleTy))
393414
return mlir::acc::VariableTypeCategory::scalar;
@@ -397,8 +418,12 @@ categorizePointee(mlir::Type pointer,
397418
return mlir::acc::VariableTypeCategory::composite;
398419
if (mlir::isa<fir::CharacterType, mlir::FunctionType>(eleTy))
399420
return mlir::acc::VariableTypeCategory::nonscalar;
421+
// Assumed-type (type(*))does not have a determined type that can be
422+
// categorized.
423+
if (mlir::isa<mlir::NoneType>(eleTy))
424+
return mlir::acc::VariableTypeCategory::uncategorized;
400425
// "pointers" - in the sense of raw address point-of-view, are considered
401-
// scalars. However
426+
// scalars.
402427
if (mlir::isa<fir::LLVMPointerType>(eleTy))
403428
return mlir::acc::VariableTypeCategory::scalar;
404429

flang/lib/Optimizer/Transforms/CUFDeviceGlobal.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,16 @@ class CUFDeviceGlobal : public fir::impl::CUFDeviceGlobalBase<CUFDeviceGlobal> {
113113
return signalPassFailure();
114114
mlir::SymbolTable gpuSymTable(gpuMod);
115115
for (auto globalOp : mod.getOps<fir::GlobalOp>()) {
116-
if (cuf::isRegisteredDeviceGlobal(globalOp))
116+
if (cuf::isRegisteredDeviceGlobal(globalOp)) {
117117
candidates.insert(globalOp);
118+
} else if (globalOp.getConstant() &&
119+
mlir::isa<fir::SequenceType>(
120+
fir::unwrapRefType(globalOp.resultType()))) {
121+
mlir::Attribute initAttr =
122+
globalOp.getInitVal().value_or(mlir::Attribute());
123+
if (initAttr && mlir::dyn_cast<mlir::DenseElementsAttr>(initAttr))
124+
candidates.insert(globalOp);
125+
}
118126
}
119127
for (auto globalOp : candidates) {
120128
auto globalName{globalOp.getSymbol().getValue()};

flang/lib/Semantics/resolve-names.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7278,6 +7278,14 @@ bool DeclarationVisitor::PassesLocalityChecks(
72787278
specName);
72797279
return false;
72807280
}
7281+
if (const DerivedTypeSpec *derived{type->AsDerived()}) { // F'2023 C1130
7282+
if (auto bad{FindAllocatableUltimateComponent(*derived)}) {
7283+
SayWithDecl(name, symbol,
7284+
"Derived type variable '%s' with ultimate ALLOCATABLE component '%s' not allowed in a %s locality-spec"_err_en_US,
7285+
bad.BuildResultDesignatorName(), specName);
7286+
return false;
7287+
}
7288+
}
72817289
}
72827290
if (symbol.attrs().test(Attr::ASYNCHRONOUS) && isReduce) { // F'2023 C1131
72837291
SayWithDecl(name, symbol,

flang/test/Fir/CUDA/cuda-device-global.f90

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,16 @@ module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", gpu.conta
1111

1212
// CHECK: gpu.module @cuda_device_mo
1313
// CHECK-NEXT: fir.global @_QMmtestsEn(dense<[3, 4, 5, 6, 7]> : tensor<5xi32>) {data_attr = #cuf.cuda<device>} : !fir.array<5xi32>
14+
15+
// -----
16+
17+
module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", gpu.container_module} {
18+
fir.global @_QMm1ECb(dense<[90, 100, 110]> : tensor<3xi32>) constant : !fir.array<3xi32>
19+
fir.global @_QMm2ECc(dense<[100, 200, 300]> : tensor<3xi32>) constant : !fir.array<3xi32>
20+
}
21+
22+
// CHECK: fir.global @_QMm1ECb
23+
// CHECK: fir.global @_QMm2ECc
24+
// CHECK: gpu.module @cuda_device_mod
25+
// CHECK-DAG: fir.global @_QMm2ECc
26+
// CHECK-DAG: fir.global @_QMm1ECb
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
! RUN: bbc -fopenacc -emit-hlfir %s -o - | fir-opt -pass-pipeline='builtin.module(test-fir-openacc-interfaces)' --mlir-disable-threading 2>&1 | FileCheck %s
2+
3+
module mm
4+
type, public :: polyty
5+
real :: field
6+
end type
7+
contains
8+
subroutine init(this)
9+
class(polyty), intent(inout) :: this
10+
!$acc enter data copyin(this, this%field)
11+
end subroutine
12+
subroutine init_assumed_type(var)
13+
type(*), intent(inout) :: var
14+
!$acc enter data copyin(var)
15+
end subroutine
16+
subroutine init_unlimited(this)
17+
class(*), intent(inout) :: this
18+
!$acc enter data copyin(this)
19+
select type(this)
20+
type is(real)
21+
!$acc enter data copyin(this)
22+
class is(polyty)
23+
!$acc enter data copyin(this, this%field)
24+
end select
25+
end subroutine
26+
end module
27+
28+
! CHECK: Visiting: {{.*}} acc.copyin {{.*}} {name = "this", structured = false}
29+
! CHECK: Mappable: !fir.class<!fir.type<_QMmmTpolyty{field:f32}>>
30+
! CHECK: Type category: composite
31+
! CHECK: Visiting: {{.*}} acc.copyin {{.*}} {name = "this%field", structured = false}
32+
! CHECK: Pointer-like: !fir.ref<f32>
33+
! CHECK: Type category: composite
34+
35+
! For unlimited polymorphic entities and assumed types - they effectively have
36+
! no declared type. Thus the type categorizer cannot categorize it.
37+
! CHECK: Visiting: {{.*}} = acc.copyin {{.*}} {name = "var", structured = false}
38+
! CHECK: Pointer-like: !fir.ref<none>
39+
! CHECK: Type category: uncategorized
40+
! CHECK: Visiting: {{.*}} = acc.copyin {{.*}} {name = "this", structured = false}
41+
! CHECK: Mappable: !fir.class<none>
42+
! CHECK: Type category: uncategorized
43+
44+
! TODO: After using select type - the appropriate type category should be
45+
! possible. Add the rest of the test once OpenACC lowering correctly handles
46+
! unlimited polymorhic.

flang/test/Semantics/resolve55.f90

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,23 @@ subroutine s8(arg)
9494
do concurrent(i=1:5) local(arg)
9595
end do
9696
end subroutine s8
97+
98+
subroutine s9()
99+
type l3
100+
integer, allocatable :: a
101+
end type
102+
type l2
103+
type(l3) :: l2_3
104+
end type
105+
type l1
106+
type(l2) :: l1_2
107+
end type
108+
type(l1) :: v
109+
integer sum
110+
111+
sum = 0
112+
!ERROR: Derived type variable 'v' with ultimate ALLOCATABLE component '%l1_2%l2_3%a' not allowed in a LOCAL_INIT locality-spec
113+
do concurrent (i = 1:10) local_init(v)
114+
sum = sum + i
115+
end do
116+
end subroutine s9

flang/test/lib/OpenACC/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@ add_flang_library(FIRTestOpenACCInterfaces
22
TestOpenACCInterfaces.cpp
33

44
DEPENDS
5+
HLFIRDialect
56
FIRDialect
67
FIROpenACCSupport
78
FIRSupport
89

910
LINK_LIBS
11+
HLFIRDialect
1012
FIRDialect
1113
FIROpenACCSupport
1214
FIRSupport
1315

1416
MLIR_DEPS
17+
MLIRDLTIDialect
1518
MLIRIR
1619
MLIROpenACCDialect
1720
MLIRPass
1821
MLIRSupport
1922

2023
MLIR_LIBS
24+
MLIRDLTIDialect
2125
MLIRIR
2226
MLIROpenACCDialect
2327
MLIRPass

flang/test/lib/OpenACC/TestOpenACCInterfaces.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include "mlir/Dialect/Arith/IR/Arith.h"
10+
#include "mlir/Dialect/DLTI/DLTI.h"
911
#include "mlir/Dialect/OpenACC/OpenACC.h"
1012
#include "mlir/IR/Builders.h"
1113
#include "mlir/IR/BuiltinOps.h"
1214
#include "mlir/Pass/Pass.h"
1315
#include "mlir/Support/LLVM.h"
16+
#include "flang/Optimizer/Dialect/FIRDialect.h"
17+
#include "flang/Optimizer/HLFIR/HLFIRDialect.h"
1418
#include "flang/Optimizer/Support/DataLayout.h"
1519

1620
using namespace mlir;
@@ -25,6 +29,11 @@ struct TestFIROpenACCInterfaces
2529
StringRef getDescription() const final {
2630
return "Test FIR implementation of the OpenACC interfaces.";
2731
}
32+
void getDependentDialects(::mlir::DialectRegistry &registry) const override {
33+
registry.insert<fir::FIROpsDialect, hlfir::hlfirDialect,
34+
mlir::arith::ArithDialect, mlir::acc::OpenACCDialect,
35+
mlir::DLTIDialect>();
36+
}
2837
void runOnOperation() override {
2938
mlir::ModuleOp mod = getOperation();
3039
auto datalayout =

libc/src/wchar/wcpncpy.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ wchar_t *wcpncpy(wchar_t *__restrict ws1, const wchar_t *__restrict ws2,
2020

2121
} // namespace LIBC_NAMESPACE_DECL
2222

23-
#endif // LLVM_LIBC_SRC_WCHAR_WCPNsCPY_H
23+
#endif // LLVM_LIBC_SRC_WCHAR_WCPNCPY_H

libc/src/wchar/wcsspn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ size_t wcsspn(const wchar_t *s1, const wchar_t *s2);
1919

2020
} // namespace LIBC_NAMESPACE_DECL
2121

22-
#endif // LLVM_LIBC_SRC_WCHAR_WCSCHR_H
22+
#endif // LLVM_LIBC_SRC_WCHAR_WCSSPN_H

lldb/docs/use/mcp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ forward communication over stdio over the network connection.
4646
└──────────┘ └──────────┘ └──────────┘
4747
```
4848

49-
Configuration example for [Claude Code][https://modelcontextprotocol.io/quickstart/user]:
49+
Configuration example for [Claude Code](https://modelcontextprotocol.io/quickstart/user):
5050

5151
```json
5252
{
@@ -59,7 +59,7 @@ Configuration example for [Claude Code][https://modelcontextprotocol.io/quicksta
5959
}
6060
```
6161

62-
Configuration example for [Visual Studio Code][https://code.visualstudio.com/docs/copilot/chat/mcp-servers]:
62+
Configuration example for [Visual Studio Code](https://code.visualstudio.com/docs/copilot/chat/mcp-servers):
6363

6464
```json
6565
{

lldb/include/lldb/Core/Debugger.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ class Debugger : public std::enable_shared_from_this<Debugger>,
227227

228228
const char *GetIOHandlerHelpPrologue();
229229

230+
void RefreshIOHandler();
231+
230232
void ClearIOHandlers();
231233

232234
bool EnableLog(llvm::StringRef channel,

0 commit comments

Comments
 (0)