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

    <tr>
        <th>Summary</th>
        <td>
            [clang-cl] static variable name inside the function 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>
          yurybura
      </td>
    </tr>
</table>

<pre>
    I compile the following code with clang-cl on Windows (x86):

```cpp
int f()
{
  static int i = 123;
  return i;
}

int main()
{
  f();
  return 0;
}
```
clang-cl generates:

```asm
--- D:\src\test\static_var_test\main.cpp ---------------------------------------

int f()
{
  static int i = 123;
  return i;
00007FF6A8941000  mov         eax,dword ptr [f::i (07FF6A8945000h)]  
00007FF6A8941006  ret  
--- No source file -------------------------------------------------------------
00007FF6A8941007  nop         word ptr [rax+rax]  
--- D:\src\test\static_var_test\main.cpp ---------------------------------------
}

int main()
{
00007FF6A8941010  sub         rsp,28h  
00007FF6A8941014  mov         dword ptr [rsp+24h],0  
  f();
00007FF6A894101C  call        f (07FF6A8941000h)  
  return 0;
00007FF6A8941021  xor         eax,eax  
00007FF6A8941023  add         rsp,28h  
00007FF6A8941027  ret  
```

msvc genarates:

```asm
--- D:\src\test\static_var_test\main.cpp ---------------------------------------

int f()
{
00007FF6BBA01490  push        rdi  
  static int i = 123;
  return i;
00007FF6BBA01492  mov         eax,dword ptr [i (07FF6BBA0C000h)]  
}
00007FF6BBA01498  pop         rdi  
00007FF6BBA01499  ret  
--- No source file -------------------------------------------------------------
00007FF6BBA0149A  int         3  
00007FF6BBA0149B  int         3  
00007FF6BBA0149C  int         3  
00007FF6BBA0149D  int         3  
00007FF6BBA0149E  int         3  
00007FF6BBA0149F  int         3  
--- D:\src\test\static_var_test\main.cpp ---------------------------------------

int main()
{
00007FF6BBA014A0  push        rdi  
00007FF6BBA014A2  sub         rsp,20h  
  f();
00007FF6BBA014A6  call        f (07FF6BBA010DCh)  
  return 0;
00007FF6BBA014AB  xor         eax,eax  
}
00007FF6BBA014AD  add         rsp,20h  
00007FF6BBA014B1  pop         rdi  
00007FF6BBA014B2  ret  
```

After compiling with clang-cl 14.0.3 in Visual Studio 2017 and debugging the compiled program, the debugger cannot display the value of the `i` variable in the watch window.

![image](https://user-images.githubusercontent.com/20358738/180771862-e2a4a067-a75f-4a50-8078-3cc5bf66bfb4.png)

How to make compiled program compatible with Visual Studio 2017 Debugger?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzVVkuvqzYQ_jVkMyIy5r1gkUejdtNNpXZ5ZcCAW4Ij2yTn_PuOeSQnryat2isVEQfG4_HMNzMfzmX5mf0EhdwfRMvBNBwq2bbyJLoapSWHkzANFC3rardoQXbwm-hKedLg0OQjiRyaOv7KIVuHzGNExrs4HEaJ6AxUqG51R5V4PT4AaMOMKMCqCHD8LXjUd_zztOKmVx2Is8iJt183s-v2THRPrM-73hkkDwzOfo-v55Br3nHFDNfP4mR6P0pc14Wt1Qo3WhU44iJjX4YYvx2Z-jZJrMtLxAfc967bkP8tNAle8W4XrZI08PAZYC-PMF-cfTh0U56kKuFgFDjhurLh-Sths39eGeLKxroTbgEeGo6GvedJi9PPErTsVYH1ZgvvTRz-Cp2bLWOATh7OsXwNQtm4hvHi8H-eu79Rt9eReJgV3efnSJQ-YFZo0jzG2guuk3iVvmHtmgYNRo5GyGzivlNujG4ACta2s9HqKv_elP-LtbsuuzZHPYAPqW4KDcfHIVEfgJXluwjQ-Krabvp6HPf6WNjOZv-Pzp4DXK9XmOAU83bodXPGoxQX6P8pBUym6UsKuPS-XbK57_1zqd-YTtDrLx35xesbxfQ7ssW0JSJjEZsv_4ln6_fUNu-pbd9T--E9td0Tte9Xuy8JbfR09bx8bxTpQ-YjzWvamgxEz2hrmCfbzZu0NZlbv6CtJ5W_2j7kL3LHX6P62nuzUdb0NdGtKsPVdL6zZ7rr45wXLMnS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