<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJy9VcFu2zgQ_Rr5QtiQKNmWDzqkCVIEaLGLNkDPlDiyuKZJLTmy67_fGdqO06QoUBRYQDApkzN8M-_xqfX61DwPJgp6lNgb5wNN4wSZvBfRuA6EQeGdPQnV99BhFAgRjdsKHcwBQhTHwXSDmCIIHEBkq_yzNeGv8bMyjl6EcloMKgrnRT-5Do13ygpIyRZZ_pDld-ffbwM4Ds_k3dyPyLGMyx38DrQ4Ghx4dT7fU_q5NlG1FuY4BFCa4KTAe7GfLJrRMhZeoKICiDhOTkxjgoLpFFmPAeK0pxynTG4IHHIFeiGeqYYxeMq95-MHCJCVd2JAHCNNMvlIz5bATO2i83t6sfZwHeYU-Q_VRa-t9S0N61W-1lpv6kLrYqlqualhVZeVWq0KuewrVdablvbQVq6L8xiO-zqNow-c6NxN5HYuunHMZPmpqNbidecY8-t6O5oi9cy4KyXPafVv7y23tfMuYpg69CHR7N9viYOfrD4T38ItgrP2L4cdjbVCdTgpe9730x7ioPCmC7wKQ3uILpNrFDvnj5z21_QmFbVA9MUROtMbwnJW6PWAxARxVN519jy-1lGC8Onpy713CN8xNfOiTxpNfL6e9ZGo44IeziA0qYU0csmjqDJzoPa-qHkhnlBEgH0U1uzgUsibYrkxiYyXikRv1fY9rHQMimNqP2vU4pVHDdEEStPCoA6GuCsv_P_f4nz6wrp800rSpSzrHy_0KZH8k3bA99GaziCpho3DkK34o3snw6x85ObelKLGEVQQ6FMY7cAfVKt6hCBGFSM3mI2r73kzd6-7YH2N8JHcLkBPd5xklOzjdJa8ob3UfEz3_0XDHx8-8DyarSP5dcox_mj9kQ69cMS2wsno5OstIX3Q1LgdjRRD1IYdXVM_JTdK1kt-K9oTQdyPxjJ0djs_4U0tDK5NfygicB2TYxkNyi5muin1ptyomZooKjQI_-owGT2bgm1-WxsJTaTJssyXq9nQVOt62a8qCZ2sSA-ylJtCFYWqO11pBcuZVS3Y2GTLD5mUSSh0AT35ppTZ8mH25xhMI3Mp8yJfybLI82qxzsv1ZqnrXq2h0sUmq3LYK2MXnGfhw3YWmpSynbaRFq2JGG-LrI-tA0iQCSGSEOnl7ZfrbKPx5naXD9SvPIrlcXWnWSqjSTX8B7DJc0g>53056</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`MlirOpMain` creates threads when `--mlir-disable-threading` is specified
</td>
</tr>
<tr>
<th>Labels</th>
<td>
mlir:core
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
teqdruid
</td>
</tr>
</table>
<pre>
This is a minor issue, since it only affects testing drivers which use the `MlirOpMain` and has no functional effect.
When `*-opt` is invoked with `--mlir-disable-threading`, multiple threads are spun up and then (presumably) not used. The problem is here: https://github.com/llvm/llvm-project/blob/7607ddd981dd15a8298e6834a66125f4a389b607/mlir/lib/Support/MlirOptMain.cpp#L147
The threads are created in the `ThreadPool` constructor, so `ThreadPool` should only be constructed if threads will actually be used. The problem is that `MlirOptMain` doesn't know if `--mlir-disable-threading` has been specified since that `llvm::cl::opt` is in `MLIRContext.cpp` and `isThreadingGloballyDisabled()` is a private function. It seems like if `MlirOptMain` used the threading flag in `MLIRContext` it would result in the desired behavior:
https://github.com/llvm/llvm-project/blob/7607ddd981dd15a8298e6834a66125f4a389b607/mlir/lib/IR/MLIRContext.cpp#L238
Why does `MlirOptMain` explicitly use its own `ThreadPool`? It doesn't appear to use `threadPool` after passing it off to the context.
For reference, my only interest here is that GDB is significantly slower in the presence of threads. I think I can work around this issue by compiling without threading, but that's not ideal.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy9VEFv2zwM_TXORYhhy4mTHHzoWnQosGEftgI7yxYda1EkT6KT5d9_pJI03ToM2GVAUMmVRD6-98jW61PzPJgo6KfE3jgfaBsnyOS9iMZ1IAwK7-xJqL6HDqNAiGjcVuhgDhCiOA6mG8QUQeAAIquLj9aET-NHZRx9CO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