[llvm] Reland "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG" (PR #134408)

Nathan Chancellor via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 1 11:52:01 PDT 2025


nathanchance wrote:

I am seeing an assertion failure when building several different distribution configurations of the Linux kernel for x86_64.

```
# bad: [4a509f853fa4821ecdb0f6bc3b90ddd48794cc8c] [libc++] Implement comparison operators for `tuple` added in C++23 (#148799)
# good: [277bcf7ffc79e7d8652dc2c89ce79535b405635a] [ELF][AsmPrinter] Emit trailing dot for constant pool section when it has a hotness prefix (#150859)
git bisect start '4a509f853fa4821ecdb0f6bc3b90ddd48794cc8c' '277bcf7ffc79e7d8652dc2c89ce79535b405635a'
# bad: [4ef92469ab341ac1bee39a9413ffaa845e307414] [libc++][hardening] Add a greppable prefix to assertion messages. (#150560)
git bisect bad 4ef92469ab341ac1bee39a9413ffaa845e307414
# bad: [75e5a705771315bc40d2188675d08cb2c71f6933] [MLIR] Migrate some conversion passes and dialects to LDBG() macro (NFC) (#151349)
git bisect bad 75e5a705771315bc40d2188675d08cb2c71f6933
# good: [20293ebd3159b3964c4466e6ee04d3e9b721eac0] [LLVM][CodeGen][SME] Only emit strided loads in streaming mode. (#150445)
git bisect good 20293ebd3159b3964c4466e6ee04d3e9b721eac0
# bad: [3d4f1fee48689465b5026f75414247307db7d34d] [mlir][spirv] Fix UpdateVCEPass to deduce the correct set of capabilities (#151108)
git bisect bad 3d4f1fee48689465b5026f75414247307db7d34d
# good: [1d6e68e63aa28783ad0de7d0b46238ce95849f2f] [analyzer] Conversion to CheckerFamily: NSOrCFErrorDerefChecker (#151171)
git bisect good 1d6e68e63aa28783ad0de7d0b46238ce95849f2f
# good: [635e6d76530328b8412fbf985708dad26e3f8ea5] [analyzer] Fix FP for cplusplus.placement new #149240 (#150161)
git bisect good 635e6d76530328b8412fbf985708dad26e3f8ea5
# good: [fcbbcffd2e6ea30097809ba0cd1e3b6003fa862f] [llvm-objcopy] [COFF] Ignore associative sections in executables (#151143)
git bisect good fcbbcffd2e6ea30097809ba0cd1e3b6003fa862f
# good: [17c1921b4a78b2ab3f455278c2a057d164863866] [mlir][spirv] Add support for structs decorations (#149793)
git bisect good 17c1921b4a78b2ab3f455278c2a057d164863866
# bad: [bae8f1336db6a7f3288a7dcf253f2d484743b257] Reland "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG" (#134408)
git bisect bad bae8f1336db6a7f3288a7dcf253f2d484743b257
# first bad commit: [bae8f1336db6a7f3288a7dcf253f2d484743b257] Reland "RegisterCoalescer: Add implicit-def of super register when coalescing SUBREG_TO_REG" (#134408)
```

`cvise` spits out:

```c
int __outb_port, __snd_audiopci_probe___trans_tmp_11;
short __outl_port;
static int index;
char id[1];
struct ensoniq {
  int cssr;
} __snd_audiopci_probe_ensoniq;
int *__snd_audiopci_probe_card;
int snd_devm_card_new(int, char *, int **);
void snd_card_rw_proc_new(void(), void());
void snd_ensoniq_proc_read();
int __snd_audiopci_probe() {
  static int dev;
  int err = snd_devm_card_new(index, &id[dev], &__snd_audiopci_probe_card);
  struct ensoniq __trans_tmp_8 = __snd_audiopci_probe_ensoniq,
                 ensoniq = __trans_tmp_8;
  char value = 0;
  asm("out"
      " %"
      "0, %w1"
      :
      : "a"(value), "Nd"(__outb_port));
  {
    int value = ensoniq.cssr;
    asm("out"
        " %"
        "0, %w1"
        :
        : "a"(value), "Nd"(__outl_port));
  }
  snd_card_rw_proc_new(snd_ensoniq_proc_read, 0);
  __snd_audiopci_probe___trans_tmp_11 = err;
  return 0;
}
```

```
$ clang --target=x86_64-linux-gnu -O2 -c -o /dev/null ens1370.i
clang: llvm/lib/CodeGen/RegisterPressure.cpp:1171: void llvm::RegPressureTracker::getUpwardPressureDelta(const MachineInstr *, PressureDiff &, RegPressureDelta &, ArrayRef<PressureChange>, ArrayRef<unsigned int>) const: Assertion `(PDiffI->getUnitInc() >= 0) == (PNew >= POld) && "PSet overflow/underflow"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: clang --target=x86_64-linux-gnu -O2 -c -o /dev/null ens1370.i
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'ens1370.i'.
4.      Running pass 'Machine Instruction Scheduler' on function '@__snd_audiopci_probe'
 #0 0x0000559069ae68b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (clang-22+0x34ae8b8)
 #1 0x0000559069ae3ff5 llvm::sys::RunSignalHandlers() (clang-22+0x34abff5)
 #2 0x0000559069a65946 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f919583e540 (/usr/lib/libc.so.6+0x3e540)
 #4 0x00007f919589894c (/usr/lib/libc.so.6+0x9894c)
 #5 0x00007f919583e410 raise (/usr/lib/libc.so.6+0x3e410)
 #6 0x00007f919582557a abort (/usr/lib/libc.so.6+0x2557a)
 #7 0x00007f91958254e3 __assert_perror_fail (/usr/lib/libc.so.6+0x254e3)
 #8 0x0000559069235abe llvm::RegPressureTracker::getUpwardPressureDelta(llvm::MachineInstr const*, llvm::PressureDiff&, llvm::RegPressureDelta&, llvm::ArrayRef<llvm::PressureChange>, llvm::ArrayRef<unsigned int>) const (clang-22+0x2bfdabe)
 #9 0x00005590690cd502 llvm::GenericScheduler::initCandidate(llvm::GenericSchedulerBase::SchedCandidate&, llvm::SUnit*, bool, llvm::RegPressureTracker const&, llvm::RegPressureTracker&) (clang-22+0x2a95502)
#10 0x00005590690cdb50 llvm::GenericScheduler::pickNodeFromQueue(llvm::SchedBoundary&, llvm::GenericSchedulerBase::CandPolicy const&, llvm::RegPressureTracker const&, llvm::GenericSchedulerBase::SchedCandidate&) (clang-22+0x2a95b50)
#11 0x00005590690cea83 llvm::GenericScheduler::pickNode(bool&) (clang-22+0x2a96a83)
#12 0x00005590690c4752 llvm::ScheduleDAGMILive::schedule() (clang-22+0x2a8c752)
#13 0x00005590690bc56a llvm::impl_detail::MachineSchedulerBase::scheduleRegions(llvm::ScheduleDAGInstrs&, bool) (clang-22+0x2a8456a)
#14 0x00005590690bbf4e llvm::impl_detail::MachineSchedulerImpl::run(llvm::MachineFunction&, llvm::TargetMachine const&, llvm::impl_detail::MachineSchedulerImpl::RequiredAnalyses const&) (clang-22+0x2a83f4e)
#15 0x00005590690d23e6 (anonymous namespace)::MachineSchedulerLegacy::runOnMachineFunction(llvm::MachineFunction&) MachineScheduler.cpp:0:0
#16 0x0000559069049623 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (clang-22+0x2a11623)
#17 0x00005590695e6b05 llvm::FPPassManager::runOnFunction(llvm::Function&) (clang-22+0x2faeb05)
#18 0x00005590695ee742 llvm::FPPassManager::runOnModule(llvm::Module&) (clang-22+0x2fb6742)
#19 0x00005590695e74c0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (clang-22+0x2faf4c0)
#20 0x000055906a2268d3 clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (clang-22+0x3bee8d3)
#21 0x000055906a23c655 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (clang-22+0x3c04655)
#22 0x000055906b8a87e9 clang::ParseAST(clang::Sema&, bool, bool) (clang-22+0x52707e9)
#23 0x000055906a7b36e6 clang::FrontendAction::Execute() (clang-22+0x417b6e6)
#24 0x000055906a7221ed clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (clang-22+0x40ea1ed)
#25 0x000055906a8854cc clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (clang-22+0x424d4cc)
#26 0x00005590688055f7 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (clang-22+0x21cd5f7)
#27 0x000055906880149f ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x000055906a587269 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
#29 0x0000559069a6562e llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (clang-22+0x342d62e)
#30 0x000055906a586aa3 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (clang-22+0x3f4eaa3)
#31 0x000055906a547cfc clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (clang-22+0x3f0fcfc)
#32 0x000055906a547f17 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (clang-22+0x3f0ff17)
#33 0x000055906a564698 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (clang-22+0x3f2c698)
#34 0x0000559068800d43 clang_main(int, char**, llvm::ToolContext const&) (clang-22+0x21c8d43)
#35 0x0000559068811457 main (clang-22+0x21d9457)
#36 0x00007f9195827675 (/usr/lib/libc.so.6+0x27675)
#37 0x00007f9195827729 __libc_start_main (/usr/lib/libc.so.6+0x27729)
#38 0x00005590687fef25 _start (clang-22+0x21c6f25)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
```

`llvm-reduce` spits out the following from the reproducer above:

```llvm
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i32 @__snd_audiopci_probe() {
entry:
  %call = tail call i32 null(i32 0, ptr null, ptr null)
  %__trans_tmp_8.sroa.0.0.copyload = load i32, ptr null, align 4
  tail call void asm sideeffect "out $0, ${1:w}", "{ax},N{dx},~{dirflag},~{fpsr},~{flags}"(i8 0, i32 0)
  %0 = load i16, ptr null, align 2
  tail call void asm sideeffect "out $0, ${1:w}", "{ax},N{dx},~{dirflag},~{fpsr},~{flags}"(i32 %__trans_tmp_8.sroa.0.0.copyload, i16 %0)
  ret i32 0
}
```

```
$ llc -o /dev/null reduced.ll
llc: llvm/lib/CodeGen/RegisterPressure.cpp:1171: void llvm::RegPressureTracker::getUpwardPressureDelta(const MachineInstr *, PressureDiff &, RegPressureDelta &, ArrayRef<PressureChange>, ArrayRef<unsigned int>) const: Assertion `(PDiffI->getUnitInc() >= 0) == (PNew >= POld) && "PSet overflow/underflow"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: llc -o /dev/null reduced.ll
1.      Running pass 'Function Pass Manager' on module 'reduced.ll'.
2.      Running pass 'Machine Instruction Scheduler' on function '@__snd_audiopci_probe'
 #0 0x000056083bb094c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (llc+0x32574c8)
 #1 0x000056083bb06b95 llvm::sys::RunSignalHandlers() (llc+0x3254b95)
 #2 0x000056083bb0a271 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f90c603e540 (/usr/lib/libc.so.6+0x3e540)
 #4 0x00007f90c609894c (/usr/lib/libc.so.6+0x9894c)
 #5 0x00007f90c603e410 raise (/usr/lib/libc.so.6+0x3e410)
 #6 0x00007f90c602557a abort (/usr/lib/libc.so.6+0x2557a)
 #7 0x00007f90c60254e3 __assert_perror_fail (/usr/lib/libc.so.6+0x254e3)
 #8 0x000056083ad6fade llvm::RegPressureTracker::getUpwardPressureDelta(llvm::MachineInstr const*, llvm::PressureDiff&, llvm::RegPressureDelta&, llvm::ArrayRef<llvm::PressureChange>, llvm::ArrayRef<unsigned int>) const (llc+0x24bdade)
 #9 0x000056083abc6452 llvm::GenericScheduler::initCandidate(llvm::GenericSchedulerBase::SchedCandidate&, llvm::SUnit*, bool, llvm::RegPressureTracker const&, llvm::RegPressureTracker&) (llc+0x2314452)
#10 0x000056083abc6aa0 llvm::GenericScheduler::pickNodeFromQueue(llvm::SchedBoundary&, llvm::GenericSchedulerBase::CandPolicy const&, llvm::RegPressureTracker const&, llvm::GenericSchedulerBase::SchedCandidate&) (llc+0x2314aa0)
#11 0x000056083abc79d3 llvm::GenericScheduler::pickNode(bool&) (llc+0x23159d3)
#12 0x000056083abbd3e2 llvm::ScheduleDAGMILive::schedule() (llc+0x230b3e2)
#13 0x000056083abb520a llvm::impl_detail::MachineSchedulerBase::scheduleRegions(llvm::ScheduleDAGInstrs&, bool) (llc+0x230320a)
#14 0x000056083abb4bee llvm::impl_detail::MachineSchedulerImpl::run(llvm::MachineFunction&, llvm::TargetMachine const&, llvm::impl_detail::MachineSchedulerImpl::RequiredAnalyses const&) (llc+0x2302bee)
#15 0x000056083abcb456 (anonymous namespace)::MachineSchedulerLegacy::runOnMachineFunction(llvm::MachineFunction&) MachineScheduler.cpp:0:0
#16 0x000056083aadd083 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (llc+0x222b083)
#17 0x000056083b0696a5 llvm::FPPassManager::runOnFunction(llvm::Function&) (llc+0x27b76a5)
#18 0x000056083b071482 llvm::FPPassManager::runOnModule(llvm::Module&) (llc+0x27bf482)
#19 0x000056083b06a0f0 llvm::legacy::PassManagerImpl::run(llvm::Module&) (llc+0x27b80f0)
#20 0x000056083a1756fe compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#21 0x000056083a172edd main (llc+0x18c0edd)
#22 0x00007f90c6027675 (/usr/lib/libc.so.6+0x27675)
#23 0x00007f90c6027729 __libc_start_main (/usr/lib/libc.so.6+0x27729)
#24 0x000056083a16ee65 _start (llc+0x18bce65)
```

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


More information about the llvm-commits mailing list