# The gcc backend

In the `opt` mode, kdts uses a fork of Google Closure Compiler (gcc) as a backend. This fork, which is called kdts-gcc in this document, is hosted at <https://github.com/KimlikDAO/gcc>.

Compared to stock gcc, this fork performs more aggressive optimizations; which often means making more assumptions about the accuracy of user provided types.

Some differences between kdts-gcc and stock gcc:

#### Constant folding of type predicates

In kdts-gcc, type predicates such as `Array.isArray(x)`, `typeof x == y`, `x instanceof y` are constant-folded if the declared or inferred type of the expression is enough the conclude the value of the expression.

See the [commit](https://github.com/google/closure-compiler/commit/95bd88c1ae26bea5f1e6c5a0f96a9470e844842a)

#### Color narrowing after a function inline

Stock gcc has advanced function inlining capabilities. If a function is inlined in the block mode, the body preserves the colors (types) of the original function. kdts-gcc tries to narrow the colors to ones implied by the specific parameters at the call site. This narrowing can lead to cascaded folds in the following passes.

See the [commit](https://github.com/google/closure-compiler/commit/7e6a1546d04802ac286a25525534599476371673)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kimlikdao.org/the-gcc-backend.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
