[LLVMdev] Fwd: LLVM IR Branchs

Rafael Baldiati Parizi parizi.computacao at gmail.com
Wed Sep 14 06:56:20 PDT 2011


Hello,
I created a new block for execution to continue, but I got the case in which
a statement defined in a block is used in another, not dominate all uses.
For example:

entry:
   %n_addr = alloca i32, align 4
   %retval = alloca i32
   %"alloca point" = bitcast i32 0 to i32
  store i32 %n, i32* %n_addr
   %0 = call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds ([20
x i8]* @.str, i32 0, i32 0)) nounwind
   %1 = load i32* %n_addr, align 4
   %2 = and i32 %1, 1
*   %3* = icmp eq i32 %2, 0
   .....
   br label %new_block

new_block:
 %4 =  call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds ([10
x i8]* @.str1, i32 0, i32 0), i32 *%4*) nounwind
 ...


How to solve this?

2011/9/5 Rafael Baldiati Parizi <parizi.computacao at gmail.com>

> Ok!  I do understand.
> Thanks by help!
>
>
> 2011/9/5 Justin Holewinski <justin.holewinski at gmail.com>
>
>> On Mon, Sep 5, 2011 at 8:37 PM, Rafael Baldiati Parizi <
>> parizi.computacao at gmail.com> wrote:
>>
>>> 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.
>>
>>
>> Why do you want to reduce the number of LLVM IR blocks?  Just because LLVM
>> IR does not have fall-through branches does not mean that the generated code
>> will not have them.  As mentioned before, this is just a level of
>> abstraction used in the LLVM IR.
>>
>>
>>>
>>>
>>> 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*
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>>>
>>>
>>
>>
>> --
>>
>> Thanks,
>>
>> Justin Holewinski
>>
>>
>
>
> --
> *Rafael Parizi*
>
>
>
>


-- 
*Rafael Parizi*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110914/045c94fd/attachment.html>


More information about the llvm-dev mailing list