[llvm] Allow DWARF expressions to refer to variable values (PR #181028)
Vladislav Dzhidzhoev via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 29 07:57:10 PDT 2026
dzhidzhoev wrote:
> > > I've also been wondering if it would make sense to enforce a scoping rule in the verifier, namely that a type should only be able to refer to either a global variable, or a variable in the type's own scope or higher (that is, not in a deeper scope or sibling scope). And perhaps this rule should be extended to intra-type references as well.
> >
> >
> > Will it work for function clones? And for LTO case with ODR-type-uniquing? Currently, we may encounter local variables referencing types from other subprograms. I guess the opposite may happen as well, if a variable used in expression is of an ODR-uniqued type.. See #165032:
>
> For function clones I guess it could be made to work somehow. But ODR uniquing inside subprogram bodies seems super weird to me. I don't know this area well, so I suppose I don't really even know what that means or why it's important.
When a program is compiled in FullLTO mode, multiple LLVM IR modules are merged together (basically, multiple bitcode files are loaded into shared LLVMContext). Types from different source modules having the same `identifier:` field are merged into one type (ODR-uniquing). This also applies to function-local types. In that case, if two bitcode modules have two variables that belong to different DISubprograms and have different local types with the same identifier (it may happen if a function is declared in a header file included from two source files), in an output module, during FullLTO process, there will be a local variable which refers to the type from another DISubprogram.
https://github.com/llvm/llvm-project/pull/181028
More information about the llvm-commits
mailing list