[PATCH] D43150: [tablegen] Recursively evaluate values of variable initializers.

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 15 17:29:45 PST 2018

tra added a comment.

In https://reviews.llvm.org/D43150#1009522, @craig.topper wrote:

> 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.


More information about the llvm-commits mailing list