-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir] Fix DistinctAttributeUniquer deleting attribute storage when crash reproduction is enabled #128566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
gysit
merged 10 commits into
llvm:main
from
graphcore:make-distinct-attr-printable-in-crash-reproducer
Mar 13, 2025
Merged
[mlir] Fix DistinctAttributeUniquer deleting attribute storage when crash reproduction is enabled #128566
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b4a909e
Use non thread-local allocator for DistinctAttr when threading is dis…
abulavin 55a7a38
fixup: Disabel threadlocal storage to handle multithreaded crash repr…
abulavin 8ace71b
fixup: add tests with multithreading enabled
abulavin d611dba
fixup: use disableMultiThreading in MLIRContext::disableMultiThreading
abulavin 3792201
fixup: use llvm::make_scope_exit instead of custom RAII guard
abulavin 68843d5
fixup: use MLIRContext* instead of auto*
abulavin 8baecc9
fixup: replace unreachable with clearer logic in allocate method
abulavin e7fd522
fixup: update outdated docs comments
abulavin 7fffb59
fixup: note that disabling threading implicitly disables thread-local…
abulavin da4e176
fixup: remove unused error handling header
abulavin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
mlir/test/Dialect/LLVMIR/add-debuginfo-func-scope-with-crash-reproduction.mlir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Test that the enable-debug-info-scope-on-llvm-func pass can create its | ||
// distinct attributes when running in the crash reproducer thread. | ||
|
||
// RUN: mlir-opt --mlir-disable-threading --mlir-pass-pipeline-crash-reproducer=. \ | ||
// RUN: --pass-pipeline="builtin.module(ensure-debug-info-scope-on-llvm-func)" \ | ||
// RUN: --mlir-print-debuginfo %s | FileCheck %s | ||
|
||
// RUN: mlir-opt --mlir-pass-pipeline-crash-reproducer=. \ | ||
// RUN: --pass-pipeline="builtin.module(ensure-debug-info-scope-on-llvm-func)" \ | ||
// RUN: --mlir-print-debuginfo %s | FileCheck %s | ||
|
||
module { | ||
llvm.func @func_no_debug() { | ||
llvm.return loc(unknown) | ||
} loc(unknown) | ||
} loc(unknown) | ||
|
||
// CHECK-LABEL: llvm.func @func_no_debug() | ||
// CHECK: llvm.return loc(#loc | ||
// CHECK: loc(#loc[[LOC:[0-9]+]]) | ||
// CHECK: #di_compile_unit = #llvm.di_compile_unit<id = distinct[{{.*}}]<>, | ||
// CHECK: #di_subprogram = #llvm.di_subprogram<id = distinct[{{.*}}]<> |
18 changes: 18 additions & 0 deletions
18
mlir/test/IR/test-builtin-distinct-attrs-with-crash-reproduction.mlir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// This test verifies that when running with crash reproduction enabled, distinct | ||
// attribute storage is not allocated in thread-local storage. Since crash | ||
// reproduction runs the pass manager in a separate thread, using thread-local | ||
// storage for distinct attributes causes use-after-free errors once the thread | ||
// that runs the pass manager joins. | ||
|
||
// RUN: mlir-opt --mlir-disable-threading --mlir-pass-pipeline-crash-reproducer=. %s -test-distinct-attrs | FileCheck %s | ||
// RUN: mlir-opt --mlir-pass-pipeline-crash-reproducer=. %s -test-distinct-attrs | FileCheck %s | ||
|
||
// CHECK: #[[DIST0:.*]] = distinct[0]<42 : i32> | ||
// CHECK: #[[DIST1:.*]] = distinct[1]<42 : i32> | ||
#distinct = distinct[0]<42 : i32> | ||
|
||
// CHECK: @foo_1 | ||
func.func @foo_1() { | ||
// CHECK: "test.op"() {distinct.input = #[[DIST0]], distinct.output = #[[DIST1]]} | ||
"test.op"() {distinct.input = #distinct} : () -> () | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.