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

    <tr>
        <th>Summary</th>
        <td>
            __attribute__((nocf_check) on function pointer doesn't add notrack prefix with -O1+
        </td>
    </tr>

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

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

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

<pre>
    I'm trying to use the nocf_check attribute on a function pointer by reproducing this testcase:
https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/X86/nocf_check.ll#L7

```
void __attribute__((nocf_check)) NoCfCheckFunc(void) {}

typedef void(*FuncPointer)(void);
void NoCfCheckCall(FuncPointer f) {
 __attribute__((nocf_check)) FuncPointer p = (__attribute__((nocf_check)) FuncPointer) (f);
  (*p)();
}
```

Compiling this with `-fcf-protection=branch` my expectation is that the call to `p` should have a `notrack` prefix.
This is the case, but only if I add `-O0`. Any higher optimization level results in a regular branch without the `notrack`.

https://godbolt.org/z/ocnz1qhbW

cc @MaskRay 
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVE1v4zYQ_TWjyyAGNbK-DjokNlQs0HaLokB7MyhqZLGhRZWksuv8-oJSEnvbQ7uAQIHkfLw3fDPSe32emBvInyA_JnIJo3WNd5ZDOLNLOttfm09A5QWDu-rpjMHi4hnDyDhZNZzUyOoZZQhOd0tgtBNKHJZJBW0nnK2eAjvsruh4drZf1Bpk1B4D-6CkZ8geQRxBPI4hzD7uqAVqzzqMS7dT9gLUGvPy_nuYnf2TVQBqO2M7oPYi9XSziWGB2oPt-QeO539UBVB7A7szBij7sdySvq2FePvW7YvVPZ5OH6xOJ6AKqLoFAaqBavzZHoZD3LfLpICq6BjPoXyC8nifIVxn7nnAzaICeowuv2z1WaO9O0P2dIfiI8NBRtzVnRcO76lW8_8F-N59RsiOCFR9p-OalarhHiviRmreqNxf3QrxbZG39WAvszYfoviiw4hQiIdBDfGlA69CguzYOTmpEQqBlyvy15lVkKvGopRGGVZJKmlMlCgUYo6mfrSL6XGUL4wynk42OKme493seNBfdxuM32LyNVIM4hnogN0S0E7minrATyj7fgX2OTLY4eN0xVGfR3Zo56Av-nVDY_iFDTr2iwkedewGx-fFSIcbg5WiXTa83yDa3dflH81g-86asLPuDNS-ArVWTa_pX2P3-72TUgh78ZP0z7_KKyZ9k_V1VsuEm7RMcyHqLM-TsRmqQapMplT3pdgXmaqrfZkXgnIp-31eJbohQXuRiyLNqU7FLhtqmYq6SPs8LdN9DXvBF6nNLjZdRJVo7xdu6pSoSozs2Ph1qBBN_AXXSyCKM8Y1axd3y9nDXhjtg79FCToYbv5Lj3HI_GvE9Jb9BFSG9aXeqvr2yJusHj6nQE_J4kzz3aNmZeCB2pXh3wEAAP__OrWj_Q">