Skip to content

Commit 8ea2ea1

Browse files
authored
Merge branch 'llvm:main' into shared-ptr
2 parents cbe532b + ff4faaa commit 8ea2ea1

File tree

73 files changed

+1684
-424
lines changed

Some content is hidden

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

73 files changed

+1684
-424
lines changed

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/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/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 =

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,

lldb/include/lldb/Core/IOHandler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ class IOHandler {
9090

9191
virtual void TerminalSizeChanged() {}
9292

93+
virtual void Refresh() {}
94+
9395
virtual const char *GetPrompt() {
9496
// Prompt support isn't mandatory
9597
return nullptr;
@@ -404,6 +406,8 @@ class IOHandlerEditline : public IOHandler {
404406

405407
void PrintAsync(const char *s, size_t len, bool is_stdout) override;
406408

409+
void Refresh() override;
410+
407411
private:
408412
#if LLDB_ENABLE_LIBEDIT
409413
bool IsInputCompleteCallback(Editline *editline, StringList &lines);

lldb/include/lldb/Host/Editline.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ class Editline {
267267

268268
size_t GetTerminalHeight() { return m_terminal_height; }
269269

270+
void Refresh();
271+
270272
private:
271273
/// Sets the lowest line number for multi-line editing sessions. A value of
272274
/// zero suppresses line number printing in the prompt.

lldb/source/Core/Debugger.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,13 @@ bool Debugger::PopIOHandler(const IOHandlerSP &pop_reader_sp) {
14451445
return true;
14461446
}
14471447

1448+
void Debugger::RefreshIOHandler() {
1449+
std::lock_guard<std::recursive_mutex> guard(m_io_handler_stack.GetMutex());
1450+
IOHandlerSP reader_sp(m_io_handler_stack.Top());
1451+
if (reader_sp)
1452+
reader_sp->Refresh();
1453+
}
1454+
14481455
StreamUP Debugger::GetAsyncOutputStream() {
14491456
return std::make_unique<StreamAsynchronousIO>(*this,
14501457
StreamAsynchronousIO::STDOUT);

0 commit comments

Comments
 (0)