forked from OSchip/llvm-project
Also add <imp-def> operands for defined and dead super-registers when rewriting.
We cannot rely on the <imp-def> operands added by LiveIntervals in all cases as demonstrated by the test case. llvm-svn: 130313
This commit is contained in:
parent
f2752a3938
commit
71d3b895ba
|
@ -260,6 +260,8 @@ void VirtRegMap::rewrite(SlotIndexes *Indexes) {
|
||||||
<< "********** Function: "
|
<< "********** Function: "
|
||||||
<< MF->getFunction()->getName() << '\n');
|
<< MF->getFunction()->getName() << '\n');
|
||||||
DEBUG(dump());
|
DEBUG(dump());
|
||||||
|
SmallVector<unsigned, 8> SuperDeads;
|
||||||
|
SmallVector<unsigned, 8> SuperDefs;
|
||||||
SmallVector<unsigned, 8> SuperKills;
|
SmallVector<unsigned, 8> SuperKills;
|
||||||
|
|
||||||
for (MachineFunction::iterator MBBI = MF->begin(), MBBE = MF->end();
|
for (MachineFunction::iterator MBBI = MF->begin(), MBBE = MF->end();
|
||||||
|
@ -283,12 +285,13 @@ void VirtRegMap::rewrite(SlotIndexes *Indexes) {
|
||||||
if (MO.getSubReg()) {
|
if (MO.getSubReg()) {
|
||||||
// A virtual register kill refers to the whole register, so we may
|
// A virtual register kill refers to the whole register, so we may
|
||||||
// have to add <imp-use,kill> operands for the super-register.
|
// have to add <imp-use,kill> operands for the super-register.
|
||||||
if (MO.isUse() && MO.isKill() && !MO.isUndef())
|
if (MO.isUse()) {
|
||||||
SuperKills.push_back(PhysReg);
|
if (MO.isKill() && !MO.isUndef())
|
||||||
|
SuperKills.push_back(PhysReg);
|
||||||
// We don't have to deal with sub-register defs because
|
} else if (MO.isDead())
|
||||||
// LiveIntervalAnalysis already added the necessary <imp-def>
|
SuperDeads.push_back(PhysReg);
|
||||||
// operands.
|
else
|
||||||
|
SuperDefs.push_back(PhysReg);
|
||||||
|
|
||||||
// PhysReg operands cannot have subregister indexes.
|
// PhysReg operands cannot have subregister indexes.
|
||||||
PhysReg = TRI->getSubReg(PhysReg, MO.getSubReg());
|
PhysReg = TRI->getSubReg(PhysReg, MO.getSubReg());
|
||||||
|
@ -305,6 +308,12 @@ void VirtRegMap::rewrite(SlotIndexes *Indexes) {
|
||||||
while (!SuperKills.empty())
|
while (!SuperKills.empty())
|
||||||
MI->addRegisterKilled(SuperKills.pop_back_val(), TRI, true);
|
MI->addRegisterKilled(SuperKills.pop_back_val(), TRI, true);
|
||||||
|
|
||||||
|
while (!SuperDeads.empty())
|
||||||
|
MI->addRegisterDead(SuperDeads.pop_back_val(), TRI, true);
|
||||||
|
|
||||||
|
while (!SuperDefs.empty())
|
||||||
|
MI->addRegisterDefined(SuperDefs.pop_back_val(), TRI);
|
||||||
|
|
||||||
DEBUG(dbgs() << "> " << *MI);
|
DEBUG(dbgs() << "> " << *MI);
|
||||||
|
|
||||||
// Finally, remove any identity copies.
|
// Finally, remove any identity copies.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
; RUN: llc < %s -regalloc=greedy -mcpu=cortex-a8 -relocation-model=pic -disable-fp-elim | FileCheck %s
|
; RUN: llc < %s -regalloc=greedy -mcpu=cortex-a8 -relocation-model=pic -disable-fp-elim -verify-machineinstrs | FileCheck %s
|
||||||
;
|
;
|
||||||
; ARM tests that crash or fail with the greedy register allocator.
|
; ARM tests that crash or fail with the greedy register allocator.
|
||||||
|
|
||||||
|
@ -59,3 +59,26 @@ for.end: ; preds = %cond.end
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; CHECK: insert_elem
|
||||||
|
; This test has a sub-register copy with a kill flag:
|
||||||
|
; %vreg6:ssub_3<def> = COPY %vreg6:ssub_2<kill>; QPR_VFP2:%vreg6
|
||||||
|
; The rewriter must do something sensible with that, or the scavenger crashes.
|
||||||
|
define void @insert_elem() nounwind {
|
||||||
|
entry:
|
||||||
|
br i1 undef, label %if.end251, label %if.then84
|
||||||
|
|
||||||
|
if.then84: ; preds = %entry
|
||||||
|
br i1 undef, label %if.end251, label %if.then195
|
||||||
|
|
||||||
|
if.then195: ; preds = %if.then84
|
||||||
|
%div = fdiv float 1.000000e+00, undef
|
||||||
|
%vecinit207 = insertelement <4 x float> undef, float %div, i32 1
|
||||||
|
%vecinit208 = insertelement <4 x float> %vecinit207, float 1.000000e+00, i32 2
|
||||||
|
%vecinit209 = insertelement <4 x float> %vecinit208, float 1.000000e+00, i32 3
|
||||||
|
%mul216 = fmul <4 x float> zeroinitializer, %vecinit209
|
||||||
|
store <4 x float> %mul216, <4 x float>* undef, align 16
|
||||||
|
br label %if.end251
|
||||||
|
|
||||||
|
if.end251: ; preds = %if.then195, %if.then84, %entry
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue