[RISCV] Fix the bug in the register allocator caused by reserved BP.
authorHsiangkai Wang <hsiangkai@google.com>
Wed, 19 Jan 2022 11:32:27 +0000 (11:32 +0000)
committerHsiangkai Wang <hsiangkai@google.com>
Fri, 21 Jan 2022 01:23:01 +0000 (01:23 +0000)
commitad06e65dc4da45be2cda3e07664502651679622a
treee2d2f28cb227986103c1921ccf6d2b99776df4f1
parentd1123e36922d18e2b93b01e85ef706bc8f819fb5
[RISCV] Fix the bug in the register allocator caused by reserved BP.

Originally, hasRVVFrameObject() will scan all the stack objects to check
whether if there is any scalable vector object on the stack or not.
However, it causes errors in the register allocator. In issue 53016, it
returns false before RA because there is no RVV stack objects. After RA,
it returns true because there are spilling slots for RVV values during RA.
The compiler will not reserve BP during register allocation and generate BP
access in the PEI pass due to the inconsistent behavior of the function.

The function is changed to use hasStdExtV() as the return value. It is
not precise, but it can make the register allocation correct.

Refer to https://github.com/llvm/llvm-project/issues/53016.

Differential Revision: https://reviews.llvm.org/D117663
llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
llvm/test/CodeGen/RISCV/rvv/emergency-slot.mir
llvm/test/CodeGen/RISCV/rvv/fixed-vectors-calling-conv.ll
llvm/test/CodeGen/RISCV/rvv/reg-alloc-reserve-bp.ll
llvm/test/CodeGen/RISCV/srem-seteq-illegal-types.ll