Skip to content

Commit 4bb5f59

Browse files
authored
Merge branch 'main' into fix-deadlock-modules
2 parents b1ae0f7 + dc71831 commit 4bb5f59

File tree

37 files changed

+1013
-44
lines changed

37 files changed

+1013
-44
lines changed

clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ auto nulloptTypeDecl() {
241241
auto hasNulloptType() { return hasType(nulloptTypeDecl()); }
242242

243243
auto inPlaceClass() {
244-
return recordDecl(hasAnyName("std::in_place_t", "absl::in_place_t",
245-
"base::in_place_t", "folly::in_place_t",
246-
"bsl::in_place_t"));
244+
return namedDecl(hasAnyName("std::in_place_t", "absl::in_place_t",
245+
"base::in_place_t", "folly::in_place_t",
246+
"bsl::in_place_t"));
247247
}
248248

249249
auto isOptionalNulloptConstructor() {

clang/unittests/Analysis/FlowSensitive/MockHeaders.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,10 @@ struct is_scalar
459459
template <>
460460
struct is_scalar<nullptr_t> : public true_type {};
461461
462+
struct in_place_t {};
463+
464+
constexpr in_place_t in_place;
465+
462466
} // namespace std
463467
464468
#endif // STD_TYPE_TRAITS_H
@@ -511,9 +515,8 @@ using remove_reference_t = typename std::remove_reference<T>::type;
511515
template <typename T>
512516
using decay_t = typename std::decay<T>::type;
513517
514-
struct in_place_t {};
515-
516-
constexpr in_place_t in_place;
518+
using std::in_place;
519+
using std::in_place_t;
517520
} // namespace absl
518521
519522
#endif // ABSL_TYPE_TRAITS_H
@@ -589,9 +592,6 @@ static constexpr char StdOptionalHeader[] = R"(
589592
590593
namespace std {
591594
592-
struct in_place_t {};
593-
constexpr in_place_t in_place;
594-
595595
struct nullopt_t {
596596
constexpr explicit nullopt_t() {}
597597
};

flang-rt/lib/cuda/kernel.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ void RTDEF(CUFLaunchKernel)(const void *kernel, intptr_t gridX, intptr_t gridY,
2323
gridDim.y = gridY;
2424
gridDim.z = gridZ;
2525
dim3 blockDim;
26-
blockDim.x = blockX;
27-
blockDim.y = blockY;
28-
blockDim.z = blockZ;
26+
blockDim.x = blockX > 1024 ? 1024 : blockX;
27+
blockDim.y = blockY > 1024 ? 1024 : blockY;
28+
blockDim.z = blockZ > 64 ? 64 : blockZ;
2929
unsigned nbNegGridDim{0};
3030
if (gridX < 0) {
3131
++nbNegGridDim;
@@ -88,9 +88,9 @@ void RTDEF(CUFLaunchClusterKernel)(const void *kernel, intptr_t clusterX,
8888
config.gridDim.x = gridX;
8989
config.gridDim.y = gridY;
9090
config.gridDim.z = gridZ;
91-
config.blockDim.x = blockX;
92-
config.blockDim.y = blockY;
93-
config.blockDim.z = blockZ;
91+
config.blockDim.x = blockX > 1024 ? 1024 : blockX;
92+
config.blockDim.y = blockY > 1024 ? 1024 : blockY;
93+
config.blockDim.z = blockZ > 64 ? 64 : blockZ;
9494
unsigned nbNegGridDim{0};
9595
if (gridX < 0) {
9696
++nbNegGridDim;
@@ -165,9 +165,9 @@ void RTDEF(CUFLaunchCooperativeKernel)(const void *kernel, intptr_t gridX,
165165
gridDim.y = gridY;
166166
gridDim.z = gridZ;
167167
dim3 blockDim;
168-
blockDim.x = blockX;
169-
blockDim.y = blockY;
170-
blockDim.z = blockZ;
168+
blockDim.x = blockX > 1024 ? 1024 : blockX;
169+
blockDim.y = blockY > 1024 ? 1024 : blockY;
170+
blockDim.z = blockZ > 64 ? 64 : blockZ;
171171
unsigned nbNegGridDim{0};
172172
if (gridX < 0) {
173173
++nbNegGridDim;

flang/lib/Optimizer/Builder/IntrinsicCall.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3516,11 +3516,23 @@ static mlir::Value getAddrFromBox(fir::FirOpBuilder &builder,
35163516
return addr;
35173517
}
35183518

3519+
static void clocDeviceArgRewrite(fir::ExtendedValue arg) {
3520+
// Special case for device address in c_loc.
3521+
if (auto emboxOp = mlir::dyn_cast_or_null<fir::EmboxOp>(
3522+
fir::getBase(arg).getDefiningOp()))
3523+
if (auto declareOp = mlir::dyn_cast_or_null<hlfir::DeclareOp>(
3524+
emboxOp.getMemref().getDefiningOp()))
3525+
if (declareOp.getDataAttr() &&
3526+
declareOp.getDataAttr() == cuf::DataAttribute::Device)
3527+
emboxOp.getMemrefMutable().assign(declareOp.getMemref());
3528+
}
3529+
35193530
static fir::ExtendedValue
35203531
genCLocOrCFunLoc(fir::FirOpBuilder &builder, mlir::Location loc,
35213532
mlir::Type resultType, llvm::ArrayRef<fir::ExtendedValue> args,
35223533
bool isFunc = false, bool isDevLoc = false) {
35233534
assert(args.size() == 1);
3535+
clocDeviceArgRewrite(args[0]);
35243536
mlir::Value res = fir::AllocaOp::create(builder, loc, resultType);
35253537
mlir::Value resAddr;
35263538
if (isDevLoc)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s
2+
3+
module symbols
4+
integer(4), device, target :: sdev(100)
5+
end module
6+
7+
subroutine sub1
8+
use iso_c_binding
9+
use symbols
10+
print*, c_loc(sdev)
11+
end subroutine
12+
13+
! CHECK-LABEL: func.func @_QPsub1()
14+
! CHECK: %[[ADDR:.*]] = fir.address_of(@_QMsymbolsEsdev) : !fir.ref<!fir.array<100xi32>>
15+
! CHECK: %[[EMBOX:.*]] = fir.embox %[[ADDR]](%{{.*}}) : (!fir.ref<!fir.array<100xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<100xi32>>
16+
! CHECK: %[[__ADDRESS:.*]] = fir.coordinate_of %{{.*}}, __address : (!fir.ref<!fir.type<_QM__fortran_builtinsT__builtin_c_ptr{__address:i64}>>) -> !fir.ref<i64>
17+
! CHECK: %[[BOX_ADDR:.*]] = fir.box_addr %[[EMBOX]] : (!fir.box<!fir.array<100xi32>>) -> !fir.ref<!fir.array<100xi32>>
18+
! CHECK: %[[CONV:.*]] = fir.convert %[[BOX_ADDR]] : (!fir.ref<!fir.array<100xi32>>) -> i64
19+
! CHECK: fir.store %[[CONV]] to %[[__ADDRESS]] : !fir.ref<i64>

libcxx/utils/compare-benchmarks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def plain_text_comparison(data, metric, baseline_name=None, candidate_name=None)
7272
geomean_0 = statistics.geometric_mean(data[f'{metric}_0'].dropna())
7373
geomean_1 = statistics.geometric_mean(data[f'{metric}_1'].dropna())
7474
geomean_row = ['Geomean', geomean_0, geomean_1, (geomean_1 - geomean_0), (geomean_1 - geomean_0) / geomean_0]
75-
table.loc[table.index.max()] = geomean_row
75+
table.loc[table.index.max() + 1] = geomean_row
7676

7777
return tabulate.tabulate(table.set_index('benchmark'), headers=headers, floatfmt=fmt, numalign='right')
7878

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CXX_SOURCES := main.cpp
2+
3+
include Makefile.rules
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
"""
2+
Test lldb-dap recieves invalidated-events when the area such as
3+
stack, variables, threads has changes but the client does not
4+
know about it.
5+
"""
6+
7+
import lldbdap_testcase
8+
from lldbsuite.test.lldbtest import line_number
9+
from dap_server import Event
10+
11+
12+
class TestDAP_invalidatedEvent(lldbdap_testcase.DAPTestCaseBase):
13+
def verify_top_frame_name(self, frame_name: str):
14+
all_frames = self.get_stackFrames()
15+
self.assertGreaterEqual(len(all_frames), 1, "Expected at least one frame.")
16+
top_frame_name = all_frames[0]["name"]
17+
self.assertRegex(top_frame_name, f"{frame_name}.*")
18+
19+
def test_invalidated_stack_area_event(self):
20+
"""
21+
Test an invalidated event for the stack area.
22+
The event is sent when the command `thread return <expr>` is sent by the user.
23+
"""
24+
other_source = "other.h"
25+
return_bp_line = line_number(other_source, "// thread return breakpoint")
26+
27+
program = self.getBuildArtifact("a.out")
28+
self.build_and_launch(program)
29+
self.set_source_breakpoints(other_source, [return_bp_line])
30+
self.continue_to_next_stop()
31+
32+
self.verify_top_frame_name("add")
33+
thread_id = self.dap_server.get_thread_id()
34+
self.assertIsNotNone(thread_id, "Exepected a thread id.")
35+
36+
# run thread return
37+
thread_command = "thread return 20"
38+
eval_resp = self.dap_server.request_evaluate(thread_command, context="repl")
39+
self.assertTrue(eval_resp["success"], f"Failed to evaluate `{thread_command}`.")
40+
41+
# wait for the invalidated stack event.
42+
stack_event = self.dap_server.wait_for_event(["invalidated"])
43+
self.assertIsNotNone(stack_event, "Expected an invalidated event.")
44+
event_body: Event = stack_event["body"]
45+
self.assertIn("stacks", event_body["areas"])
46+
self.assertIn("threadId", event_body.keys())
47+
self.assertEqual(
48+
thread_id,
49+
event_body["threadId"],
50+
f"Expected the event from thread {thread_id}.",
51+
)
52+
53+
# confirm we are back at the main frame.
54+
self.verify_top_frame_name("main")
55+
self.continue_to_exit()
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include "other.h"
2+
3+
int main() {
4+
int first = 5;
5+
int second = 10;
6+
const int result = add(first, second);
7+
8+
return 0;
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef OTHER_H
2+
#define OTHER_H
3+
4+
int add(int a, int b) {
5+
int first = a;
6+
int second = b; // thread return breakpoint
7+
int result = first + second;
8+
return result;
9+
}
10+
#endif // OTHER_H

0 commit comments

Comments
 (0)