<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=http://email.email.llvm.org/c/eJzNVMlu2zAQ_RrpQlSgKCuWDzrETlIUSNqihxbwxaDEkcSYIRUuTtKv72hxHLhFe-glAkVpODOPs_CxMuKl3BjtpAAbZZcRvYroZed97waJ3eBo6zppjaiM8omxLa78xBfc4eujaPRqcpnnCzqPSWSZgEZqIJ-_3F1_-3hNonyNo1ZctwN-dqnNA9gWovxqGKNXZYwitdFCeml0xIqIraJsPSkPRgoyumw6qPduUpNoOesJPrIhuHyOwFYnC_Ia0G5XBam81DtveX-22WT6XuGi5dWfqz7Ot7ff70hjlHCEK0V8Bw7IgOKINy2gfOr3GcBum6ZvSnxAOww5I9GC_qaag-6D64jlz0e5HvbcbVevab5aenAeI4rYZpjnxXs8Isntek13i_eE0Jv-bVIW_PR7NDvWheWySbCi-mgZBPtLaz4JwNBehu3RicwUINx7K6vggbjOBCVIb-EA2qORdAnZBGtRUi-j08nYaFyyIyJ5MnbvyJP03ZQ9PCOGc5i7S2JRZmKVrXjMg--MLa3ex8Gq8ozt6ByqpDYPKCh1OH4-9NbcQ-1RlM4FQObd5BlN07gri1Q0_CLNKCz5oshyml3kRUMLBsUSFkUaK16BcuXAfsaO7K-NgBZrxhhSP_7_OGTJKGM0pXm6pEXKkoJXnC9QhrpIl6LA8wsPXKpkwBmustiWI2QVWodKJZ13JyXHwrUaYA57C4-B6x9hjtdLr6C843v4x6U2NgWZaEf2EamxcXjf1o64UHeEO2S5AAyhwibuCdfijPbxmGc5JvkL6OGycw>53011</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Make [[clang::nomerge]] work for trap intrinsics such as __debugbreak and __builtin_trap
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:codegen
      </td>
    </tr>

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

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

<pre>
    Consider:
https://gcc.godbolt.org/z/esvPqdfn9

```
#define NOMERGE [[clang::nomerge]]
bool condition();
void mergeChecks() {
    if (condition())
      NOMERGE __builtin_trap();
      if (condition())
      NOMERGE __builtin_trap();
      if (condition())
      NOMERGE __builtin_trap();
}
```

LLVM folds all these traps together:
```
_Z11mergeChecksv: # @_Z11mergeChecksv
  push rax
  call _Z9conditionv
  test al, al
  jne .LBB0_4
  call _Z9conditionv
  test al, al
  jne .LBB0_4
  call _Z9conditionv
  test al, al
  jne .LBB0_4
  pop rax
  ret
.LBB0_4: # %if.then
  ud2
```

Ideally, the nomerge attribute should prevent this. Currently the attribute only really works with call expressions.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzNVEtv2zAM_jX2RZghy3GTHHxo0nYY0G7DDhvQSyBLtK1GlVw90nW_fvQjTZEN27WGLJsi-ZEfRam28qXaWuOVBJcUlwm9SuhlF0LvB4nd4GiFyFora6tDZl2LK7_wBX_4-iQbs55c5vmCzmMSWSGhUQbI5y93198-XpOk3OAQmpt2wC8ujX0E10JSXg1j9Kqt1URYI1VQ1iRslbB1Umwm5cEqSUaXbQdi7yc1SZaznuCjGoLL5whsfbIgrwntdnVUOiizC473Z8Em0_cKlyyv_l71cb69_X5HGqulJ1xrEjrwQAYUT4JtAeXTfp8B7O7z_E2JD2iHKRckWdA_VHPSffQdcfznURZDzN39-pXmq2UAHzCjhG2HeV58wBbJbjcbulu8J4Te9m9JOQjT79HsWBdWqibDipqjZZTsH1vzSQKm9jKERycyHwHCQ3CqjgGI72zUkvQODmACGimfkW10DiX9MjqdjK3BJTcikmfr9p48q9BN7OEnYniP3H2WyqqQ62LN06CChuqO7-E_53HEwyZyY-MQZTAmXhXCEx9FR7jHBpVQx7bG-HvCjTzr2DQ6XZ3dJphcrDNhH1HQ-nD8fOidfQARUFTeR8CTfVMWNM_TrhJ1LWRTNiJf0GWZL3LKLyCnF7nkJa0ZSzWvQftqYMPYkY2wElrcE8aQSqoqRhmjOS3zJV3lLFvxmnOEKkGs8qVcYXfDI1c6G7IZLrrUVWNiyM-jUisf_EnJsaytAZiD3sNT5OZHnKPxGDrrKmf26cimGqn8BidNncw">