imageworks/OpenShadingLanguage — pull request #110 by lgritz (2012-02-13 18:17:13+00:00)
Title: Review: OSL Optimizations: assignment to unconnected outputs, redundant useparam.

OSL Optimizations: assignment to unconnected outputs, redundant useparam. I'm sorry to say that these don't make a dramatic difference in the test scene I'm working on at the moment, but I still think they are a good optimization that may help in some situations.

(1) Previously, multiple params that happened to be connected to the same earlier layer could each, separately, check whether that layer was run. Now, it remembers which layers have unconditionally been run, and will not generate the layer-checking LLVM IR redundantly.

(2) Assignments to output parameters that are not connected to any downstream layers will be eliminated. There's a new attribute, "opt_elide_unconnected_output", that when set to 0 will disable this optimization -- a necessary step for testshade, which can try to pull data from outputs that aren't connected to anything. May be helpful for other apps as well.
(FIXME: this should be expanded to apply to any ops that write only to unconnected outputs, not just for assignment.)

Also, a bug was fixed in outparam_assign_elision -- an early 'return' which I'm pretty sure was at some point inserted temporarily for debugging (to disable the optimizations in the remainder of that function) and inadvertently committed.

Extras I fixed along the way:

Remove redundant and unused Symbol::m_connected -- this info is already present via m_valuesource.

Name the structs we define in LLVM, makes trolling through the debug LLVM IR dumps easier on the eyes.