[LLVMdev] Changing basic blocks
Emílio Wuerges
wuerges at gmail.com
Thu Aug 16 17:30:10 PDT 2007
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20070816/7755786b/attachment.html>
More information about the llvm-dev
mailing list