@zero9178 Thanks for these ideas!
I did not know that mutable attributes exist and it sounds like they are a strictly better alternative than encoding the back edge using a string. I think this insight makes solution 2 much more attractive!
The example I posted above does only show a subset of the debug metadata usage. One additional aspect, not shown previously, is that we need to reference the debug metadata from the actual program / ir:
// debug metadata definition
llvm.debug_info @ __debug_info {
llvm.di_derived_type @var_type { ... }
}
// somewhere in the program
llvm.intr.dbg.value llvm.di_local_variable<name="my_var", type = @ __debug_info::var_type> = %arg : i64
The example shows how a debug intrinsic reference a type definition inside the metadata region using a symbol. While a graph region is a great solution for the local dependencies, it does not solve the task of relating debug info to the program / ir? We would thus presumably need a second mechanism to link metadata to the program, which makes me believe using symbols is a better solution.