[MIPS] `llc` crashes with "Using an undefined physical register" when using global register variable
Description
-
Save the following piece of C code:
register long reg28 __asm__("$28"); long foo() { return reg28; } -
Compile the code to LLVM IR:
clang --target=mipsel-linux mips.c -S -emit-llvm -o mips.ll -
Attempt to compile it using llc with assersions:
llc --mtriple=mipsel-linux mips.ll -
llc crashes.
However, direct compilation from C to assembly works correctly and produces valid assembly that uses the $gp register as expected.
https://llvm.godbolt.org/z/qvrvfzz8v https://godbolt.org/z/v5xMf5PKe
LLVM Version:
trunk
Backtrace
# Machine code for function foo: NoPHIs, TracksLiveness, TiedOpsRewritten, TracksDebugUserValues
bb.0.entry:
%0:gpr32 = COPY $gp
$v0 = COPY %0:gpr32
RetRA implicit killed $v0
# End machine code for function foo.
*** Bad machine code: Using an undefined physical register ***
- function: foo
- basic block: %bb.0 entry (0x56285e7c66c0)
- instruction: %0:gpr32 = COPY $gp
- operand 1: $gp
LLVM ERROR: Found 1 machine code errors.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: llvm-build-debug/bin/llc --mtriple=mipsel-linux mips1.ll
1. Running pass 'Function Pass Manager' on module 'mips1.ll'.
2. Running pass 'Greedy Register Allocator' on function '@foo'
#0 0x0000562859a0a5e9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /llvm-project/llvm/lib/Support/Unix/Signals.inc:804:11
#1 0x0000562859a0aa9b PrintStackTraceSignalHandler(void*) /llvm-project/llvm/lib/Support/Unix/Signals.inc:880:1
#2 0x0000562859a08c9f llvm::sys::RunSignalHandlers() /llvm-project/llvm/lib/Support/Signals.cpp:105:5
#3 0x0000562859a0b199 SignalHandler(int, siginfo_t*, void*) /llvm-project/llvm/lib/Support/Unix/Signals.inc:418:7
#4 0x00007f0f64644520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x00007f0f646989fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#6 0x00007f0f646989fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#7 0x00007f0f646989fc pthread_kill ./nptl/pthread_kill.c:89:10
#8 0x00007f0f64644476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#9 0x00007f0f6462a7f3 abort ./stdlib/abort.c:81:7
#10 0x00005628599370dc llvm::report_fatal_error(llvm::Twine const&, bool) /llvm-project/llvm/lib/Support/ErrorHandling.cpp:126:5
#11 0x0000562858585323 (anonymous namespace)::MachineVerifier::ReportedErrors::~ReportedErrors() /llvm-project/llvm/lib/CodeGen/MachineVerifier.cpp:262:7
#12 0x00005628585846d0 (anonymous namespace)::MachineVerifier::~MachineVerifier() /llvm-project/llvm/lib/CodeGen/MachineVerifier.cpp:102:8
#13 0x0000562858584b84 llvm::MachineFunction::verify(llvm::Pass*, char const*, llvm::raw_ostream*, bool) const /llvm-project/llvm/lib/CodeGen/MachineVerifier.cpp:431:3
#14 0x00005628582fb748 llvm::LiveRangeCalc::findReachingDefs(llvm::LiveRange&, llvm::MachineBasicBlock&, llvm::SlotIndex, llvm::Register, llvm::ArrayRef<llvm::SlotIndex>) /llvm-project/llvm/lib/CodeGen/LiveRangeCalc.cpp:211:7
#15 0x00005628582fb5f7 llvm::LiveRangeCalc::extend(llvm::LiveRange&, llvm::SlotIndex, llvm::Register, llvm::ArrayRef<llvm::SlotIndex>) /llvm-project/llvm/lib/CodeGen/LiveRangeCalc.cpp:104:7
#16 0x00005628583004df llvm::LiveIntervalCalc::extendToUses(llvm::LiveRange&, llvm::Register, llvm::LaneBitmask, llvm::LiveInterval*) /llvm-project/llvm/lib/CodeGen/LiveIntervalCalc.cpp:145:27
#17 0x00005628582ddfa7 llvm::LiveIntervalCalc::extendToUses(llvm::LiveRange&, llvm::MCRegister) /llvm-project/llvm/include/llvm/CodeGen/LiveIntervalCalc.h:56:3
#18 0x00005628582d8532 llvm::LiveIntervals::computeRegUnitRange(llvm::LiveRange&, unsigned int) /llvm-project/llvm/lib/CodeGen/LiveIntervals.cpp:341:7
#19 0x00005628582ddaca llvm::LiveIntervals::getRegUnit(unsigned int) /llvm-project/llvm/include/llvm/CodeGen/LiveIntervals.h:422:13
#20 0x0000562858305d8e llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister)::$_0::operator()(unsigned int, llvm::LiveRange const&) const /llvm-project/llvm/lib/CodeGen/LiveRegMatrix.cpp:180:39
#21 0x0000562858305221 bool foreachUnit<llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister)::$_0>(llvm::TargetRegisterInfo const*, llvm::LiveInterval const&, llvm::MCRegister, llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister)::$_0) /llvm-project/llvm/lib/CodeGen/LiveRegMatrix.cpp:104:11
#22 0x0000562858304ff7 llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister) /llvm-project/llvm/lib/CodeGen/LiveRegMatrix.cpp:178:8
#23 0x0000562858305341 llvm::LiveRegMatrix::checkInterference(llvm::LiveInterval const&, llvm::MCRegister) /llvm-project/llvm/lib/CodeGen/LiveRegMatrix.cpp:204:7
#24 0x00005628586a9daf llvm::RAGreedy::tryAssign(llvm::LiveInterval const&, llvm::AllocationOrder&, llvm::SmallVectorImpl<llvm::Register>&, llvm::SmallSet<llvm::Register, 16u, std::less<llvm::Register>> const&) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:556:10
#25 0x00005628586b294a llvm::RAGreedy::selectOrSplitImpl(llvm::LiveInterval const&, llvm::SmallVectorImpl<llvm::Register>&, llvm::SmallSet<llvm::Register, 16u, std::less<llvm::Register>>&, llvm::SmallVector<std::pair<llvm::LiveInterval const*, llvm::MCRegister>, 8u>&, unsigned int) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:2583:11
#26 0x00005628586b336e llvm::RAGreedy::selectOrSplit(llvm::LiveInterval const&, llvm::SmallVectorImpl<llvm::Register>&) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:2312:7
#27 0x00005628589d1025 llvm::RegAllocBase::allocatePhysRegs() /llvm-project/llvm/lib/CodeGen/RegAllocBase.cpp:115:35
#28 0x00005628586a9059 llvm::RAGreedy::run(llvm::MachineFunction&) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:2925:3
#29 0x00005628586b5bf1 (anonymous namespace)::RAGreedyLegacy::runOnMachineFunction(llvm::MachineFunction&) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:298:15
#30 0x000056285840def2 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:108:8
#31 0x0000562858c319ef llvm::FPPassManager::runOnFunction(llvm::Function&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1406:23
#32 0x0000562858c3608b llvm::FPPassManager::runOnModule(llvm::Module&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1452:16
#33 0x0000562858c32269 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1521:23
#34 0x0000562858c31e16 llvm::legacy::PassManagerImpl::run(llvm::Module&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:539:16
#35 0x0000562858c36331 llvm::legacy::PassManager::run(llvm::Module&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1648:3
#36 0x0000562857342e40 compileModule(char**, llvm::LLVMContext&) /llvm-project/llvm/tools/llc/llc.cpp:755:9
#37 0x0000562857341065 main /llvm-project/llvm/tools/llc/llc.cpp:400:13
#38 0x00007f0f6462bd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#39 0x00007f0f6462be40 call_init ./csu/../csu/libc-start.c:128:20
#40 0x00007f0f6462be40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#41 0x0000562857340845 _start (/llvm-build-debug/bin/llc+0xda1845)
[1] 746812 IOT instruction (core dumped) llvm-build-debug/bin/llc --mtriple=mipsel-linux mips1.ll
@llvm/issue-subscribers-backend-mips
Author: Iris (el-ev)
-
Save the following piece of C code:
register long reg28 __asm__("$28"); long foo() { return reg28; } -
Compile the code to LLVM IR:
clang --target=mipsel-linux mips.c -S -emit-llvm -o mips.ll -
Attempt to compile it using llc with assersions:
llc --mtriple=mipsel-linux mips.ll -
llc crashes.
However, direct compilation from C to assembly works correctly and produces valid assembly that uses the $gp register as expected.
https://llvm.godbolt.org/z/qvrvfzz8v https://godbolt.org/z/v5xMf5PKe
LLVM Version:
trunk
Backtrace
# Machine code for function foo: NoPHIs, TracksLiveness, TiedOpsRewritten, TracksDebugUserValues
bb.0.entry:
%0:gpr32 = COPY $gp
$v0 = COPY %0:gpr32
RetRA implicit killed $v0
# End machine code for function foo.
*** Bad machine code: Using an undefined physical register ***
- function: foo
- basic block: %bb.0 entry (0x56285e7c66c0)
- instruction: %0:gpr32 = COPY $gp
- operand 1: $gp
LLVM ERROR: Found 1 machine code errors.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: llvm-build-debug/bin/llc --mtriple=mipsel-linux mips1.ll
1. Running pass 'Function Pass Manager' on module 'mips1.ll'.
2. Running pass 'Greedy Register Allocator' on function '@<!-- -->foo'
#<!-- -->0 0x0000562859a0a5e9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /llvm-project/llvm/lib/Support/Unix/Signals.inc:804:11
#<!-- -->1 0x0000562859a0aa9b PrintStackTraceSignalHandler(void*) /llvm-project/llvm/lib/Support/Unix/Signals.inc:880:1
#<!-- -->2 0x0000562859a08c9f llvm::sys::RunSignalHandlers() /llvm-project/llvm/lib/Support/Signals.cpp:105:5
#<!-- -->3 0x0000562859a0b199 SignalHandler(int, siginfo_t*, void*) /llvm-project/llvm/lib/Support/Unix/Signals.inc:418:7
#<!-- -->4 0x00007f0f64644520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#<!-- -->5 0x00007f0f646989fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#<!-- -->6 0x00007f0f646989fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#<!-- -->7 0x00007f0f646989fc pthread_kill ./nptl/pthread_kill.c:89:10
#<!-- -->8 0x00007f0f64644476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#<!-- -->9 0x00007f0f6462a7f3 abort ./stdlib/abort.c:81:7
#<!-- -->10 0x00005628599370dc llvm::report_fatal_error(llvm::Twine const&, bool) /llvm-project/llvm/lib/Support/ErrorHandling.cpp:126:5
#<!-- -->11 0x0000562858585323 (anonymous namespace)::MachineVerifier::ReportedErrors::~ReportedErrors() /llvm-project/llvm/lib/CodeGen/MachineVerifier.cpp:262:7
#<!-- -->12 0x00005628585846d0 (anonymous namespace)::MachineVerifier::~MachineVerifier() /llvm-project/llvm/lib/CodeGen/MachineVerifier.cpp:102:8
#<!-- -->13 0x0000562858584b84 llvm::MachineFunction::verify(llvm::Pass*, char const*, llvm::raw_ostream*, bool) const /llvm-project/llvm/lib/CodeGen/MachineVerifier.cpp:431:3
#<!-- -->14 0x00005628582fb748 llvm::LiveRangeCalc::findReachingDefs(llvm::LiveRange&, llvm::MachineBasicBlock&, llvm::SlotIndex, llvm::Register, llvm::ArrayRef<llvm::SlotIndex>) /llvm-project/llvm/lib/CodeGen/LiveRangeCalc.cpp:211:7
#<!-- -->15 0x00005628582fb5f7 llvm::LiveRangeCalc::extend(llvm::LiveRange&, llvm::SlotIndex, llvm::Register, llvm::ArrayRef<llvm::SlotIndex>) /llvm-project/llvm/lib/CodeGen/LiveRangeCalc.cpp:104:7
#<!-- -->16 0x00005628583004df llvm::LiveIntervalCalc::extendToUses(llvm::LiveRange&, llvm::Register, llvm::LaneBitmask, llvm::LiveInterval*) /llvm-project/llvm/lib/CodeGen/LiveIntervalCalc.cpp:145:27
#<!-- -->17 0x00005628582ddfa7 llvm::LiveIntervalCalc::extendToUses(llvm::LiveRange&, llvm::MCRegister) /llvm-project/llvm/include/llvm/CodeGen/LiveIntervalCalc.h:56:3
#<!-- -->18 0x00005628582d8532 llvm::LiveIntervals::computeRegUnitRange(llvm::LiveRange&, unsigned int) /llvm-project/llvm/lib/CodeGen/LiveIntervals.cpp:341:7
#<!-- -->19 0x00005628582ddaca llvm::LiveIntervals::getRegUnit(unsigned int) /llvm-project/llvm/include/llvm/CodeGen/LiveIntervals.h:422:13
#<!-- -->20 0x0000562858305d8e llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister)::$_0::operator()(unsigned int, llvm::LiveRange const&) const /llvm-project/llvm/lib/CodeGen/LiveRegMatrix.cpp:180:39
#<!-- -->21 0x0000562858305221 bool foreachUnit<llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister)::$_0>(llvm::TargetRegisterInfo const*, llvm::LiveInterval const&, llvm::MCRegister, llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister)::$_0) /llvm-project/llvm/lib/CodeGen/LiveRegMatrix.cpp:104:11
#<!-- -->22 0x0000562858304ff7 llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister) /llvm-project/llvm/lib/CodeGen/LiveRegMatrix.cpp:178:8
#<!-- -->23 0x0000562858305341 llvm::LiveRegMatrix::checkInterference(llvm::LiveInterval const&, llvm::MCRegister) /llvm-project/llvm/lib/CodeGen/LiveRegMatrix.cpp:204:7
#<!-- -->24 0x00005628586a9daf llvm::RAGreedy::tryAssign(llvm::LiveInterval const&, llvm::AllocationOrder&, llvm::SmallVectorImpl<llvm::Register>&, llvm::SmallSet<llvm::Register, 16u, std::less<llvm::Register>> const&) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:556:10
#<!-- -->25 0x00005628586b294a llvm::RAGreedy::selectOrSplitImpl(llvm::LiveInterval const&, llvm::SmallVectorImpl<llvm::Register>&, llvm::SmallSet<llvm::Register, 16u, std::less<llvm::Register>>&, llvm::SmallVector<std::pair<llvm::LiveInterval const*, llvm::MCRegister>, 8u>&, unsigned int) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:2583:11
#<!-- -->26 0x00005628586b336e llvm::RAGreedy::selectOrSplit(llvm::LiveInterval const&, llvm::SmallVectorImpl<llvm::Register>&) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:2312:7
#<!-- -->27 0x00005628589d1025 llvm::RegAllocBase::allocatePhysRegs() /llvm-project/llvm/lib/CodeGen/RegAllocBase.cpp:115:35
#<!-- -->28 0x00005628586a9059 llvm::RAGreedy::run(llvm::MachineFunction&) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:2925:3
#<!-- -->29 0x00005628586b5bf1 (anonymous namespace)::RAGreedyLegacy::runOnMachineFunction(llvm::MachineFunction&) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:298:15
#<!-- -->30 0x000056285840def2 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:108:8
#<!-- -->31 0x0000562858c319ef llvm::FPPassManager::runOnFunction(llvm::Function&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1406:23
#<!-- -->32 0x0000562858c3608b llvm::FPPassManager::runOnModule(llvm::Module&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1452:16
#<!-- -->33 0x0000562858c32269 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1521:23
#<!-- -->34 0x0000562858c31e16 llvm::legacy::PassManagerImpl::run(llvm::Module&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:539:16
#<!-- -->35 0x0000562858c36331 llvm::legacy::PassManager::run(llvm::Module&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1648:3
#<!-- -->36 0x0000562857342e40 compileModule(char**, llvm::LLVMContext&) /llvm-project/llvm/tools/llc/llc.cpp:755:9
#<!-- -->37 0x0000562857341065 main /llvm-project/llvm/tools/llc/llc.cpp:400:13
#<!-- -->38 0x00007f0f6462bd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#<!-- -->39 0x00007f0f6462be40 call_init ./csu/../csu/libc-start.c:128:20
#<!-- -->40 0x00007f0f6462be40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#<!-- -->41 0x0000562857340845 _start (/llvm-build-debug/bin/llc+0xda1845)
[1] 746812 IOT instruction (core dumped) llvm-build-debug/bin/llc --mtriple=mipsel-linux mips1.ll
@llvm/issue-subscribers-bug
Author: Iris (el-ev)
-
Save the following piece of C code:
register long reg28 __asm__("$28"); long foo() { return reg28; } -
Compile the code to LLVM IR:
clang --target=mipsel-linux mips.c -S -emit-llvm -o mips.ll -
Attempt to compile it using llc with assersions:
llc --mtriple=mipsel-linux mips.ll -
llc crashes.
However, direct compilation from C to assembly works correctly and produces valid assembly that uses the $gp register as expected.
https://llvm.godbolt.org/z/qvrvfzz8v https://godbolt.org/z/v5xMf5PKe
LLVM Version:
trunk
Backtrace
# Machine code for function foo: NoPHIs, TracksLiveness, TiedOpsRewritten, TracksDebugUserValues
bb.0.entry:
%0:gpr32 = COPY $gp
$v0 = COPY %0:gpr32
RetRA implicit killed $v0
# End machine code for function foo.
*** Bad machine code: Using an undefined physical register ***
- function: foo
- basic block: %bb.0 entry (0x56285e7c66c0)
- instruction: %0:gpr32 = COPY $gp
- operand 1: $gp
LLVM ERROR: Found 1 machine code errors.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: llvm-build-debug/bin/llc --mtriple=mipsel-linux mips1.ll
1. Running pass 'Function Pass Manager' on module 'mips1.ll'.
2. Running pass 'Greedy Register Allocator' on function '@<!-- -->foo'
#<!-- -->0 0x0000562859a0a5e9 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /llvm-project/llvm/lib/Support/Unix/Signals.inc:804:11
#<!-- -->1 0x0000562859a0aa9b PrintStackTraceSignalHandler(void*) /llvm-project/llvm/lib/Support/Unix/Signals.inc:880:1
#<!-- -->2 0x0000562859a08c9f llvm::sys::RunSignalHandlers() /llvm-project/llvm/lib/Support/Signals.cpp:105:5
#<!-- -->3 0x0000562859a0b199 SignalHandler(int, siginfo_t*, void*) /llvm-project/llvm/lib/Support/Unix/Signals.inc:418:7
#<!-- -->4 0x00007f0f64644520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#<!-- -->5 0x00007f0f646989fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#<!-- -->6 0x00007f0f646989fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#<!-- -->7 0x00007f0f646989fc pthread_kill ./nptl/pthread_kill.c:89:10
#<!-- -->8 0x00007f0f64644476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#<!-- -->9 0x00007f0f6462a7f3 abort ./stdlib/abort.c:81:7
#<!-- -->10 0x00005628599370dc llvm::report_fatal_error(llvm::Twine const&, bool) /llvm-project/llvm/lib/Support/ErrorHandling.cpp:126:5
#<!-- -->11 0x0000562858585323 (anonymous namespace)::MachineVerifier::ReportedErrors::~ReportedErrors() /llvm-project/llvm/lib/CodeGen/MachineVerifier.cpp:262:7
#<!-- -->12 0x00005628585846d0 (anonymous namespace)::MachineVerifier::~MachineVerifier() /llvm-project/llvm/lib/CodeGen/MachineVerifier.cpp:102:8
#<!-- -->13 0x0000562858584b84 llvm::MachineFunction::verify(llvm::Pass*, char const*, llvm::raw_ostream*, bool) const /llvm-project/llvm/lib/CodeGen/MachineVerifier.cpp:431:3
#<!-- -->14 0x00005628582fb748 llvm::LiveRangeCalc::findReachingDefs(llvm::LiveRange&, llvm::MachineBasicBlock&, llvm::SlotIndex, llvm::Register, llvm::ArrayRef<llvm::SlotIndex>) /llvm-project/llvm/lib/CodeGen/LiveRangeCalc.cpp:211:7
#<!-- -->15 0x00005628582fb5f7 llvm::LiveRangeCalc::extend(llvm::LiveRange&, llvm::SlotIndex, llvm::Register, llvm::ArrayRef<llvm::SlotIndex>) /llvm-project/llvm/lib/CodeGen/LiveRangeCalc.cpp:104:7
#<!-- -->16 0x00005628583004df llvm::LiveIntervalCalc::extendToUses(llvm::LiveRange&, llvm::Register, llvm::LaneBitmask, llvm::LiveInterval*) /llvm-project/llvm/lib/CodeGen/LiveIntervalCalc.cpp:145:27
#<!-- -->17 0x00005628582ddfa7 llvm::LiveIntervalCalc::extendToUses(llvm::LiveRange&, llvm::MCRegister) /llvm-project/llvm/include/llvm/CodeGen/LiveIntervalCalc.h:56:3
#<!-- -->18 0x00005628582d8532 llvm::LiveIntervals::computeRegUnitRange(llvm::LiveRange&, unsigned int) /llvm-project/llvm/lib/CodeGen/LiveIntervals.cpp:341:7
#<!-- -->19 0x00005628582ddaca llvm::LiveIntervals::getRegUnit(unsigned int) /llvm-project/llvm/include/llvm/CodeGen/LiveIntervals.h:422:13
#<!-- -->20 0x0000562858305d8e llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister)::$_0::operator()(unsigned int, llvm::LiveRange const&) const /llvm-project/llvm/lib/CodeGen/LiveRegMatrix.cpp:180:39
#<!-- -->21 0x0000562858305221 bool foreachUnit<llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister)::$_0>(llvm::TargetRegisterInfo const*, llvm::LiveInterval const&, llvm::MCRegister, llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister)::$_0) /llvm-project/llvm/lib/CodeGen/LiveRegMatrix.cpp:104:11
#<!-- -->22 0x0000562858304ff7 llvm::LiveRegMatrix::checkRegUnitInterference(llvm::LiveInterval const&, llvm::MCRegister) /llvm-project/llvm/lib/CodeGen/LiveRegMatrix.cpp:178:8
#<!-- -->23 0x0000562858305341 llvm::LiveRegMatrix::checkInterference(llvm::LiveInterval const&, llvm::MCRegister) /llvm-project/llvm/lib/CodeGen/LiveRegMatrix.cpp:204:7
#<!-- -->24 0x00005628586a9daf llvm::RAGreedy::tryAssign(llvm::LiveInterval const&, llvm::AllocationOrder&, llvm::SmallVectorImpl<llvm::Register>&, llvm::SmallSet<llvm::Register, 16u, std::less<llvm::Register>> const&) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:556:10
#<!-- -->25 0x00005628586b294a llvm::RAGreedy::selectOrSplitImpl(llvm::LiveInterval const&, llvm::SmallVectorImpl<llvm::Register>&, llvm::SmallSet<llvm::Register, 16u, std::less<llvm::Register>>&, llvm::SmallVector<std::pair<llvm::LiveInterval const*, llvm::MCRegister>, 8u>&, unsigned int) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:2583:11
#<!-- -->26 0x00005628586b336e llvm::RAGreedy::selectOrSplit(llvm::LiveInterval const&, llvm::SmallVectorImpl<llvm::Register>&) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:2312:7
#<!-- -->27 0x00005628589d1025 llvm::RegAllocBase::allocatePhysRegs() /llvm-project/llvm/lib/CodeGen/RegAllocBase.cpp:115:35
#<!-- -->28 0x00005628586a9059 llvm::RAGreedy::run(llvm::MachineFunction&) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:2925:3
#<!-- -->29 0x00005628586b5bf1 (anonymous namespace)::RAGreedyLegacy::runOnMachineFunction(llvm::MachineFunction&) /llvm-project/llvm/lib/CodeGen/RegAllocGreedy.cpp:298:15
#<!-- -->30 0x000056285840def2 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:108:8
#<!-- -->31 0x0000562858c319ef llvm::FPPassManager::runOnFunction(llvm::Function&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1406:23
#<!-- -->32 0x0000562858c3608b llvm::FPPassManager::runOnModule(llvm::Module&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1452:16
#<!-- -->33 0x0000562858c32269 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1521:23
#<!-- -->34 0x0000562858c31e16 llvm::legacy::PassManagerImpl::run(llvm::Module&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:539:16
#<!-- -->35 0x0000562858c36331 llvm::legacy::PassManager::run(llvm::Module&) /llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1648:3
#<!-- -->36 0x0000562857342e40 compileModule(char**, llvm::LLVMContext&) /llvm-project/llvm/tools/llc/llc.cpp:755:9
#<!-- -->37 0x0000562857341065 main /llvm-project/llvm/tools/llc/llc.cpp:400:13
#<!-- -->38 0x00007f0f6462bd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#<!-- -->39 0x00007f0f6462be40 call_init ./csu/../csu/libc-start.c:128:20
#<!-- -->40 0x00007f0f6462be40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#<!-- -->41 0x0000562857340845 _start (/llvm-build-debug/bin/llc+0xda1845)
[1] 746812 IOT instruction (core dumped) llvm-build-debug/bin/llc --mtriple=mipsel-linux mips1.ll
cc @yingopq
When append -O3 to clang, would also generate this error;
When append -mattr=+noabicalls to llc, would be OK.
And I checked the Mips backend code, we only reserve $gp when enable -mattr=+noabicalls.
So did you think this issue can be closed since appending -mattr=+noabicalls to llc would be OK.