[llvm-dev] Problem of getting two unused registers in eliminateFrameIndex()
Ehsan Ali via llvm-dev
llvm-dev at lists.llvm.org
Mon Aug 14 18:39:40 PDT 2017
Hello all,
For my custom processor backend I am trying add some instruction using
BuildMI() inside eliminateFrameIndex().
I tried RegScavenger like this:
unsigned RegUnused0 = RS->FindUnusedReg(&LASER::GNPRegsRegClass);
if (!RegUnused0)
RegUnused0 = RS->scavengeRegister(&LASER::GNPRegsRegClass, II, SPAdj);
assert(RegUnused0 && "Register scavenger failed");
RS->setRegUsed(RegUnused0);
It works but there are two issues:
1) I need to registers and RegScavenger only returns one.
2) I cannot unset the used register and I get spill slot error message
when I ran out of the available registers.
So I gave up and tried createVirtualRegister():
MachineRegisterInfo &RegInfo = MBB.getParent()->getRegInfo();
const TargetRegisterClass *RC = &LASER::GNPRegsRegClass;
unsigned Reg = RegInfo.createVirtualRegister(RC);
But then I get the following error:
MachineCopyPropagation.cpp:267: void
anonymous}::MachineCopyPropagation::CopyPropagateBlock(llvm::MachineBasicBlock&):
Assertion `!TargetRegisterInfo::isVirtualRegister(Reg) &&
"MachineCopyPropagation should be run after register allocation!"'
failed.
How can I solve my problem of getting two free registers in
eliminateFrameIndex() ?
Thank you,
Ehsan Ali.
More information about the llvm-dev
mailing list