# llvm: fix lowering of runtime refs to comptime-only decls · gitcafe/zig

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

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

Visibility: public

Requested revision: cb0e22db4e18dd803e1edd681c836fadbae0ea6f

Requested commit: cb0e22db4e18dd803e1edd681c836fadbae0ea6f

Commit: cb0e22db4e18dd803e1edd681c836fadbae0ea6f

Tree: 0377d1540686d1e34998a171abb3a7f7ce53ca5e

Author: Jacob Young

Committer: Andrew Kelley

## Message

```
llvm: fix lowering of runtime refs to comptime-only decls

When we want a runtime pointer to a zero-bit value we use an undef
pointer, but what if we want a runtime pointer to a comptime-only value?
Normally, if `T` is a comptime-only type such as `*const comptime_int`,
then `*const T` would also be a comptime-only type, so anything
referencing a comptime-only value is usually also comptime-only, and
therefore not emitted to the executable.

However, what if instead we have a `*const anyopaque` pointing to a
comptime-only value?  Certainly, `*const anyopaque` is a runtime type,
and so we need some runtime value to store, even when it happens to be
pointing to a comptime-only value.  In this case we want to do the same
thing as we do when pointing to a zero-bit value, so we use
`hasRuntimeBits` to handle both cases instead of ignoring comptime.

Closes #12025

```

## Parents

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

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