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

Dan Gohman gohman at apple.com
Wed Feb 17 11:55:37 PST 2010


On Feb 15, 2010, at 6:00 PM, Nick Lewycky wrote:

> Dan Gohman wrote:
>> 
>> On 2 February 2010 21:21, Nick Lewycky<nicholas at mxc.ca>  wrote:
>>> 
>>> Jakob, I'll make the tweaks to InlineCost that you proposed and post an
>>> updated patch with the results of a nightly test run. Realize that I'm
>>> expecting no visible performance difference at all since no code in the
>>> nightly test uses __builtin_unreachable().
>> 
>> There is code which uses things like "noreturn" and other
>> things which can lead to unreachable getting generated.
>> Offhand you may be right that these wouldn't be affected
>> though. This happens to be a very testable hypothesis :).
> 
> A 'noreturn' function call turns into a call + unreachable. The call can't be eliminated, so this patch has no effect on that case, since it's not a branch to unreachable (it'd a branch to call).

Ok.

> I want to emphasize that this patch is not nearly as scary as you seem to think it is. :-)

Artificially keeping dead instructions live is not customary in LLVM
behavior. CodeGenPrepare is *really* late. The relative sparsity of asm
diffs is encouraging, so I won't interfere. I do reserve some
misgivings though.

> 
>> Would you mind compiling some tests with and without the
>> change, and diffing the .s files? I'd be interested in
>> learning what kinds of diffs, if any, appear.
> 
> Done, asmchanges.diff attached. Original is - with my patch is + . I took TEST.llc.Makefile and modified it to keep the .s files, then did a run with and without the patch to see what happens to the output. Everything different was diff'd and all the differences that were irrelevant (timestamp, filename, anonymous namespace(!)) were removed. The remaining differences are a complete mystery to me -- I wonder whether two runs of llc even emit the same thing. :)

I've looked into some llc determinism problems recently. With the
exception of a few problems which are now fixed, llc output is
reproducible for things I've looked at. If you know of cases where
it isn't, please file bugs.

It seems like the very first diff here, yyerror, is a fairly
small function which should be easy enough to understand. Does
it diverse in opt or llc? If llc, can you run llc with
-print-machineinstrs -print-lsr-output -print-isel-input and
figure out where it diverges?

Thanks,

Dan





More information about the llvm-commits mailing list