[PATCH] D134365: [LoongArch] Add support for llvm.trap and llvm.debugtrap

WÁNG Xuěruì via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 23 03:05:37 PDT 2022


xen0n added a comment.

In D134365#3806160 <https://reviews.llvm.org/D134365#3806160>, @xry111 wrote:

> In D134365#3806143 <https://reviews.llvm.org/D134365#3806143>, @xry111 wrote:
>
>> I have some doubt here: on x86_64 a `trap` leads to SIGILL, but a `debugtrap` leads to SIGTRAP.  Not sure if they have a good reason or this is just for satisfying some "habit" of x86 programmers.
>>
>> If we want a SIGILL we can `amswap.w $r0, $r0, $r0`.
>
> I used `amswap.w $r0, $r0, $r1` in my early work <https://github.com/xry111/llvm-project/blob/1f1a3723c2614033e97e28ccee8438f1421bb4da/llvm/lib/Target/LoongArch/LoongArchInstrInfo.td#L1358>.

It's a shame the ISA manual didn't give us a bit pattern guaranteed to cause INE (hence SIGILL). In theory all-zeros would work but I got told (I believe at least by FlyGoat) that apparently some engineering sample batches of 3A5000 treated the all-zeros insn word as valid, so it's probably better to be extra safe and just avoid it.

> But again I'm not sure if we want a SIGTRAP of SIGILL (or something else) here.

I'd really like to differentiate but according to glibc the `break 0` is used as the ultimate fallback for `abort`. Still a shame the two things have to be conflated if strictly implementing the specs...


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134365/new/

https://reviews.llvm.org/D134365



More information about the llvm-commits mailing list