Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename compiler-generated constants non-sequentially
In the course of our runtime optimization of shader networks, we generate lots of new constant symbols (for example, as we optimize an "a = b + c" into "a = newconst" if b and c can be determined to be constants). The new constants are named with a numerical suffix doled out in a sequental manner. I've always thought that maybe it would be helpful for me when debugging optimizer output if the name of the symbol also revealed the value of the constant it held (when possible). Never did anything about it. Now it turns out that this has an application for JIT to PTX, where the PTX cache can save compilation-to-PTX time if it encounters LLVM IR that is exactly the same as it has seen before and is cache. If the constants are generated in a different order, it generates non-functional, purely text differences in the code we generate, and this means the PTX cache doesn't function as efficiently as possible. So this change alters the compiler-generated constant naming for two cases: int constants, and string constants. The int constants append the value of the integer (using '_' instead of '-' for negatives), and the string constants append the hexidecimal value of the ustring hash for that string. In both cases it does this without using or incrementing the `m_next_newconst` counter that it uses to sequentially name the other types that can't easily encode the value to generate a unique name. It's really to help the PTX cache, but as a side benefit, it will be slightly easier for me to make sense of the optimized code when I need to read it with my own eyes while debugging. Signed-off-by: Larry Gritz <lg@larrygritz.com>
- Loading branch information