I have two values and I want see if them are equals. Then, I would a instruction like if Value1 != Value2, error without create a new block, continuing the execution in the same block, forcing the LLI to execute this. 2011/9/5 Eli Friedman <eli.friedman at gmail.com>> On Mon, Sep 5, 2011 at 4:47 PM, Rafael Baldiati Parizi > <parizi.computacao at gmail.com> wrote: > > Hello, > > I would know how can I make a branch in llvm ir without a label of > > destination? > > For example: > > br i1 %1, label %bb, NO LABEL HERE > > What are you trying to do? > > -Eli >-- *Rafael Parizi* -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110905/009d2577/attachment.html>
This is necessary because I am working with the addition of instruction in the code llvm for C programs, after generating the intermediate language and for that, I would put this deviation without changing block. 2011/9/5 Rafael Baldiati Parizi <parizi.computacao at gmail.com>> I have two values and I want see if them are equals. Then, I would a > instruction like > if Value1 != Value2, error > without create a new block, continuing the execution in the same block, > forcing the LLI to execute this. > > 2011/9/5 Eli Friedman <eli.friedman at gmail.com> > >> On Mon, Sep 5, 2011 at 4:47 PM, Rafael Baldiati Parizi >> <parizi.computacao at gmail.com> wrote: >> > Hello, >> > I would know how can I make a branch in llvm ir without a label of >> > destination? >> > For example: >> > br i1 %1, label %bb, NO LABEL HERE >> >> What are you trying to do? >> >> -Eli >> > > > > -- > *Rafael Parizi* > > > >-- *Rafael Parizi* -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110905/5ce279c8/attachment.html>
On Mon, Sep 5, 2011 at 5:13 PM, Rafael Baldiati Parizi <parizi.computacao at gmail.com> wrote:> I have two values and I want see if them are equals. Then, I would a > instruction like > if Value1 != Value2, error > without create a new block, continuing the execution in the same block, > forcing the LLI to execute this.You can't do that; a br instruction must be at the end of a block. Splitting a block is trivial, though: the C++ API provides SplitBlock, and if you're just manipulating the text, you can insert a br to a label immediately followed by that label anywhere in any function without changing the semantics of the program. -Eli> 2011/9/5 Eli Friedman <eli.friedman at gmail.com> >> >> On Mon, Sep 5, 2011 at 4:47 PM, Rafael Baldiati Parizi >> <parizi.computacao at gmail.com> wrote: >> > Hello, >> > I would know how can I make a branch in llvm ir without a label of >> > destination? >> > For example: >> > br i1 %1, label %bb, NO LABEL HERE >> >> What are you trying to do? >> >> -Eli > > > > -- > Rafael Parizi > > > >
On Mon, Sep 5, 2011 at 5:25 PM, Eli Friedman <eli.friedman at gmail.com> wrote:> On Mon, Sep 5, 2011 at 5:13 PM, Rafael Baldiati Parizi > <parizi.computacao at gmail.com> wrote: >> I have two values and I want see if them are equals. Then, I would a >> instruction like >> if Value1 != Value2, error >> without create a new block, continuing the execution in the same block, >> forcing the LLI to execute this. > > You can't do that; a br instruction must be at the end of a block. > > Splitting a block is trivial, though: the C++ API provides SplitBlock, > and if you're just manipulating the text, you can insert a br to a > label immediately followed by that label anywhere in any function > without changing the semantics of the program.Err, strictly speaking, not anywhere... you can't split a block before a PHI node or a landingpad. But otherwise, there are no restrictions. -Eli
Rafael Baldiati Parizi wrote:> I have two values and I want see if them are equals. Then, I would a > instruction like > if Value1 != Value2, error > without create a new block, continuing the execution in the same block, > forcing the LLI to execute this.You can not. The definition of a "basic block" is a sequence of instructions with a single entry and a single exit. You can not insert multiple exits within a basic block. I realize that this restriction feels arbitrary, but there's a vast amount of research and practical experience in compiler design built around the notion of basic blocks making up a control flow graph. Nick> 2011/9/5 Eli Friedman <eli.friedman at gmail.com > <mailto:eli.friedman at gmail.com>> > > On Mon, Sep 5, 2011 at 4:47 PM, Rafael Baldiati Parizi > <parizi.computacao at gmail.com <mailto:parizi.computacao at gmail.com>> > wrote: > > Hello, > > I would know how can I make a branch in llvm ir without a label of > > destination? > > For example: > > br i1 %1, label %bb, NO LABEL HERE > > What are you trying to do? > > -Eli > > > > > -- > */Rafael Parizi/* > > > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Yes, that's how I'm doing now ... create a new block where the execution flow will continue after the shift, following the basics of basic blocks. But, I want to find a way to reduce the number of block of my code. 2011/9/5 Nick Lewycky <nicholas at mxc.ca>> Rafael Baldiati Parizi wrote: > >> I have two values and I want see if them are equals. Then, I would a >> instruction like >> if Value1 != Value2, error >> without create a new block, continuing the execution in the same block, >> forcing the LLI to execute this. >> > > You can not. The definition of a "basic block" is a sequence of > instructions with a single entry and a single exit. You can not insert > multiple exits within a basic block. > > I realize that this restriction feels arbitrary, but there's a vast amount > of research and practical experience in compiler design built around the > notion of basic blocks making up a control flow graph. > > Nick > > 2011/9/5 Eli Friedman <eli.friedman at gmail.com >> <mailto:eli.friedman at gmail.com**>> >> >> >> On Mon, Sep 5, 2011 at 4:47 PM, Rafael Baldiati Parizi >> <parizi.computacao at gmail.com <mailto:parizi.computacao@**gmail.com<parizi.computacao at gmail.com> >> >> >> >> wrote: >> > Hello, >> > I would know how can I make a branch in llvm ir without a label of >> > destination? >> > For example: >> > br i1 %1, label %bb, NO LABEL HERE >> >> What are you trying to do? >> >> -Eli >> >> >> >> >> -- >> */Rafael Parizi/* >> >> >> >> >> >> ______________________________**_________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/**mailman/listinfo/llvmdev<http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev> >> > >-- *Rafael Parizi* -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110905/0cd0ddef/attachment.html>