[llvm-commits] [llvm] r126190 - in /llvm/trunk: lib/CodeGen/VirtRegRewriter.cpp test/CodeGen/X86/2011-02-21-VirtRegRewriter-KillSubReg.ll

Andrew Trick atrick at apple.com
Mon Feb 21 23:37:36 PST 2011


On Feb 21, 2011, at 10:59 PM, Evan Cheng wrote:
> 
> On Feb 21, 2011, at 10:52 PM, Andrew Trick wrote:
> 
>> Author: atrick
>> Date: Tue Feb 22 00:52:56 2011
>> New Revision: 126190
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=126190&view=rev
>> Log:
>> VirtRegRewriter assertion fix.
>> Apparently it's ok for multiple operands to "kill" the same register.
> 
> It is?
> 
> Evan

Prior to the standard spiller, we have:
  MOV8mr %vreg34<kill>, 1, %noreg, 3, %noreg, %vreg34:sub_8bit<kill>; mem:ST1[%arrayidx833] GR32_ABCD:%vreg34

Before rewriting we have:
  %EAX<def> = MOV32rm <fi#0>, 1, %noreg, 0, %noreg; mem:LD4[FixedStack0]
  MOV8mr %EAX<kill>, 1, %noreg, 3, %noreg, %AL<kill>; mem:ST1[%arrayidx833]

After rewriting:
  %EAX<def> = MOV32rm <fi#0>, 1, %noreg, 0, %noreg; mem:LD4[FixedStack0]
  MOV8mr %EAX, 1, %noreg, 3, %noreg, %AL<kill>; mem:ST1[%arrayidx833]

It seems valid enough to me for a combination of passes that will hopefully soon be deprecated. I'm honestly not sure yet what the ideal rules should be for subreg kill flags.

-Andy

> 
>> Fixes PR9237.
>> 
>> Added:
>>   llvm/trunk/test/CodeGen/X86/2011-02-21-VirtRegRewriter-KillSubReg.ll
>> Modified:
>>   llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp
>> 
>> Modified: llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp?rev=126190&r1=126189&r2=126190&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/VirtRegRewriter.cpp Tue Feb 22 00:52:56 2011
>> @@ -478,7 +478,8 @@
>>  if (!RegKills[KReg])
>>    return;
>> 
>> -  assert(KillOps[KReg] == KillOp && "invalid superreg kill flags");
>> +  assert(KillOps[KReg]->getParent() == KillOp->getParent() &&
>> +         "invalid superreg kill flags");
>>  KillOps[KReg] = NULL;
>>  RegKills.reset(KReg);
>> 
>> @@ -487,7 +488,8 @@
>>  for (const unsigned *SR = TRI->getSubRegisters(KReg); *SR; ++SR) {
>>    DEBUG(dbgs() << "  Resurrect subreg " << TRI->getName(*SR) << "\n");
>> 
>> -    assert(KillOps[*SR] == KillOp && "invalid subreg kill flags");
>> +    assert(KillOps[*SR]->getParent() == KillOp->getParent() &&
>> +           "invalid subreg kill flags");
>>    KillOps[*SR] = NULL;
>>    RegKills.reset(*SR);
>>  }
>> 
>> Added: llvm/trunk/test/CodeGen/X86/2011-02-21-VirtRegRewriter-KillSubReg.ll
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2011-02-21-VirtRegRewriter-KillSubReg.ll?rev=126190&view=auto
>> ==============================================================================
>> --- llvm/trunk/test/CodeGen/X86/2011-02-21-VirtRegRewriter-KillSubReg.ll (added)
>> +++ llvm/trunk/test/CodeGen/X86/2011-02-21-VirtRegRewriter-KillSubReg.ll Tue Feb 22 00:52:56 2011
>> @@ -0,0 +1,50 @@
>> +; RUN: llc < %s -O2 -march=x86 -mtriple=i386-pc-linux-gnu -relocation-model=pic | FileCheck %s
>> +; PR9237: Assertion in VirtRegRewriter.cpp, ResurrectConfirmedKill
>> +;         `KillOps[*SR] == KillOp && "invalid subreg kill flags"'
>> +
>> +%t = type { i32 }
>> +
>> +define i32 @foo(%t* %s) nounwind {
>> +entry:
>> +  br label %if.then735
>> +
>> +if.then735:
>> +  %call747 = call i32 undef(%t* %s, i8* null, i8* undef, i32 128, i8* undef, i32 516) nounwind
>> +  br i1 undef, label %if.then751, label %if.then758
>> +
>> +if.then751:
>> +  unreachable
>> +
>> +if.then758:
>> +  %add761 = add i32 %call747, 4
>> +  %add763 = add i32 %add761, %call747
>> +  %add.ptr768 = getelementptr inbounds [516 x i8]* null, i32 0, i32 %add761
>> +  br i1 undef, label %cond.false783, label %cond.true771
>> +
>> +cond.true771:
>> +  %call782 = call i8* @__memmove_chk(i8* %add.ptr768, i8* undef, i32 %call747, i32 undef)
>> +  br label %cond.end791
>> +
>> +; CHECK: calll __memmove_chk
>> +cond.false783:
>> +  %call.i1035 = call i8* @__memmove_chk(i8* %add.ptr768, i8* undef, i32 %call747, i32 undef) nounwind
>> +  br label %cond.end791
>> +
>> +cond.end791:
>> +  %conv801 = trunc i32 %call747 to i8
>> +  %add.ptr822.sum = add i32 %call747, 3
>> +  %arrayidx833 = getelementptr inbounds [516 x i8]* null, i32 0, i32 %add.ptr822.sum
>> +  store i8 %conv801, i8* %arrayidx833, align 1
>> +  %cmp841 = icmp eq i8* undef, null
>> +  br i1 %cmp841, label %if.end849, label %if.then843
>> +
>> +if.then843:
>> +  unreachable
>> +
>> +if.end849:
>> +  %call921 = call i32 undef(%t* %s, i8* undef, i8* undef, i32 %add763) nounwind
>> +  unreachable
>> +
>> +}
>> +
>> +declare i8* @__memmove_chk(i8*, i8*, i32, i32) nounwind
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110221/ca7d319a/attachment.html>


More information about the llvm-commits mailing list