[Lldb-commits] [lldb] [clang] [clang][DebugInfo] Emit global variable definitions for static data members with constant initializers (PR #70639)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Wed Nov 8 15:28:00 PST 2023


Michael137 wrote:

> This causes Clang to assert:
> 
> ```
>       llvm/lib/IR/Metadata.cpp:689:
>       void llvm::MDNode::resolve(): Assertion `isUniqued() && "Expected this to be uniqued"' failed.
> ```
> 
> See https://bugs.chromium.org/p/chromium/issues/detail?id=1500262#c1 for a reproducer.
> 
> I'll revert to green.

Thanks for the repro. Reduced it to:
```
struct Foo;                                                 
template <bool c> using Int = int;                          
class Bar {                                                 
  template <typename T> static const bool Constant = false; 
  Int<Constant<Foo>> Val;                                   
  Bar();                                                    
};                                                          
Bar::Bar() {}                                               
```
when compiling with `-debug-info-kind=limited`.

The issue was that `EmitGlobalVariable` can cause creation of `DINodes`, which, if using limited debug-info, will be temporary. But the emission of the global variables is done *after* we've uniqued the temporaries. So the fix is really to just do the `EmitGlobalVariable` at the beginning of `CGDebugInfo::finalize`. Will submit a new PR with that change and a new test-case for this

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


More information about the lldb-commits mailing list