[Mlir-commits] [mlir] [MLIR][LLVM] Support Recursive DITypes (PR #80251)

Tobias Gysi llvmlistbot at llvm.org
Tue Mar 19 06:58:44 PDT 2024


gysit wrote:

@zyx-billy 

We see some downstream breakage after bumping LLVM past your revision. It looks like DICompositeType can have a recursive scope parameter. Since the scope is translated as part of translatePlaceholder running the following example:

```
#di_composite_type = #llvm.di_composite_type<tag = DW_TAG_null, recId = distinct[0]<>>
#di_composite_type1 = #llvm.di_composite_type<tag = DW_TAG_null, recId = distinct[1]<>>
#di_file = #llvm.di_file<"test.mlir" in "/">
#di_derived_type = #llvm.di_derived_type<tag = DW_TAG_reference_type, baseType = #di_composite_type1, sizeInBits = 64>
#di_namespace = #llvm.di_namespace<name = "__1", exportSymbols = true>
#di_subroutine_type = #llvm.di_subroutine_type<types = #di_derived_type>
#di_subprogram = #llvm.di_subprogram<scope = #di_composite_type, name = "my_func", file = #di_file, line = 182, scopeLine = 182, subprogramFlags = Optimized, type = #di_subroutine_type>
#di_composite_type2 = #llvm.di_composite_type<tag = DW_TAG_class_type, recId = distinct[0]<>, name = "locale", file = #di_file, line = 124, scope = #di_namespace, flags = "TypePassByReference|NonTrivial", sizeInBits = 64, elements = #di_subprogram>
// This currently does not work since the scope tries to recursively translate
// the composite type again. We probably need to translate the scope late
// like the composite type elements.
#di_composite_type3 = #llvm.di_composite_type<tag = DW_TAG_class_type, recId = distinct[1]<>, name = "id", file = #di_file, line = 204, scope = #di_composite_type2, flags = "Public|TypePassByReference|NonTrivial", sizeInBits = 128>
#di_global_variable = #llvm.di_global_variable<scope = #di_namespace, name = "my_global", file = #di_file, line = 4641, type = #di_composite_type3, isDefined = true>
#di_global_variable_expression = #llvm.di_global_variable_expression<var = #di_global_variable, expr = <>>

llvm.mlir.global @global_variable() {dbg_expr = #di_global_variable_expression} : !llvm.struct<(struct<(i64)>, i32)>
```

produces an assert: `Assertion `iter != recursiveTypeMap.end() && "unbound DI recursive self type"`. 

I believe solving that problem probably requires setting the scope to a placeholder value in translatePlaceholder and then replace it - similar to the elements - in fillPlaceholder once the recursive scope is avialable.

Any chance you can work on a forward fix for this? Or should we maybe revert until there is a fix?

https://github.com/llvm/llvm-project/pull/80251


More information about the Mlir-commits mailing list