# LLVM: implement debug info for structs · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/c3663f2617fd317f458bfa013ea94efb7dbcfee5)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: c3663f2617fd317f458bfa013ea94efb7dbcfee5

Requested commit: c3663f2617fd317f458bfa013ea94efb7dbcfee5

Commit: c3663f2617fd317f458bfa013ea94efb7dbcfee5

Tree: 21f88c80bd8279909a3f65abd3bc01c87eb3ca0d

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
LLVM: implement debug info for structs

This involved some significant reworking in order to introduce the
concept of "forward declarations" to the system to break dependency
loops.

The `lowerDebugType` function now takes an `enum { full, fwd }` and is moved
from `DeclGen` to `Object` so that it can be called from `flushModule`.

`DITypeMap` is now an `ArrayHashMap` instead of a `HashMap` so that we can
iterate over the entries in `flushModule` and finalize the forward decl
DITypes into full DITypes.

`DITypeMap` now stores `AnnotatedDITypePtr` values instead of
`*DIType` values. This is an abstraction around a `usize` which assumes
the pointers will be at least 2 bytes aligned and uses the least
significant bit to store whether it is forward decl or a fully resolved
debug info type.

`lowerDebugTypeImpl` is extracted out from `lowerDebugType` and it has a
mechanism for completing a forward decl DIType to a fully resolved one.
The function now contains lowering for struct types. Closes #11095.

There is a workaround for struct types which have not had
`resolveFieldTypes` called in Sema, even by the time `flushModule` is
called. This is a deficiency of Sema that should be addressed, and the
workaround removed. I think Sema needs a new mechanism to queue up type
resolution work instead of doing it in-line, so that it does not cause
false dependency loops. We already have one failing behavior test
because of a false dependency loop.

```

## Parents

- [cfc31b5bbdf67632626eb934886cdeaefe40e595](https://git.cafe/gitcafe/zig/commit/cfc31b5bbdf67632626eb934886cdeaefe40e595?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/c3663f2617fd317f458bfa013ea94efb7dbcfee5?format=markdown)
