-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][LLVM] Fix recursive DI type export memory leak #88122
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
[MLIR][LLVM] Fix recursive DI type export memory leak #88122
Conversation
213d3d6
to
cf496c2
Compare
Can we ensure that get's landed soonish? While I understand the concern for about how to test this, it is probably better to land this and ship a test as a followup, given that this breaks production flows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
I think it makes sense to land this soonish since it fixes an upstream bug.
Sounds good. Let me fix the failures and land this then. |
cf496c2
to
2c2e9a2
Compare
OK turns out the test isn't too hard. Just had to make the previous nested recursive-decl test also use the nested decl again outside, which will die if it was cached to a temporary. |
@llvm/pr-subscribers-mlir-llvm @llvm/pr-subscribers-mlir Author: Billy Zhu (zyx-billy) ChangesFollowup to discussion #87295 (comment). The export cache should not cache temporary nodes. Full diff: https://github.com/llvm/llvm-project/pull/88122.diff 2 Files Affected:
diff --git a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
index 46e2e7f2ba5dc4..2de5e372d88c0e 100644
--- a/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/DebugTranslation.cpp
@@ -352,7 +352,8 @@ llvm::DINode *DebugTranslation::translate(DINodeAttr attr) {
DISubroutineTypeAttr>(
[&](auto attr) { return translateImpl(attr); });
- attrToNode.insert({attr, node});
+ if (node && !node->isTemporary())
+ attrToNode.insert({attr, node});
return node;
}
diff --git a/mlir/test/Target/LLVMIR/llvmir-debug.mlir b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
index f4c18bf6bd53c0..8ab1a1b290dad3 100644
--- a/mlir/test/Target/LLVMIR/llvmir-debug.mlir
+++ b/mlir/test/Target/LLVMIR/llvmir-debug.mlir
@@ -442,12 +442,16 @@ llvm.mlir.global @global_variable() {dbg_expr = #di_global_variable_expression}
#di_subprogram = #llvm.di_subprogram<scope = #di_file, file = #di_file, subprogramFlags = Optimized, type = #di_subroutine_type>
#di_composite_type = #llvm.di_composite_type<tag = DW_TAG_class_type, recId = distinct[0]<>, scope = #di_subprogram>
-#di_global_variable = #llvm.di_global_variable<file = #di_file, line = 1, type = #di_composite_type>
+// Use the inner type standalone outside too. Ensures it's not cached wrong.
+#di_var_type = #llvm.di_subroutine_type<types = #di_composite_type, #di_composite_type_inner>
+#di_global_variable = #llvm.di_global_variable<file = #di_file, line = 1, type = #di_var_type>
#di_global_variable_expression = #llvm.di_global_variable_expression<var = #di_global_variable>
llvm.mlir.global @global_variable() {dbg_expr = #di_global_variable_expression} : !llvm.struct<()>
-// CHECK: distinct !DIGlobalVariable({{.*}}type: ![[COMP:[0-9]+]],
+// CHECK: distinct !DIGlobalVariable({{.*}}type: ![[VAR:[0-9]+]],
+// CHECK: ![[VAR]] = !DISubroutineType(types: ![[COMPS:[0-9]+]])
+// CHECK: ![[COMPS]] = !{![[COMP:[0-9]+]],
// CHECK: ![[COMP]] = distinct !DICompositeType({{.*}}scope: ![[SCOPE:[0-9]+]],
// CHECK: ![[SCOPE]] = !DISubprogram({{.*}}type: ![[SUBROUTINE:[0-9]+]],
// CHECK: ![[SUBROUTINE]] = !DISubroutineType(types: ![[SR_TYPES:[0-9]+]])
|
Nice thanks! |
Followup to discussion llvm#87295 (comment). The export cache should not cache temporary nodes.
Followup to discussion llvm#87295 (comment). The export cache should not cache temporary nodes.
Followup to discussion #87295 (comment).
The export cache should not cache temporary nodes.