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

    <tr>
        <th>Summary</th>
        <td>
            [ORC] LLJITBuilder overwrite CodeModel setting from JTMB
        </td>
    </tr>

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

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

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

<pre>
    I am doing something like this to configure a LLJIT object with it's code model set as `CodeModel::Large`.

```cpp
auto JTMBOrErr = orc::JITTargetMachineBuilder::detectHost();
if (JTMBOrErr)
 exit_on_err(JTMBOrErr.takeError());

auto JTMB = std::move(*JTMBOrErr);
JTMB.setCodeModel(CodeModel::Large);

// TODO find a way to setCodeModel(CodeModel::Large)
// because JTMB's code model is overwritten by create() function
jit = exit_on_err(orc::LLJITBuilder().setJITTargetMachineBuilder(JTMB).create());
```

As written in the comment, the code model is overwritten by `LLJITBuilder::create`. Digging in the code, we can see that `LLJITBuilder::create` call `LLJITBuilderState::prepareForConstruction`, which then set `CodeModel::Small` without looking at the setting in JTMB. See here :
https://github.com/llvm/llvm-project/blob/040e0d4fa45f3606fb584c2923dd111cca675feb/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp#L755-L757

I think there is no reason to force this setting.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVF1v4joQ_TXmZbSRY0hCHvLQlqLbqhXSLe8rx5kk3iY2sidl---v7ACl3fu1EgL8dWbOOTMjvdedQaxYdsuyzUJO1FtX4UGTfHtf1LZ5rx5AjtBYbTrwdkTqw79BvyJQrz2QBWVNq7vJIUh4enp82IOtf6AiOGrqQRMThQdlG4TRNjiARwLpgeX8zjb4HPbY8oYtb56k65DlPGF8w_jN6Tvn80cdDvOOnMjC4_75dufunQO23IB1aoZ4fNjvAwo9S9Vrg7eTHhp082GDhIr-sJ6Y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