This is a summary of discussions relative to the merge request created by 
(cr1901) <[email protected]> titled
Enable reload in lm32 backend after testing showed minimal regressions 
[PR120077]
since its creation.

Description: This PR closes 
[120077](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120077) on BZ.

I compiled `lm32-none-gcc` with newlib support, and ran the `compile.exp`, 
`execute.exp`, `dg.exp`, and `old-deja.exp` test suites twice; once with LRA 
disabled (baseline), and once with LRA enabled (lra). All 16 multilib 
configurations were tested. Both sets of tests were run against f4b5c2bf40d.

lm32 has a binutils simulator, and while DejaGNU doesn't currently know about 
it in-tree, I was able to define an out-of-tree boards file that worked:

1. export `DEJAGNU=/path/to/site.exp`
2. Fill out `site.exp` with the following:

    ```
    global boards_dir
    lappend boards_dir /path/to/site_exp_dir
    ```

3. Fill out `lm32-sim.exp` _in the same directory as `site.exp`_ with the 
following:

   ```
   # Load the generic configuration for this board. This will define a basic
   # set of routines needed by the tool to communicate with the board.
   load_generic_config "sim"

   # basic-sim.exp is a basic description for the standard Cygnus simulator.
   load_base_board_description "basic-sim"

   # This will look for lm32-elf-run somewhere on your PATH, or in the gcc build
   # dir if binutils was built in-tree.
   setup_sim lm32

   # Makes the slash notation described in "Passing options and running 
multiple testsuites"
   # at https://gcc.gnu.org/install/test.html work. Also "does the right thing" 
for
   # [get_multilibs].
   process_multilib_options ""

   # The compiler used to build for this board. This has *nothing* to do
   # with what compiler is tested if we're testing gcc. Further, this is
   # the default, so this line is optional for most boards.
   # (Does not appear to be optional for lm32-sim. Try removing it and see what 
happens!)
   set_board_info compiler "[find_gcc]"

   # We only support newlib on this target.
   # However, we include libgloss so we can find the linker scripts.
   # For lm32, libnosys is also required and it's not part of the default
   # [libgloss_link_flags].
   set_board_info cflags "[newlib_include_flags] [libgloss_include_flags]"
   set_board_info ldflags "[newlib_link_flags] [libgloss_link_flags] -L 
[get_multilibs]/libgloss/libnosys"

   # No linker script for this board. This is the default explicitly written 
out.
   set_board_info ldscript "-Tsim.ld"

   # set_board_info needs_status_wrapper  1

   set_board_info gcc,stack_size 16384
   set_board_info noargs 1
   set_board_info gdb,nosignals 1

   # 16
   set_board_info gcc,timeout 8
   # set_board_info gdb,timeout 1
   # set_board_info sim,timeout 1
   # set_board_info gdb,noresults 1
   ```

4. `make check-gcc` and `make check-g++` should "just work" and pick up the new 
board file. The full command-lines I used were:
   ```
   make -j5 
check-gcc//lm32-sim/{,-mbarrel-shift-enabled,-mmultiply-enabled,-mdivide-enabled,-msign-extend-enabled,'-mdivide-enabled/-msign-extend-enabled','-mmultiply-enabled/-mdivide-enabled','-mmultiply-enabled/-msign-extend-enabled','-mmultiply-enabled/-mdivide-enabled/-msign-extend-enabled','-mbarrel-shift-enabled/-mmultiply-enabled','-mbarrel-shift-enabled/-mdivide-enabled','-mbarrel-shift-enabled/-msign-extend-enabled','-mbarrel-shift-enabled/-mdivide-enabled/-msign-extend-enabled','-mbarrel-shift-enabled/-mmultiply-enabled/-mdivide-enabled','-mbarrel-shift-enabled/-mmultiply-enabled/-msign-extend-enabled','-mbarrel-shift-enabled/-mmultiply-enabled/-mdivide-enabled/-msign-extend-enabled'}
 RUNTESTFLAGS="compile.exp execute.exp dg.exp old-deja.exp "
   make -j5 
check-g++//lm32-sim/{,-mbarrel-shift-enabled,-mmultiply-enabled,-mdivide-enabled,-msign-extend-enabled,'-mdivide-enabled/-msign-extend-enabled','-mmultiply-enabled/-mdivide-enabled','-mmultiply-enabled/-msign-extend-enabled','-mmultiply-enabled/-mdivide-enabled/-msign-extend-enabled','-mbarrel-shift-enabled/-mmultiply-enabled','-mbarrel-shift-enabled/-mdivide-enabled','-mbarrel-shift-enabled/-msign-extend-enabled','-mbarrel-shift-enabled/-mdivide-enabled/-msign-extend-enabled','-mbarrel-shift-enabled/-mmultiply-enabled/-mdivide-enabled','-mbarrel-shift-enabled/-mmultiply-enabled/-msign-extend-enabled','-mbarrel-shift-enabled/-mmultiply-enabled/-mdivide-enabled/-msign-extend-enabled'}
 RUNTESTFLAGS="compile.exp execute.exp dg.exp old-deja.exp "
   ```

   I encountered issues with log files being truncated when interleaving 
`check-gcc` and `check-g++`, so I ran them separately.
   
Once I ran the testsuites with LRA disabled and enabled, I uploaded them into a 
git repo using [Bunsen](https://sourceware.org/bunsen/). The repo of testruns 
is available on [Codeberg](https://codeberg.org/cr1901/gcc-testruns), for those 
curious. You will want the `lm32-baseline-2026-04-30T07.50.19` and 
`lm32-lra-2026-04-30T14.05.53` tags. I then used Bunsen's `r-diff-testruns` 
command output to analyze the differences at a file level (i.e. I'm summarizing 
the various optimization level and multilib configs):

|Test file                                  |Without LRA                   
|With LRA                      |
|:------------------------------------------|:-----------------------------|:-----------------------------|
| c-c++-common/missing-close-symbol.c       | all PASS                     | 
transient error              |
| c-c++-common/Wbidi-chars-ranges.c         | all PASS                     | 
transient error              |
| gcc.c-torture/compile/asmgoto-2.c         | all UNSUPPORTED              | 
all PASS                     |
| gcc.c-torture/compile/asmgoto-5.c         | all UNSUPPORTED              | 
all PASS                     |
| gcc.c-torture/compile/asmgoto-6.c         | all UNSUPPORTED              | 
all PASS                     |
| gcc.c-torture/compile/limits-externdecl.c | all FAIL                     | 
all PASS                     |
| gcc.c-torture/compile/pr98096.c           | all UNSUPPORTED              | 
all PASS                     |
| gcc.c-torture/execute/built-in-setjmp.c   | all FAIL                     | 
all PASS                     |
| gcc.dg/asm-hard-reg-error-4.c             | all UNSUPPORTED              | 
all PASS                     |
| gcc.dg/asm-hard-reg-error-5.c             | all UNSUPPORTED              | 
all PASS                     |
| gcc.dg/asm-hard-reg-error-6.c             | all UNSUPPORTED              | 
all PASS                     |
| gcc.dg/c11-atomic-2.c                     | all FAIL                     | 
all PASS                     |
| gcc.dg/missing-symbol-3.c                 | all PASS                     | 
transient error              |
| gcc.dg/pr100590.c                         | all UNSUPPORTED              | 
all PASS                     |
| gcc.dg/pr107385.c                         | all UNSUPPORTED              | 
all PASS                     |
| gcc.dg/pr108095.c                         | all UNSUPPORTED              | 
all PASS                     |
| gcc.dg/pr110079.c                         | all UNSUPPORTED              | 
all PASS                     |
| gcc.dg/pr43058.c                          | all FAIL                     | 
all PASS                     |
| gcc.dg/pr48141.c                          | all FAIL                     | 
all PASS                     |
| gcc.dg/pr70281.c                          | all PASS                     | 
transient error              |
| gcc.dg/pr97459-2.c                        | all FAIL                     | 
all PASS                     |
| gcc.dg/pr97459-4.c                        | all FAIL                     | 
all PASS                     |
| gcc.dg/pr97459-5.c                        | all FAIL                     | 
all PASS                     |
| gcc.dg/pr97459-6.c                        | all FAIL                     | 
all PASS                     |
| gcc.dg/pr97954.c                          | all UNSUPPORTED              | 
all PASS                     |
| gcc.dg/struct-by-value-1.c                | UNSUPPORTED/FAIL mix         | 
all PASS                     |
| g++.dg/eh/ctor2.C                         | PASS/FAIL mix                | 
disjoint PASS/FAIL mix       |
| g++.dg/inherit/covariant4.C               | PASS/FAIL mix                | 
PASS/FAIL mix                |
| g++.dg/ipa/pr71207.C                      | PASS/FAIL mix                | 
PASS/FAIL mix                |
| g++.dg/tree-ssa/pr96979.C                 | all FAIL                     | 
all PASS                     |
| g++.dg/warn/uninit-pr105562.C             | all FAIL                     | 
all PASS                     |
| g++.dg/warn/Warray-bounds-pr122824.C      | all FAIL                     | 
all PASS                     |
| g++.old-deja/g++.eh/catch5p.C             | PASS/FAIL mix                | 
disjoint PASS/FAIL mix       |
| g++.old-deja/g++.eh/catch6.C              | PASS/FAIL mix                | 
disjoint PASS/FAIL mix       |
| g++.old-deja/g++.eh/catch6p.C             | PASS/FAIL mix                | 
disjoint PASS/FAIL mix       |
| g++.old-deja/g++.mike/align1.C            | PASS/FAIL mix                | 
disjoint PASS/FAIL mix       |
| g++.old-deja/g++.mike/dyncast1.C          | PASS/FAIL mix                | 
disjoint PASS/FAIL mix       |
| g++.old-deja/g++.mike/p658.C              | all UNSUPPORTED              | 
all UNRESOLVED/FAIL mix      |
| g++.old-deja/g++.other/dyncast4.C         | PASS/FAIL mix                | 
disjoint PASS/FAIL mix       |
| g++.old-deja/g++.robertl/eh990323-2.C     | PASS/FAIL mix                | 
disjoint PASS/FAIL mix       |

Notes:

* "Transient errors" mean "the test failed , but I could not duplicate." Race 
condition in dejagnu? Bit flip? Who knows :)! All of the
   failures seem to be excess-error related, like some columns of the error 
output got stripped:
  
   ```
   FAIL: c-c++-common/Wbidi-chars-ranges.c  -Wc++-compat  (test for excess 
errors)
   Excess errors:
    <U+2066>if (isAdmin)<U+2069> <U+2066> begin admins only */
                                 ~~~~~~~~                    ^
                                 |                           |
                                 |                           end of 
bidirectional context
                                 U+2066 (LEFT-TO-RIGHT ISOLATE)
   ```

* For `g++.dg/inherit/covariant4.C` are `g++.dg/ipa/pr71207.C`, the test 
results don't change, but the failure reason varies between `core: 4 byte 
misaligned read to address` and "the test timed out". I wasn't sure if this is 
noteworthy with the 8 second timeout in my board file, so I included them just 
in case.

Based on these results, I don't believe that the lm32 backend really depends on 
differences between reload and LRA. Specifically:

* Many tests that fail with LRA disabled, pass with LRA enabled.
* Disregarding transient errors, _there is no test which was previously passing 
in all multilib configurations that started failing when LRA is enabled._
* Tests that started failing when LRA is enabled seem to all be part of tests 
which were already flaky before LRA was enabled (most of `g++.old-deja`, 
`g++.dg/inherit/covariant4.C`, and `g++.dg/ipa/pr71207.C`?).

For these reasons, I'm offering this PR and test results as reason to just 
"flip the LRA switch on" for lm32. I don't use the backend myself as much as I 
did 10 years ago; everybody loves RISC-V nowadays. but the target is 
unchanging, and the backend is simple enough for a single person to study that 
I think it's worth keeping around as gcc's version of 
[Cpu0](https://jonathan2251.github.io/lbd/llvmstructure.html).

The full and up to date discussion can be found at 
https://forge.sourceware.org/gcc/gcc-TEST/pulls/153

The merge request has been closed without being merged directly on the forge 
repository.


On 2026-05-11 19:46:03+00:00, Drea Pinski (pinskia) wrote:

https://gcc.gnu.org/pipermail/gcc-cvs/2026-May/453720.html

Reply via email to