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

    <tr>
        <th>Summary</th>
        <td>
            [OpenMP][AArch64] ompt/synchronization/[masked.c | master.c] fail due to possibly wrong codegen
        </td>
    </tr>

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

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

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

<pre>
    On AArch64, `ompt/synchronization/master.c` and `ompt/synchronization/masked.c` both fail in similar ways in current `main`:

```
# | /GitHub/llvm/llvm-project/openmp/runtime/test/ompt/synchronization/masked.c:38:11: error: CHECK: expected string not found in input
# | // CHECK: {{^}}[[MASTER_ID]]: current_address={{.*}}[[RETURN_ADDRESS_END]]
# | ^
# | <stdin>:8:120: note: scanning from here
# | 281474976710658: ompt_event_masked_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaaaf8260d0
# | ^
# | <stdin>:8:120: note: with "MASTER_ID" equal to "281474976710658"
# | 281474976710658: ompt_event_masked_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaaaf8260d0
# | ^
# | <stdin>:8:120: note: with "RETURN_ADDRESS_END" equal to "0xaaaaaf8260d0"
# | 281474976710658: ompt_event_masked_end: parallel_id=281474976710661, task_id=281474976710662, codeptr_ra=0xaaaaaf8260d0
# | ^
# | <stdin>:9:13: note: possible intended match here
# | 281474976710658: current_address=0xaaaaaf8260d8 or 0xaaaaaf8260d4
```

When looking at the disassembly, there is a spurious branch instruction that isn't supposed to be there:

```
 ce8:   91364000        add     x0, x0, #0xd90
 cec:   97ffff19        bl 950 <__kmpc_end_master@plt>
 cf0:   14000001        b       cf4 <main.omp_outlined+0xd4>
 cf4:   d503201f        nop
 cf8:   14000001 b       cfc <main.omp_outlined+0xdc>
 cfc:   d0000088        adrp x8, 12000 <__gmon_start__@Base>
 d00:   f9404d08        ldr     x8, [x8, #152]
```

I'd expect the code to fallthrough from the `nop` (label) to the `adrp`. Instead, there's a branch to the `adrp` instruction.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVt-T2yYQ_mvwC1MPAv2wHvxgn-wm00nSuaTTRw2ClUVPAhVQ7q5_fQckn-98l6R9bD2MsLTsx34fCyx3Tp00wBZle5RVKz75ztitAAdm1Rj5uP2k8W5nRZeniN5glBMzjB7Ro3vUorNGq7-4V0Yjehy482DXAuUEcy1_NPYO5Dy2Mb7DLVc9Vho7NaieW3zPH114F5O1oH0AG7jSKCeI7RCpEDk_c7K0-ZUyjIobjOjxZ-XfTQ2ix77_OizdT6M1f4AIQZkR9DAierST9moARI8eXLT8MGq2YxvEdkmC2A6DtcaGPzfvDje_xC8PIwgPEjtvlT5hbTxuzaRlYKT0OPlXwSJ6vPijYh9adkBFFVpYm_2H3ecvh9v6fYWy2NjuLE7NpbTgHGLV7LlGdPfc9fbw5bfbj_Wuqm4Pnz_Xh49njJdRZIerD-zGeak0YgfEdpEwDfIHPhB6J7jWgWBrzYA7sPASgG6StEjLIi8SkmcBAAdta_gaop7VrEHLYBi55X0Pfa0kYtULzzwJqee5u3vLSINRGAmjt7XliFXkgYdfu6E5kdd58a9J3ivfYUTpRX9KMfw58R57EwzXLCn9H6vwRipdyXE1739fjTKowZ6LMRrnVNMDVtqDliDxwL3o_tkOeL1pX8S2wcbiF1_Stw-6-Py9A417Y-7CLuQe-w6wVI47B0PTP0aNQlRYOcyxGyerzORwY7kWHVbaeTuJcLph33GPldOIFh67aRyNAxmWtIEZ4vvnLhYQ2WFcJixPCSF4-XEpY_9AQjTzE1FGHmR58RWLb9G2bZuUZ9-mx2VGwnrU9d0wipAY9XzPoJSMvQ8rtGC0ZMZIwuSEJE8YSy_aNACFW2RthrE2k--VBononjzI9DlSOiPJjDBKkvaMpM34NGRzNdllFvGdWcTzWRbOMiJsNhe97IgfNkGmhAYdI_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