llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.93k stars 11.53k forks source link

MIR fails verifier when regalloc produces error: inline assembly requires more registers than available #46262

Open arsenm opened 4 years ago

arsenm commented 4 years ago
Bugzilla Link 46918
Version trunk
OS Linux
Attachments Testcase
CC @qcolombet

Extended Description

The register allocator currently produces MIR that fails the verifier when it can't handle inline assembly. It produces the user error in the context, and then has to produce something and keep going. The MIR should pass the verifier so the compilation can reach the end successfully. I'm not sure whether it would be better to hack up the code to avoid failing the verifier, or to change the verifier check for the error and disable the liveness checks.

llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs

arsenm commented 4 years ago

Asserting variant

arsenm commented 4 years ago

A related case also hits this asserT:

error: inline assembly requires more registers than available llc: /home/matt/src/llvm-project/llvm/include/llvm/MC/MCRegisterInfo.h:677: llvm::MCRegUnitIterator::MCRegUnitIterator(llvm::MCRegister, const llvm::MCRegisterInfo *): Assertion `Reg && "Null register has no regunits"' failed.

arsenm commented 1 year ago

Seems partially fixed, still hits this:

*** Bad machine code: Using an undefined physical register ***
- function:    too_many_regs
- basic block: %bb.0  (0x80f9eb0) [0B;1040B)
- instruction: 544B SI_SPILL_V256_SAVE killed $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7, %stack.1, $sgpr32, 0, implicit $exec :: (store (s256) into %stack.1, align 4, addrspace 5)
- operand 0:   killed $vgpr0_vgpr1_vgpr2_vgpr3_vgpr4_vgpr5_vgpr6_vgpr7
LLVM ERROR: Found 1 machine code errors.