[llvm] [Mips] Fix atomic min/max generate mips4 instructions when compiling for mips2 (PR #149983)

Vladimir Vereschaka via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 17 10:55:02 PDT 2025


vvereschaka wrote:

@yingopq 

https://lab.llvm.org/buildbot/#/builders/187/builds/11459

broken `atomic-min-max.ll` test on the expensive builder

```
******************** TEST 'LLVM :: CodeGen/Mips/atomic-min-max.ll' FAILED ********************
Exit Code: 1
Command Output (stdout):
--
# RUN: at line 2
/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc -mtriple=mips-elf -O0 -mcpu=mips32r2 -verify-machineinstrs /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll -o - | /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll --check-prefix=MIPS
# executed command: /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc -mtriple=mips-elf -O0 -mcpu=mips32r2 -verify-machineinstrs /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll -o -
# executed command: /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll --check-prefix=MIPS
# RUN: at line 3
/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc -mtriple=mips-elf -O0 -mcpu=mips32r6 -verify-machineinstrs /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll -o - | /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll --check-prefix=MIPSR6
# executed command: /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc -mtriple=mips-elf -O0 -mcpu=mips32r6 -verify-machineinstrs /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll -o -
# executed command: /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll --check-prefix=MIPSR6
# RUN: at line 4
/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc -mtriple=mips-elf -O0 -mcpu=mips32r2 -mattr=+micromips -verify-machineinstrs /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll -o - | /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll --check-prefix=MM
# executed command: /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc -mtriple=mips-elf -O0 -mcpu=mips32r2 -mattr=+micromips -verify-machineinstrs /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll -o -
# executed command: /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll --check-prefix=MM
# RUN: at line 5
/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc -mtriple=mips-elf -O0 -mcpu=mips32r6 -mattr=+micromips -verify-machineinstrs /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll -o - | /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll --check-prefix=MMR6
# executed command: /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc -mtriple=mips-elf -O0 -mcpu=mips32r6 -mattr=+micromips -verify-machineinstrs /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll -o -
# executed command: /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll --check-prefix=MMR6
# RUN: at line 6
/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc -mtriple=mipsel-elf -O0 -mcpu=mips2 /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll -o - | /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll --check-prefix=MIPS2
# executed command: /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc -mtriple=mipsel-elf -O0 -mcpu=mips2 /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll -o -
# .---command stderr------------
# | 
# | # After Mips pseudo instruction expansion pass
# | # Machine code for function test_max_16: NoPHIs, TracksLiveness, NoVRegs, TiedOpsRewritten
# | Frame Objects:
# |   fi#0: size=4, align=4, at location [SP-4]
# | save/restore points:
# | save points are empty
# | restore points are empty
# | Function Live Ins: $a0, $a1
# | 
# | bb.0.entry:
# |   successors: %bb.1(0x80000000); %bb.1(100.00%)
# |   liveins: $a0, $a1
# |   $sp = ADDiu $sp, -8
# |   CFI_INSTRUCTION def_cfa_offset 8
# |   dead renamable $at = KILL renamable $a1
# |   SYNC 0
# |   renamable $at = ADDiu $zero, -4
# |   renamable $a2 = AND renamable $a0, killed renamable $at
# |   renamable $at = ANDi killed renamable $a0, 3
# |   renamable $t2 = SLL killed renamable $at, 3
# |   renamable $at = ORi $zero, 65535
# |   renamable $t0 = SLLV killed renamable $at, renamable $t2
# |   renamable $t1 = NOR $zero, renamable $t0
# |   renamable $a3 = SLLV killed renamable $a1, renamable $t2
# | 
# | bb.1.entry:
# | ; predecessors: %bb.0, %bb.3
# |   successors: %bb.2(0x40000000), %bb.3(0x40000000); %bb.2(50.00%), %bb.3(50.00%)
# |   liveins: $a3, $t2, $a2
# |   $v0 = LL $a2, 0
# |   $a0 = SRAV $v0, $t2
# |   $a0 = SLL killed $a0, 16
# |   $a0 = SRA killed $a0, 16
# |   $at = OR $zero, $a0
# |   $a0 = SLLV $a0, $t2
# |   $a1 = SLT $a0, $a3
# |   $v1 = OR $a3, $zero
# |   BEQ $a1, $zero, %bb.2, implicit-def $at
# |   B %bb.3, implicit-def $at
# | 
# | bb.2.entry:
# | ; predecessors: %bb.1
# |   successors: %bb.3(0x80000000); %bb.3(100.00%)
# |   liveins: $a0
# |   $v1 = OR $a0, $zero
# | 
# | bb.3.entry:
# | ; predecessors: %bb.1, %bb.2
# |   successors: %bb.1(0x00000000), %bb.5(0x80000000); %bb.1(0.00%), %bb.5(100.00%)
# |   liveins: $a3, $t2, $a2, $t1, $v0, $v1, $t0
# |   $v1 = AND $v1, $t0
# |   $a0 = AND $v0, $t1
# |   $a0 = OR $a0, $v1
# |   $a0 = SC $a0(tied-def 0), $a2, 0
# |   BEQ $a0, $zero, %bb.1, implicit-def $at
# | 
# | bb.4.entry:
# | 
# | bb.5.entry:
# | ; predecessors: %bb.3
# |   successors: %bb.6(0x80000000); %bb.6(100.00%)
# |   liveins: $at
# |   SW killed $at, $sp, 4 :: (store (s32) into %stack.0)
# | 
# | bb.6.entry:
# | ; predecessors: %bb.5
# | 
# |   $v0 = LW $sp, 4 :: (load (s32) from %stack.0)
# |   SYNC 0
# |   $sp = ADDiu $sp, 8
# |   PseudoReturn undef $ra, implicit killed $v0
# | 
# | # End machine code for function test_max_16.
# | 
# | *** Bad machine code: MBB exits via conditional branch/fall-through but the CFG successors don't match the actual successors! ***
# | - function:    test_max_16
# | - basic block: %bb.3 entry (0x5c77e2bdab88)
# | 
# | *** Bad machine code: MBB has unexpected successors which are not branch targets, fallthrough, EHPads, or inlineasm_br targets. ***
# | - function:    test_max_16
# | - basic block: %bb.3 entry (0x5c77e2bdab88)
# | LLVM ERROR: Found 2 machine code errors.
# | PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
# | Stack dump:
# | 0.	Program arguments: /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc -mtriple=mipsel-elf -O0 -mcpu=mips2 /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll -o -
# | 1.	Running pass 'Function Pass Manager' on module '/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll'.
# | 2.	Running pass 'Verify generated machine code' on function '@test_max_16'
# |  #0 0x00005c77bfa75808 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc+0x7bc9808)
# |  #1 0x00005c77bfa72f15 llvm::sys::RunSignalHandlers() (/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc+0x7bc6f15)
# |  #2 0x00005c77bfa765d1 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
# |  #3 0x00007c2f22c45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
# |  #4 0x00007c2f22c9eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
# |  #5 0x00007c2f22c4527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
# |  #6 0x00007c2f22c288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
# |  #7 0x00005c77bf9dbaf5 llvm::report_fatal_error(llvm::Twine const&, bool) (/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc+0x7b2faf5)
# |  #8 0x00005c77bebbc5fe (/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc+0x6d105fe)
# |  #9 0x00005c77bebbd5db (anonymous namespace)::MachineVerifierLegacyPass::runOnMachineFunction(llvm::MachineFunction&) MachineVerifier.cpp:0:0
# | #10 0x00005c77bea9a543 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc+0x6bee543)
# | #11 0x00005c77beff180b llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc+0x714580b)
# | #12 0x00005c77beff9872 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc+0x714d872)
# | #13 0x00005c77beff232a llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc+0x714632a)
# | #14 0x00005c77bc9da459 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
# | #15 0x00005c77bc9d7a9d main (/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc+0x4b2ba9d)
# | #16 0x00007c2f22c2a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
# | #17 0x00007c2f22c2a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
# | #18 0x00005c77bc9d39e5 _start (/home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/llc+0x4b279e5)
# `-----------------------------
# error: command failed with exit status: -6
# executed command: /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/build/bin/FileCheck /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll --check-prefix=MIPS2
# .---command stderr------------
# | /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll:1048:16: error: MIPS2-LABEL: expected string not found in input
# | ; MIPS2-LABEL: test_max_16:
# |                ^
# | <stdin>:154:14: note: scanning from here
# | test_umin_32: 
# |              ^
# | 
# | Input file: <stdin>
# | Check file: /home/buildbot/worker/as-builder-4/ramdisk/expensive-checks/llvm-project/llvm/test/CodeGen/Mips/atomic-min-max.ll
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |           149:  .p2align 2 
# |           150:  .type test_umin_32, at function 
# |           151:  .set nomicromips 
# |           152:  .set nomips16 
# |           153:  .ent test_umin_32 
# |           154: test_umin_32: 
# | label:1048                  X error: no match found
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1
--
********************
```

https://github.com/llvm/llvm-project/pull/149983


More information about the llvm-commits mailing list