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

    <tr>
        <th>Summary</th>
        <td>
            SPEC CPU 2017 502.gcc_r and 602.gcc_s fails at runtime when built with clang-cl on Windows
        </td>
    </tr>

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

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

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

<pre>
    Hello,

I'm trying to run SPEC CPU 2017 C/C++ benchmarks on Windows with clang-cl, but for some reason it is failing at runtime for 502.gcc_r and 602.gcc_s. It only fails with -O3 and -flto (full or thin) which suggests it might be a bad optimization. I don't know how to reduce the problem further other than providing a minimal config file. Tested with clang 15.0.6. Any help would be appreciated. Thanks.

Minimal config file:

```
label = clang-cl
default:
   CC                 = clang-cl /TC
   CLD = clang-cl -clang:-fuse-ld=lld
   CXX                = clang-cl /TP
   CXXLD              = clang-cl -clang:-fuse-ld=lld
   OBJ = .obj
   PORTABILITY = /DSPEC_P64
   CC_VERSION_OPTION   = ""
   CXX_VERSION_OPTION  =  ""
   OPTIMIZE    = -clang:-O3 -flto=thin
```

Repro steps:

1. Obtain SPEC CPU 2017 and set it up for Windows
2. Download Visual Studio 2022 and install the "Desktop development with C++" workload.
3. Install clang/LLVM through LLVM's installer.
4. Copy and paste the above config file contents to `spec2017\config\clang-cl.cfg`
4. Open x64 Native Tools Command Prompt for VS2022
5. If `clang-cl.exe` is not already on PATH, `set "PATH=path\to\LLVM\bin;%PATH%`
6. `cd path\to\spec2017`
7. `shrc.bat`
8. `runcpu -a validate --size train --iterations 1 -c clang-cl 602.gcc_s`
9. Observe that the benchmark builds successfully, but fails at runtime. Removing `flto=thin` makes it pass.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVd2S2jgTfRpx02WXkcf8XHAxY0KFryaBmuGb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