[LLVMdev] Changing basic blocks

Emílio Wuerges wuerges at gmail.com
Fri Aug 17 12:39:18 PDT 2007


Just for the update, I found my way around like this:
rts is my optimizer.

  for (int i = 0; i < rts.total_emmited(); ++i)
  {
          MachineInstr * mi = rts.emmited_instruction(i);
          MachineInstr* last = BB->remove(mi);
          BB->push_back(last);
  }


2007/8/16, Emílio Wuerges <wuerges at gmail.com>:
>
> Yup,
> You are right. That exploded.
> I missed some lines in between.
> there was a .reserve(total) in the actual code.
> But, there is some side effect I still could not  find.
>
>
> 2007/8/16, Chris Lattner <sabre at nondot.org>:
> >
> > On Wed, 15 Aug 2007, [ISO-8859-1] Emílio Wuerges wrote:
> > > --
> > > int total = BB->size();
> > > std::vector<MachineInstr*> positionmap(total);
> > >  for (int i = 0; i< total; ++i)
> > >    positionmap.push_back (BB->remove(BB->begin()));
> > >  for(int i = 0; i< total; ++i)
> > >    BB->push_back(positionmap[i]);
> > > --
> >
> > This doesn't do what you think.  This line:
> >
> > std::vector<MachineInstr*> positionmap(total);
> >
> > Creates a vector with "total" null elements in it, it doesn't reserve
> > space.  This means that this loop:
> >    for(int i = 0; i< total; ++i)
> >      BB->push_back(positionmap[i]);
> >
> > Inserts all these nulls into the BB.  I'm surprised this doesn't
> > explode.
> >
> > -Chris
> >
> > --
> > http://nondot.org/sabre/
> > http://llvm.org/
> > _______________________________________________
> > LLVM Developers mailing list
> > LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
> >
> >
>
>
> --
> Emilio Wuerges
> LAPS - Laboratorio de Automacao de Projeto de Sistemas
> UFSC - Universidade Federal de Santa Catarina
> Brasil
>



-- 
Emilio Wuerges
LAPS - Laboratorio de Automacao de Projeto de Sistemas
UFSC - Universidade Federal de Santa Catarina
Brasil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070817/de040ae2/attachment.html>


More information about the llvm-dev mailing list