<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/61892>61892</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Modules] EvaluateAsInitializer executed in every importer when a variable template depends on a conversion operator
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          davidstone
      </td>
    </tr>
</table>

<pre>
    Given the following two module files

```cpp
export module a;

struct integer {
        explicit operator int() const {
                return 0;
        }
};

template<typename>
int a = static_cast<int>(integer());

void aa() {
        a<void>;
}
```

```cpp
import a;

int main() {
}
```

And compiling them with

```shell
clang++ -std=c++20 -x c++-module -fmodule-output=a.pcm --precompile -c a.cpp
clang++ -ftime-trace -std=c++20 -fmodule-file=a=a.pcm -c b.cpp
```

We see one additional entry in the `b.json` time trace compared to the output if we delete the line that instantiates the variable template:

```json
{
        "pid": 53878,
        "tid": 53889,
        "ph": "X",
        "ts": 0,
        "dur": 60,
        "name": "Total EvaluateAsInitializer",
        "args": {
                "count": 1,
                "avg ms": 0
        }
}
```

This is likely the source of https://github.com/llvm/llvm-project/issues/61040#issuecomment-1447329303 -- in other words, this `EvaluateAsInitializer` shows up even when doing constant initialization by declaring `a` as `constexpr`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVUGP4jgT_TXmUgoydgjkwKG7mf70HfY20u5tVTgV4lnHjuwKdO-vXzmBbpph57JSBI6fq-rl-ZWNKdmjJ9qJ9bNY7xc4chfirsGTbRIHT4tDaN53_7Mn8sAdQRucC2frj8DnAH1oRkfQWkdJyL2QT5ffSs6PGYZ5ht6GEPkagEI_365PHEfDYD3TkSKIzQda09vgrLEMYaCIHGJeJdRWqBpM8Im_rBayjsRj9CBvStRis7-MN_u70kz94JBJ6Bd-H8hjT0J_mzHrGRCE3kNiZGv-NJhY6Jf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