[LLVMdev] Remove identical or redundant basic blocks?

Eugene Toder eltoder at gmail.com
Sat May 8 15:55:06 PDT 2010


Would it make sense to have a similar pass that operates on llvm main IR?

On Sat, May 8, 2010 at 5:15 PM, Dale Johannesen <dalej at apple.com> wrote:
> The branch folding pass does this, but it operates later, on the
> target-dependent form in llc.
>
> On May 8, 2010, at 8:48 AM, Heinz Riener wrote:
>
>> Dear all,
>>
>> after optimizing a small LLVM example program (i.e., with opt -O3),
>> the
>> resulting code contains several basic blocks, which I consider
>> identical
>> or redundant.  For instance,
>>
>> return:                                           ; preds = %min.exit
>>   ret i32 0
>>
>> bb15:                                             ; preds = %min.exit
>>   ret i32 0
>>
>> or,
>>
>> bb7.i:                                            ; preds = %bb1.i
>>   br label %bb3.i
>>
>> bb9.i:                                            ; preds = %bb1.i
>>   br label %bb3.i
>>
>> I think it is safe to remove the blocks bb7.i, bb9.i, bb15 while
>> replacing each jump to bb15 with return and jumps to bb7.i, bb9.i with
>> bb3.i.
>>
>> Is there any opt pass I can apply to the code to merge or remove these
>> blocks?
>>
>> Heinz
>> _______________________________________________
>> LLVM Developers mailing list
>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>




More information about the llvm-dev mailing list