Avoid needing to walk out legalization tables. NFCI.
authorNirav Dave <niravd@google.com>
Sat, 16 Jun 2018 02:51:29 +0000 (02:51 +0000)
committerNirav Dave <niravd@google.com>
Sat, 16 Jun 2018 02:51:29 +0000 (02:51 +0000)
commitd4ff2f8a743681583ec6426b4ad488151fa1b9dc
tree2e49f1e22d1ae268590d307082d797b44e25fb27
parentcbd80f49d5f8298d5c7e35db50e03d79eac50ffa
Avoid needing to walk out legalization tables. NFCI.

Relanding after fixing expensive check from modifying tables.

To avoid redundant work, during DAG legalization we keep tables
mapping pre-legalized SDValues to post-legalized SDValues and a
SDValue-to-SDValue map to enable fast node replacements. However, as
the keys are nodes which may be reused it is possible that an entry in
a table refers to a now deleted node N (that should have been renamed
by the value replacement map) while a new node N' exists. If N' is
then replaced that entry would be wrong. Previously we avoided this by
when potentially violating this property, walking every table and
updating all node pointers. This is very expensive but hopefully rare
occurance.

This patch assigns each instance of a SDValue used in legalization a
unique id and uses these ids in the legalization tables. This avoids
any such aliasing issue, avoiding the full table search and allowing
more aggressive incremental table pruning.

In some cases this is a 1000x speedup to compilation.

Reviewers: jyknight, echristo, bogner, tra

Reviewed By: bogner

Subscribers: dberris, grandinj, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D47959

llvm-svn: 334880
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h