[llvm] [DebugInfo] Swap 'Unit' and 'Type' positions in DISubprogram. (PR #96474)

Abid Qadeer via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 24 10:01:10 PDT 2024


abidh wrote:

> Most curious; my understanding of `Verifier::visitMDNode` [0] is that it should be calling out into visitDISubprogram by switching on the metadata ID -- do you have a reproducer for the behaviour you're observing? It sounds like something is broken, but if it's fixed by re-ordering fields then there's something even bigger that's broken lurking under the surface.
> 
> [0]
> 
> https://github.com/llvm/llvm-project/blob/6481dc57612671ebe77fe9c34214fba94e1b3b27/llvm/lib/IR/Verifier.cpp#L1058

Problem comes from the loop a few lines below [0]. It calls the visitMDNode on operands in order. You can reproduce it using following code. 

```
int test(int a[][5])
{
    return a[0][2];
}
```
You will see that control reaches `Verifier::visitDISubrange` first with `CurrentSourceLang` still equal to `dwarf::DW_LANG_lo_user (32768)`. The `Verifier::visitDICompileUnit` which sets the value of `CurrentSourceLang` will be called later.


[0] https://github.com/llvm/llvm-project/blob/6481dc57612671ebe77fe9c34214fba94e1b3b27/llvm/lib/IR/Verifier.cpp#L1063

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


More information about the llvm-commits mailing list