imageworks/OpenShadingLanguage — pull request #83 by lgritz (2011-10-20 04:35:54+00:00)
Title: Review: Optimization debug help

Optimization debug help: turn SS::debug into an int with levels, at high levels create a detailed log of code transformations and why they were done.

Only kicking in when debug >= 2, this really helps me figure out how code gets transformed during our runtime optimization. We don't get a lot of optimizer bugs, but when they occasionally crop up, it's very time consuming to figure out what's happening and why. This gives me a trail of breadcrumbs to work with. I can get a log that looks like:

turned op 12 from div to $tmp5 = $const2 : div by 1
turned op 14 from neg to $tmp6 = $const2 : const fold
turned op 15 from assign to nop : replace symbol with constant
turned op 34 from assign to ___307_z = $const4 : coerce to correct type