Skip to content

Commit 105e6dd

Browse files
committed
guard reading as well
1 parent e5960dc commit 105e6dd

File tree

5 files changed

+16
-12
lines changed

5 files changed

+16
-12
lines changed

mlir/lib/Bindings/Python/Globals.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ class PyGlobals {
120120

121121
class TracebackLoc {
122122
public:
123-
bool locTracebacksEnabled() const;
123+
bool locTracebacksEnabled();
124124

125125
void setLocTracebacksEnabled(bool value);
126126

127-
size_t locTracebackFramesLimit() const;
127+
size_t locTracebackFramesLimit();
128128

129129
void setLocTracebackFramesLimit(size_t value);
130130

mlir/lib/Bindings/Python/IRModule.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ PyGlobals::lookupOperationClass(llvm::StringRef operationName) {
198198
return std::nullopt;
199199
}
200200

201-
bool PyGlobals::TracebackLoc::locTracebacksEnabled() const {
201+
bool PyGlobals::TracebackLoc::locTracebacksEnabled() {
202+
nanobind::ft_lock_guard lock(mutex);
202203
return locTracebackEnabled_;
203204
}
204205

@@ -207,7 +208,8 @@ void PyGlobals::TracebackLoc::setLocTracebacksEnabled(bool value) {
207208
locTracebackEnabled_ = value;
208209
}
209210

210-
size_t PyGlobals::TracebackLoc::locTracebackFramesLimit() const {
211+
size_t PyGlobals::TracebackLoc::locTracebackFramesLimit() {
212+
nanobind::ft_lock_guard lock(mutex);
211213
return locTracebackFramesLimit_;
212214
}
213215

mlir/test/python/ir/auto_location.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ def testInferLocations():
3434
two = arith.constant(IndexType.get(), 2)
3535

3636
# fmt: off
37-
# CHECK: loc(callsite("testInferLocations"("{{.*}}/test/python/ir/auto_location.py":31:13 to :43) at callsite("run"("{{.*}}/test/python/ir/auto_location.py":13:4 to :7) at "<module>"("{{.*}}/test/python/ir/auto_location.py":26:1 to :4))))
37+
# CHECK: loc(callsite("testInferLocations"("{{.*}}[[SEP:[/\\]]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":31:13 to :43) at callsite("run"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":13:4 to :7) at "<module>"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":26:1 to :4))))
3838
# fmt: on
3939
print(op.___location)
4040

4141
# fmt: off
42-
# CHECK: loc(callsite("ConstantOp.__init__"("{{.*}}/mlir/dialects/arith.py":65:12 to :76) at callsite("constant"("{{.*}}/mlir/dialects/arith.py":110:40 to :81) at callsite("testInferLocations"("{{.*}}/test/python/ir/auto_location.py":32:14 to :48) at callsite("run"("{{.*}}/test/python/ir/auto_location.py":13:4 to :7) at "<module>"("{{.*}}/test/python/ir/auto_location.py":26:1 to :4))))))
42+
# CHECK: loc(callsite("ConstantOp.__init__"("{{.*}}[[SEP]]mlir[[SEP]]dialects[[SEP]]arith.py":65:12 to :76) at callsite("constant"("{{.*}}[[SEP]]mlir[[SEP]]dialects[[SEP]]arith.py":110:40 to :81) at callsite("testInferLocations"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":32:14 to :48) at callsite("run"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":13:4 to :7) at "<module>"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":26:1 to :4))))))
4343
# fmt: on
4444
print(one.___location)
4545

4646
# fmt: off
47-
# CHECK: loc(callsite("testInferLocations"("{{.*}}/test/python/ir/auto_location.py":34:14 to :48) at callsite("run"("{{.*}}/test/python/ir/auto_location.py":13:4 to :7) at "<module>"("{{.*}}/test/python/ir/auto_location.py":26:1 to :4))))
47+
# CHECK: loc(callsite("testInferLocations"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":34:14 to :48) at callsite("run"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":13:4 to :7) at "<module>"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":26:1 to :4))))
4848
# fmt: on
4949
print(two.___location)
5050

5151
_cext.globals.register_traceback_file_inclusion(_arith_ops_gen.__file__)
5252
three = arith.constant(IndexType.get(), 3)
5353
# fmt: off
54-
# CHECK: loc(callsite("ConstantOp.__init__"("{{.*}}/mlir/dialects/_arith_ops_gen.py":405:4 to :218) at callsite("testInferLocations"("{{.*}}/test/python/ir/auto_location.py":52:16 to :50) at callsite("run"("{{.*}}/test/python/ir/auto_location.py":13:4 to :7) at "<module>"("{{.*}}/test/python/ir/auto_location.py":26:1 to :4)))))
54+
# CHECK: loc(callsite("ConstantOp.__init__"("{{.*}}[[SEP]]mlir[[SEP]]dialects[[SEP]]_arith_ops_gen.py":405:4 to :218) at callsite("testInferLocations"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":52:16 to :50) at callsite("run"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":13:4 to :7) at "<module>"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":26:1 to :4)))))
5555
# fmt: on
5656
print(three.___location)
5757

@@ -60,13 +60,13 @@ def foo():
6060
print(four.___location)
6161

6262
# fmt: off
63-
# CHECK: loc(callsite("ConstantOp.__init__"("{{.*}}/mlir/dialects/_arith_ops_gen.py":405:4 to :218) at callsite("testInferLocations.<locals>.foo"("{{.*}}/test/python/ir/auto_location.py":59:19 to :53) at callsite("testInferLocations"("{{.*}}/test/python/ir/auto_location.py":65:8 to :13) at callsite("run"("{{.*}}/test/python/ir/auto_location.py":13:4 to :7) at "<module>"("{{.*}}/test/python/ir/auto_location.py":26:1 to :4))))))
63+
# CHECK: loc(callsite("ConstantOp.__init__"("{{.*}}[[SEP]]mlir[[SEP]]dialects[[SEP]]_arith_ops_gen.py":405:4 to :218) at callsite("testInferLocations.<locals>.foo"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":59:19 to :53) at callsite("testInferLocations"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":65:8 to :13) at callsite("run"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":13:4 to :7) at "<module>"("{{.*}}[[SEP]]test[[SEP]]python[[SEP]]ir[[SEP]]auto_location.py":26:1 to :4))))))
6464
# fmt: on
6565
foo()
6666

6767
_cext.globals.register_traceback_file_exclusion(__file__)
6868

6969
# fmt: off
70-
# CHECK: loc("ConstantOp.__init__"("{{.*}}/mlir/dialects/_arith_ops_gen.py":405:4 to :218))
70+
# CHECK: loc("ConstantOp.__init__"("{{.*}}[[SEP]]mlir[[SEP]]dialects[[SEP]]_arith_ops_gen.py":405:4 to :218))
7171
# fmt: on
7272
foo()

mlir/test/python/ir/lit.local.cfg

Lines changed: 0 additions & 2 deletions
This file was deleted.

mlir/test/python/lit.local.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ config.environment["ASAN_OPTIONS"] = "detect_leaks=0"
22
if not config.enable_bindings_python:
33
config.unsupported = True
44
config.excludes.add("python_test_ops.td")
5+
6+
import sys
7+
if sys.version_info >= (3, 11):
8+
config.available_features.add("python-ge-311")

0 commit comments

Comments
 (0)