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

    <tr>
        <th>Summary</th>
        <td>
            Expose `PassBuilder::addVectorPasses` or add vectorization to `PassBuilder::buildFunctionSimplificationPipeline`
        </td>
    </tr>

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

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

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

<pre>
    `PassBuilder::buildFunctionSimplificationPipeline` does not perform vectorization. Currently, the only way to get vectorization (without listing out all the passes yourself) is to call `PassBuilder::buildPerModuleDefaultPipeline`, which works at module level. This means that you cannot build a `FunctionPassManager` that does vectorization.

There is a function `PassBuilder::addVectorPasses` that `PassBuilder::buildPerModuleDefaultPipeline` uses to build its function optimization pipeline, which builds the vectorization pass. It is currently not exposed.

I am trying to upgrade a client, [terra](https://terralang.org/) to LLVM 17. Terra uses a JIT that optimizes on a per-function basis. Therefore, a module optimization pipeline is inappropriate. In the legacy pass manager, we used `PassManagerBuilder::populateModulePassManager` with a wrapper type to extract out the appropriate function passes. It is not obvious how to do that in the new infrastructure, and the available pipeline construction methods do not appear to provide adequate support for optimizing functions.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVMFuIzcM_Rr5QsQYyxknPswh2dRAig0QoMHeOTOcGbUaSZUoe92vLyjbyXqxixZ7sS2L5ON7jxSmZEZH1Kj6UdVPC8w8-diQtcYzJ4t5nJjiovX9sVGb6hVTeszG9hTV-kGtH1o57LLr2Hj3h5mDNYPpUE6vJpA1jtSmgt5TAucZAsXBxxn21LGP5p8SuYRPOUZybI9KfwKeCLyzRzjgEdjDSHwdD0rfHwxPPjNYk9i4EeQ3WluSA6ZECY4-x0R2UHoLJkmlTiJ-SuOV4ovvs6UnGjBb_oaAtHWYTDfBwce_EiDDXELB0p7sEt4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