Otherwise we often end up with partially evaluated fields even when
their (evaluated) values are known at the time of the record instantiation.
Details
- Reviewers
arsenm craig.topper nhaehnle
Diff Detail
- Build Status
Buildable 14826 Build 14826: arc lint + arc unit
Event Timeline
Wasn't the point of how this was written before so that we go through a loop in Record::resolveReferencesTo and resolve each field and call setValue. And the VarInit just loops up the value saved by that resolving. Now it looks we by pass those cached results and just recurse all the time. Won't this be a big perf hit?
It should not impact performance much. If we've managed to fold the value at some point, then we'll return right away, because there's nothing to fold any more.
If folding failed we will attempt to fold again when the variable is used later. It should not happen often as all currently existing tablegen files apparently manage to provide enough information to fold the records and avoid the problem this patch solves.
Performance impact on my machine using bin/tblgen -I ~/work/llvm/repo/llvm/lib/Target/NVPTX -I ~/work/llvm/repo/llvm/lib/Target -I ~/work/llvm/repo/llvm/include ~/work/llvm/repo/llvm/lib/Target/NVPTX/NVPTX.td -o /dev/null is lost in the noise:
w/o changes: 0.261s-0.275s
with this patch: 0.265s-0.274s
Most of the time will be spent in the back-ends and that part is not affected by the patch.
I believe the change is correct, although the change D43564 should be doing the same thing with caching on top of it.
If this is urgent we could take it and resolve the conflicts, otherwise I'd prefer if we went with my changes if you're okay with them, but keep your test case around.
I have few pending patches depending on this change, so I'd rather land this patch soon. The conflict will be easy to resolve -- just replace the changes to VarInit::resolveReferences with your version.
D43564 is currently the last patch in your set, which may take some time until it lands. If you can rebase D43564 to the bottom of your stack (and incorporate this test), I'd be OK going with it.