jmorse wrote:

Several decades later; I applied this check to the verifier and reduced around 
it:
```
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index b1cf81a3dbdc..9e2250b584b1 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -1421,6 +1421,9 @@ void Verifier::visitDISubprogram(const DISubprogram &N) {
               "invalid retained nodes, expected DILocalVariable, DILabel, "
               "DIImportedEntity or DIType",
               &N, Node, Op);
+      if (DIType *T = dyn_cast<DIType>(Op)) {
+        CheckDI(T->getScope() == &N, "wrong scope for thingy", T, 
T->getScope(), &N);
+      }
     }
   }
   CheckDI(!hasConflictingReferenceFlags(N.getFlags()),
```

Which produced these two IR files:
https://gist.github.com/jmorse/fc7d5479171b9943ae27d0f03cd9db5c
https://gist.github.com/jmorse/17040c19a096dd3780274f8e58d97b16
Which when linked with `llvm-link aa.ll bb.ll -o cc.ll -S` hit the verifier 
assertion, and have output IR which exhibits the problem you identified 
@dzhidzhoev , where the DICompositeType for `handle` ends up in one 
DISubprograms retainedNodes list but points its scope at a different 
DISubprogram. Seemingly this is something to do with the merging (or not 
merging) of distinct DISubprograms during the IR linker, unfortunately I've 
zero knowledge about that portion of LLVM.

https://github.com/llvm/llvm-project/pull/75385
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to