[sil-cloner] Always call doPreProcess when visiting SILInstructions.

It is important to call doPreProcess to correctly setup the available opened archetypes which were referenced from the original instruction being copied.

This fixes a concrete bug in LoopRotate optimization and potential bugs related to cloning.

rdar://27659420
This commit is contained in:
Roman Levenstein
2016-08-03 15:01:19 -07:00
parent 02d2517866
commit d92c4cc379
3 changed files with 62 additions and 3 deletions

View File

@@ -31,7 +31,15 @@ class SILVisitor {
public:
ImplClass &asImpl() { return static_cast<ImplClass &>(*this); }
// Peform any required pre-processing before visiting.
// Sub-classes can override it to provide their custom
// pre-processing steps.
void beforeVisit(ValueBase *V) {
}
ValueRetTy visit(ValueBase *V) {
asImpl().beforeVisit(V);
switch (V->getKind()) {
#define VALUE(CLASS, PARENT) \
case ValueKind::CLASS: \