[LLVMdev] What is dead def?

Mehdi Amini mehdi.amini at apple.com
Fri Jan 2 19:23:12 PST 2015


Yes this is unused definition. The comments in AggressiveAntiDepBreaker explains it quite accurately. They can also comes from instructions that produce multiple results but only part of them are used (the EFLAGS is an example).

Mehdi

> On Jan 2, 2015, at 7:15 PM, Thomson <lilotom at gmail.com> wrote:
> 
> Thanks Mehdi. Below is an example of "dead def", it looks like unused definition as you mentioned, could you confirm? I also saw dead defs in some generated code before register allocation, like "%reg1030<def> = ADD8rr %reg1028<kill>, %reg1029<kill>, %EFLAGS<imp-def,dead>", does it mean similar for EFLAGS here?
> 
> // AggressiveAntiDepBreaker.cpp
> void AggressiveAntiDepBreaker::PrescanInstruction(MachineInstr *MI,
>                                                   unsigned Count,
>                                              std::set<unsigned>& PassthruRegs) {
>   std::vector<unsigned> &DefIndices = State->GetDefIndices();
>   std::multimap<unsigned, AggressiveAntiDepState::RegisterReference>&
>     RegRefs = State->GetRegRefs();
> 
>   // Handle dead defs by simulating a last-use of the register just
>   // after the def. A dead def can occur because the def is truly
>   // dead, or because only a subregister is live at the def. If we
>   // don't do this the dead def will be incorrectly merged into the
>   // previous def.
>   for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
>     MachineOperand &MO = MI->getOperand(i);
>     if (!MO.isReg() || !MO.isDef()) continue;
>     unsigned Reg = MO.getReg();
>     if (Reg == 0) continue;
> 
>     HandleLastUse(Reg, Count + 1, "", "\tDead Def: ", "\n");
>   }
> 
> On Fri, Jan 2, 2015 at 4:38 AM, Mehdi Amini <mehdi.amini at apple.com <mailto:mehdi.amini at apple.com>> wrote:
> 
> > On Jan 1, 2015, at 7:24 AM, Thomson <lilotom at gmail.com <mailto:lilotom at gmail.com>> wrote:
> >
> > I saw there is reference to dead def on registers in LLVM source code. I am not aware of this concept from the traditional course material. What are the properties of dead def?
> 
> Could it be a def that is never used (hence dead)?
> If you mention where you saw it, it may be easier to help :)
> 
> Best,
> 
> Mehdi
> 
> 
> >
> > Cheers
> > Thomson
> > _______________________________________________
> > LLVM Developers mailing list
> > LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu>         http://llvm.cs.uiuc.edu <http://llvm.cs.uiuc.edu/>
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev <http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150102/bf26b745/attachment.html>


More information about the llvm-dev mailing list