[llvm-commits] patch: moving unreachable elimination to codegenprep

Jakob Stoklund Olesen stoklund at 2pi.dk
Tue Feb 2 11:10:29 PST 2010


On Feb 2, 2010, at 8:53 AM, Nick Lewycky wrote:

> This is a resurrection of the patch first discussed back in October 2009 to change the way unreachable is handled to make it live in the IR for as long as possible. The goal is to implement http://nondot.org/sabre/LLVMNotes/BuiltinUnreachable.txt in time for the LLVM 2.7 freeze so that python can make use of it when they land unladen-swallow.

Nick, I couldn't find that discussion in the archives. Do you have any pointers?

> This patch does most of the work of just moving the time unreachables are eliminated at late as possible, currently CodeGenPrep, and updates InlineCost and SCEV to handle it. Most of the patch is just updating codegen unit tests that use the unreachable instruction.

I can only comment on the InlineCost changes.

It seems to me you would need to avoid unreachable instructions in the CountCodeReductionFor* methods as well. Is unreachable only found at the beginning of a block?

What about all the undead code driving a switch or br to unreachable? That should not be counted in the inline cost since it will eventually be eliminated.

> The primary concern from last time was the side-effects of keeping the chain of computation that fed into a dead branch. The 'extra' instructions could have effects on everything from inlining to loop analysis, but any approach short of cramming the entire expression into metadata attached to the branch would have the same problem.

It seems that a lot of optimizations could be sabotaged by undead code.

Do we have any measurements that show this to be a good idea in the first place?

/jakob

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100202/12c48778/attachment.bin>


More information about the llvm-commits mailing list