[LLVMdev] Remove identical or redundant basic blocks?

Dale Johannesen dalej at apple.com
Sun May 9 09:41:12 PDT 2010


On May 9, 2010, at 7:17 AM, Heinz Riener wrote:

> Dale is totally right, all of these blocks disappear in later
> target-dependent optimizations.  I have not thought about that since
> eliminating these blocks requires no target-dependent information.
> However, I guess it is not worth eliminating them earlier.

Branches have sufficient target-dependent aspects that you really need  
to deal with them at that level.  For example:

ret might expand to a single instruction, a lengthy epilog, or a tail  
call
many targets have limits on how far a conditional branch can reach;  
sometimes intermediate unconditional branches are needed as  
steppingstones
not all targets can support all conditional branches that appear in  
the IR; some of them expand to multiple instructions

Since targets need to deal with this stuff in any case, it's not worth  
it to try to be too clever at the target-independent level.  In some  
cases the target would have to undo whatever you did anyway.




More information about the llvm-dev mailing list