Re: [PATCH v1] LoongArch: Add -fno-isolate-erroneous-paths-dereference in Makefile

From: Huacai Chen

Date: Sun Sep 28 2025 - 08:52:52 EST


On Tue, Sep 23, 2025 at 8:39 PM Xi Ruoyao <xry111@xxxxxxxxxxx> wrote:
>
> On Tue, 2025-09-23 at 14:17 +0800, Tiezhu Yang wrote:
> > Currently, when compiling with GCC, there is no "break 0x7" instruction
> > for zero division due to using the option -mno-check-zero-division, but
> > the compiler still generates "break 0x0" instruction for zero division.
> >
> > Here is a simple example:
> >
> > $ cat test.c
> > int div(int a)
> > {
> > return a / 0;
> > }
> > $ gcc -O2 -S test.c -o test.s
> >
> > GCC generates "break 0" On LoongArch and "ud2" on x86, objtool decodes
> > "ud2" as INSN_BUG for x86, so decode "break 0" as INSN_BUG can fix the
> > objtool warnings for LoongArch, but this is not the intention.
> >
> > When decoding "break 0" as INSN_TRAP in the previous commit, the aim is
> > to handle "break 0" as a trap. The generated "break 0" for zero division
> > by GCC is not proper, it should generate a break instruction with proper
> > bug type, so add the GCC option -fno-isolate-erroneous-paths-dereference
> > to avoid generating the unexpected "break 0" instruction for now.
>
> I just proposed GCC to use the same "documented undefined instruction"
> as Clang:
> https://gcc.gnu.org/pipermail/gcc-patches/2025-September/695981.html.
I have discussed it with Tiezhu offline, and we prefer "break 0x1".

Huacai

>
> --
> Xi Ruoyao <xry111@xxxxxxxxxxx>