Merge pull request #19436 from gottesmm/pr-e2ea20678fd79a26d047317cef26331dddb0298e

[sil] Introduce FullApplySiteKind and ApplySiteKind to allow for exha…
diff --git a/include/swift/SIL/SILInstruction.h b/include/swift/SIL/SILInstruction.h
index de10d48..4f5852e 100644
--- a/include/swift/SIL/SILInstruction.h
+++ b/include/swift/SIL/SILInstruction.h
@@ -7477,6 +7477,40 @@
          const GenericSpecializationInformation *SpecializationInfo);
 };
 
+struct ApplySiteKind {
+  enum innerty : std::underlying_type<SILInstructionKind>::type {
+#define APPLYSITE_INST(ID, PARENT) ID = unsigned(SILInstructionKind::ID),
+#include "swift/SIL/SILNodes.def"
+  } value;
+
+  explicit ApplySiteKind(SILInstructionKind kind) {
+    auto newValue = ApplySiteKind::fromNodeKindHelper(kind);
+    assert(newValue && "Non apply site passed into ApplySiteKind");
+    value = newValue.getValue();
+  }
+
+  ApplySiteKind(innerty value) : value(value) {}
+  operator innerty() const { return value; }
+
+  static Optional<ApplySiteKind> fromNodeKind(SILInstructionKind kind) {
+    if (auto innerTyOpt = ApplySiteKind::fromNodeKindHelper(kind))
+      return ApplySiteKind(*innerTyOpt);
+    return None;
+  }
+
+private:
+  static Optional<innerty> fromNodeKindHelper(SILInstructionKind kind) {
+    switch (kind) {
+#define APPLYSITE_INST(ID, PARENT)                                             \
+  case SILInstructionKind::ID:                                                 \
+    return ApplySiteKind::ID;
+#include "swift/SIL/SILNodes.def"
+    default:
+      return None;
+    }
+  }
+};
+
 /// An apply instruction.
 class ApplySite {
   SILInstruction *Inst;
@@ -7500,17 +7534,23 @@
   }
 
   static ApplySite isa(SILNode *node) {
-    switch (node->getKind()) {
-    case SILNodeKind::ApplyInst:
-      return ApplySite(cast<ApplyInst>(node));
-    case SILNodeKind::BeginApplyInst:
-      return ApplySite(cast<BeginApplyInst>(node));
-    case SILNodeKind::TryApplyInst:
-      return ApplySite(cast<TryApplyInst>(node));
-    case SILNodeKind::PartialApplyInst:
-      return ApplySite(cast<PartialApplyInst>(node));
-    default:
+    auto *i = dyn_cast<SILInstruction>(node);
+    if (!i)
       return ApplySite();
+
+    auto kind = ApplySiteKind::fromNodeKind(i->getKind());
+    if (!kind)
+      return ApplySite();
+
+    switch (kind.getValue()) {
+    case ApplySiteKind::ApplyInst:
+      return ApplySite(cast<ApplyInst>(node));
+    case ApplySiteKind::BeginApplyInst:
+      return ApplySite(cast<BeginApplyInst>(node));
+    case ApplySiteKind::TryApplyInst:
+      return ApplySite(cast<TryApplyInst>(node));
+    case ApplySiteKind::PartialApplyInst:
+      return ApplySite(cast<PartialApplyInst>(node));
     }
   }
 
@@ -7524,19 +7564,18 @@
   SILFunction *getFunction() const { return Inst->getFunction(); }
   SILBasicBlock *getParent() const { return Inst->getParent(); }
 
-#define FOREACH_IMPL_RETURN(OPERATION) do {                             \
-    switch (Inst->getKind()) {                                          \
-    case SILInstructionKind::ApplyInst:                                 \
-      return cast<ApplyInst>(Inst)->OPERATION;                          \
-    case SILInstructionKind::BeginApplyInst:                            \
-      return cast<BeginApplyInst>(Inst)->OPERATION;                     \
-    case SILInstructionKind::PartialApplyInst:                          \
-      return cast<PartialApplyInst>(Inst)->OPERATION;                   \
-    case SILInstructionKind::TryApplyInst:                              \
-      return cast<TryApplyInst>(Inst)->OPERATION;                       \
-    default:                                                            \
-      llvm_unreachable("not an apply instruction!");                    \
-    }                                                                   \
+#define FOREACH_IMPL_RETURN(OPERATION)                                         \
+  do {                                                                         \
+    switch (ApplySiteKind(Inst->getKind())) {                                  \
+    case ApplySiteKind::ApplyInst:                                             \
+      return cast<ApplyInst>(Inst)->OPERATION;                                 \
+    case ApplySiteKind::BeginApplyInst:                                        \
+      return cast<BeginApplyInst>(Inst)->OPERATION;                            \
+    case ApplySiteKind::PartialApplyInst:                                      \
+      return cast<PartialApplyInst>(Inst)->OPERATION;                          \
+    case ApplySiteKind::TryApplyInst:                                          \
+      return cast<TryApplyInst>(Inst)->OPERATION;                              \
+    }                                                                          \
   } while (0)
 
   /// Return the callee operand.
@@ -7670,12 +7709,12 @@
   /// Return the callee's function argument index corresponding to the first
   /// applied argument: 0 for full applies; >= 0 for partial applies.
   unsigned getCalleeArgIndexOfFirstAppliedArg() const {
-    switch (Inst->getKind()) {
-    case SILInstructionKind::ApplyInst:
-    case SILInstructionKind::BeginApplyInst:
-    case SILInstructionKind::TryApplyInst:
+    switch (ApplySiteKind(Inst->getKind())) {
+    case ApplySiteKind::ApplyInst:
+    case ApplySiteKind::BeginApplyInst:
+    case ApplySiteKind::TryApplyInst:
       return 0;
-    case SILInstructionKind::PartialApplyInst:
+    case ApplySiteKind::PartialApplyInst:
       // The arguments to partial_apply are a suffix of the partial_apply's
       // callee. Note that getSubstCalleeConv is function type of the callee
       // argument passed to this apply, not necessarilly the function type of
@@ -7686,8 +7725,6 @@
       // pa2 = partial_apply pa1(b) : $(a, b)
       // apply pa2(a)
       return getSubstCalleeConv().getNumSILArguments() - getNumArguments();
-    default:
-      llvm_unreachable("not implemented for this instruction!");
     }
   }
 
@@ -7711,72 +7748,72 @@
 
   /// Return true if 'self' is an applied argument.
   bool hasSelfArgument() const {
-    switch (Inst->getKind()) {
-    case SILInstructionKind::ApplyInst:
+    switch (ApplySiteKind(Inst->getKind())) {
+    case ApplySiteKind::ApplyInst:
       return cast<ApplyInst>(Inst)->hasSelfArgument();
-    case SILInstructionKind::BeginApplyInst:
+    case ApplySiteKind::BeginApplyInst:
       return cast<BeginApplyInst>(Inst)->hasSelfArgument();
-    case SILInstructionKind::TryApplyInst:
+    case ApplySiteKind::TryApplyInst:
       return cast<TryApplyInst>(Inst)->hasSelfArgument();
-    default:
-      llvm_unreachable("not implemented for this instruction!");
+    case ApplySiteKind::PartialApplyInst:
+      llvm_unreachable("unhandled case");
     }
   }
 
   /// Return the applied 'self' argument value.
   SILValue getSelfArgument() const {
-    switch (Inst->getKind()) {
-    case SILInstructionKind::ApplyInst:
+    switch (ApplySiteKind(Inst->getKind())) {
+    case ApplySiteKind::ApplyInst:
       return cast<ApplyInst>(Inst)->getSelfArgument();
-    case SILInstructionKind::BeginApplyInst:
+    case ApplySiteKind::BeginApplyInst:
       return cast<BeginApplyInst>(Inst)->getSelfArgument();
-    case SILInstructionKind::TryApplyInst:
+    case ApplySiteKind::TryApplyInst:
       return cast<TryApplyInst>(Inst)->getSelfArgument();
-    default:
-      llvm_unreachable("not implemented for this instruction!");
+    case ApplySiteKind::PartialApplyInst:
+      llvm_unreachable("unhandled case");
     }
   }
 
   /// Return the 'self' apply operand.
   Operand &getSelfArgumentOperand() {
-    switch (Inst->getKind()) {
-    case SILInstructionKind::ApplyInst:
+    switch (ApplySiteKind(Inst->getKind())) {
+    case ApplySiteKind::ApplyInst:
       return cast<ApplyInst>(Inst)->getSelfArgumentOperand();
-    case SILInstructionKind::BeginApplyInst:
+    case ApplySiteKind::BeginApplyInst:
       return cast<BeginApplyInst>(Inst)->getSelfArgumentOperand();
-    case SILInstructionKind::TryApplyInst:
+    case ApplySiteKind::TryApplyInst:
       return cast<TryApplyInst>(Inst)->getSelfArgumentOperand();
-    default:
-      llvm_unreachable("not implemented for this instruction!");
+    case ApplySiteKind::PartialApplyInst:
+      llvm_unreachable("Unhandled cast");
     }
   }
 
   /// Return a list of applied arguments without self.
   OperandValueArrayRef getArgumentsWithoutSelf() const {
-    switch (Inst->getKind()) {
-    case SILInstructionKind::ApplyInst:
+    switch (ApplySiteKind(Inst->getKind())) {
+    case ApplySiteKind::ApplyInst:
       return cast<ApplyInst>(Inst)->getArgumentsWithoutSelf();
-    case SILInstructionKind::BeginApplyInst:
+    case ApplySiteKind::BeginApplyInst:
       return cast<BeginApplyInst>(Inst)->getArgumentsWithoutSelf();
-    case SILInstructionKind::TryApplyInst:
+    case ApplySiteKind::TryApplyInst:
       return cast<TryApplyInst>(Inst)->getArgumentsWithoutSelf();
-    default:
-      llvm_unreachable("not implemented for this instruction!");
+    case ApplySiteKind::PartialApplyInst:
+      llvm_unreachable("Unhandled case");
     }
   }
 
   /// Return whether the given apply is of a formally-throwing function
   /// which is statically known not to throw.
   bool isNonThrowing() const {
-    switch (getInstruction()->getKind()) {
-    case SILInstructionKind::ApplyInst:
+    switch (ApplySiteKind(getInstruction()->getKind())) {
+    case ApplySiteKind::ApplyInst:
       return cast<ApplyInst>(Inst)->isNonThrowing();
-    case SILInstructionKind::BeginApplyInst:
+    case ApplySiteKind::BeginApplyInst:
       return cast<BeginApplyInst>(Inst)->isNonThrowing();
-    case SILInstructionKind::TryApplyInst:
+    case ApplySiteKind::TryApplyInst:
       return false;
-    default:
-      llvm_unreachable("not implemented for this instruction!");
+    case ApplySiteKind::PartialApplyInst:
+      llvm_unreachable("Unhandled case");
     }
   }
 
@@ -7792,10 +7829,41 @@
   }
 
   static bool classof(const SILInstruction *inst) {
-    return (inst->getKind() == SILInstructionKind::ApplyInst ||
-            inst->getKind() == SILInstructionKind::BeginApplyInst ||
-            inst->getKind() == SILInstructionKind::PartialApplyInst ||
-            inst->getKind() == SILInstructionKind::TryApplyInst);
+    return bool(ApplySiteKind::fromNodeKind(inst->getKind()));
+  }
+};
+
+struct FullApplySiteKind {
+  enum innerty : std::underlying_type<SILInstructionKind>::type {
+#define FULLAPPLYSITE_INST(ID, PARENT) ID = unsigned(SILInstructionKind::ID),
+#include "swift/SIL/SILNodes.def"
+  } value;
+
+  explicit FullApplySiteKind(SILInstructionKind kind) {
+    auto fullApplySiteKind = FullApplySiteKind::fromNodeKindHelper(kind);
+    assert(fullApplySiteKind && "SILNodeKind is not a FullApplySiteKind?!");
+    value = fullApplySiteKind.getValue();
+  }
+
+  FullApplySiteKind(innerty value) : value(value) {}
+  operator innerty() const { return value; }
+
+  static Optional<FullApplySiteKind> fromNodeKind(SILInstructionKind kind) {
+    if (auto innerOpt = FullApplySiteKind::fromNodeKindHelper(kind))
+      return FullApplySiteKind(*innerOpt);
+    return None;
+  }
+
+private:
+  static Optional<innerty> fromNodeKindHelper(SILInstructionKind kind) {
+    switch (kind) {
+#define FULLAPPLYSITE_INST(ID, PARENT)                                         \
+  case SILInstructionKind::ID:                                                 \
+    return FullApplySiteKind::ID;
+#include "swift/SIL/SILNodes.def"
+    default:
+      return None;
+    }
   }
 };
 
@@ -7813,15 +7881,19 @@
   FullApplySite(TryApplyInst *inst) : ApplySite(inst) {}
 
   static FullApplySite isa(SILNode *node) {
-    switch (node->getKind()) {
-    case SILNodeKind::ApplyInst:
-      return FullApplySite(cast<ApplyInst>(node));
-    case SILNodeKind::BeginApplyInst:
-      return FullApplySite(cast<BeginApplyInst>(node));
-    case SILNodeKind::TryApplyInst:
-      return FullApplySite(cast<TryApplyInst>(node));
-    default:
+    auto *i = dyn_cast<SILInstruction>(node);
+    if (!i)
       return FullApplySite();
+    auto kind = FullApplySiteKind::fromNodeKind(i->getKind());
+    if (!kind)
+      return FullApplySite();
+    switch (kind.getValue()) {
+    case FullApplySiteKind::ApplyInst:
+      return FullApplySite(cast<ApplyInst>(node));
+    case FullApplySiteKind::BeginApplyInst:
+      return FullApplySite(cast<BeginApplyInst>(node));
+    case FullApplySiteKind::TryApplyInst:
+      return FullApplySite(cast<TryApplyInst>(node));
     }
   }
 
@@ -7846,9 +7918,7 @@
   }
 
   static bool classof(const SILInstruction *inst) {
-    return (inst->getKind() == SILInstructionKind::ApplyInst ||
-            inst->getKind() == SILInstructionKind::BeginApplyInst ||
-            inst->getKind() == SILInstructionKind::TryApplyInst);
+    return bool(FullApplySiteKind::fromNodeKind(inst->getKind()));
   }
 };
 
diff --git a/include/swift/SIL/SILNodes.def b/include/swift/SIL/SILNodes.def
index 5425ccb..48c62a3 100644
--- a/include/swift/SIL/SILNodes.def
+++ b/include/swift/SIL/SILNodes.def
@@ -9,11 +9,63 @@
 // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
 //
 //===----------------------------------------------------------------------===//
-//
-// This file defines macros used for macro-metaprogramming with SIL nodes.
-//
+///
+/// \file
+///
+/// This file defines macros used for macro-metaprogramming with SIL nodes. It
+/// supports changing how macros expand by #defining an auxillary variable
+/// before including SILNodes.def as summarized in the chart below:
+///
+/// | #define            | Operation                                               |
+/// |--------------------+---------------------------------------------------------|
+/// | N/A                | Visit single value insts as insts                       |
+/// | VALUE              | Visit single value insts as values                      |
+/// | ABSTRACT_VALUE     | Visit abstract single value insts as values             |
+/// | APPLYSITE_INST     | Visit full and partial apply site insts as apply sites. |
+/// | FULLAPPLYSITE_INST | Visit full apply site insts as apply sites.             |
+///
+/// We describe the triggering variables below:
+///
+/// 1. VALUE(ID, PARENT).
+///
+///     If defined will cause SingleValueInsts to passed to VALUE(ID, PARENT)
+///     instead of to FULL_INST.
+///
+/// 2. ABSTRACT_VALUE(ID, PARENT).
+///
+///     If defined this will cause ABSTRACT_SINGLE_VALUE_INST to expand to
+///     ABSTRACT_VALUE INSTEAD OF ABSTRACT_INST.
+///
+/// 3. FULLAPPLYSITE_INST(ID, PARENT).
+///
+///   If defined this will cause:
+///
+///       * FULLAPPLYSITE_SINGLE_VALUE_INST,
+///       * FULLAPPLYSITE_MULTIPLE_VALUE_INST,
+///       * FULLAPPLYSITE_TERMINATOR_INST,
+///
+///   To expand to FULLAPPLYSITE_INST(ID, PARENT) instead of SINGLE_VALUE_INST,
+///   MULTIPLE_VALUE_INST, or TERMINATOR_INST.
+///
+/// 4. APPLYSITE_INST(ID, PARENT)
+///
+///   If defined this will cuase:
+///
+///         * APPLYSITE_SINGLE_VALUE_INST
+///         * APPLYSITE_MULTIPLE_VALUE_INST
+///         * APPLYSITE_TERMINATOR_INST
+///
+///   to expand to APPLYSITE_INST(ID, PARENT) instead of delegating to
+///   SINGLE_VALUE_INST.
+///
 //===----------------------------------------------------------------------===//
 
+#ifdef APPLYSITE_INST
+#ifdef FULLAPPLYSITE_INST
+#error "Can not query for apply site and full apply site in one include"
+#endif
+#endif
+
 /// NODE(ID, PARENT)
 ///
 ///   A concrete subclass of SILNode.  ID is the name of the class as well
@@ -38,6 +90,26 @@
 #endif
 #endif
 
+#ifndef APPLYSITE_SINGLE_VALUE_INST
+#ifdef APPLYSITE_INST
+#define APPLYSITE_SINGLE_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE) \
+  APPLYSITE_INST(ID, PARENT)
+#else
+#define APPLYSITE_SINGLE_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE) \
+  SINGLE_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE)
+#endif
+#endif
+
+#ifndef FULLAPPLYSITE_SINGLE_VALUE_INST
+#ifdef FULLAPPLYSITE_INST
+#define FULLAPPLYSITE_SINGLE_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE) \
+  FULLAPPLYSITE_INST(ID, PARENT)
+#else
+#define FULLAPPLYSITE_SINGLE_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE) \
+  APPLYSITE_SINGLE_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE)
+#endif
+#endif
+
 /// MULTIPLE_VALUE_INST(Id, TextualName, Parent, MemBehavior, MayRelease)
 ///
 ///   A concrete subclass of MultipleValueInstruction. ID is a member of
@@ -48,6 +120,26 @@
   FULL_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE)
 #endif
 
+#ifndef APPLYSITE_MULTIPLE_VALUE_INST
+#ifdef APPLYSITE_INST
+#define APPLYSITE_MULTIPLE_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE) \
+  APPLYSITE_INST(ID, PARENT)
+#else
+#define APPLYSITE_MULTIPLE_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE) \
+  MULTIPLE_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE)
+#endif
+#endif
+
+#ifndef FULLAPPLYSITE_MULTIPLE_VALUE_INST
+#ifdef FULLAPPLYSITE_INST
+#define FULLAPPLYSITE_MULTIPLE_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE) \
+  FULLAPPLYSITE_INST(ID, PARENT)
+#else
+#define FULLAPPLYSITE_MULTIPLE_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE) \
+  APPLYSITE_MULTIPLE_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE)
+#endif
+#endif
+
 /// MULTIPLE_VALUE_INST_RESULT(ID, PARENT)
 ///
 ///   A concrete subclass of MultipleValueInstructionResult. ID is a member of
@@ -115,6 +207,34 @@
   NON_VALUE_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE)
 #endif
 
+/// APPLYSITE_TERMINATOR_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE)
+///
+/// ID is a member of ApplySiteKind, TerminatorKind, and ApplySiteKind and name
+/// of a subclass of TermInst.
+#ifndef APPLYSITE_TERMINATOR_INST
+#ifdef APPLYSITE_INST
+#define APPLYSITE_TERMINATOR_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE) \
+  APPLYSITE_INST(ID, NAME)
+#else
+#define APPLYSITE_TERMINATOR_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE) \
+  TERMINATOR(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE)
+#endif
+#endif
+
+/// FULLAPPLYSITE_TERMINATOR(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE)
+///
+/// ID is a member of FullApplySiteKind, TerminatorKind, and ApplySiteKind and
+/// name of a subclass of TermInst.
+#ifndef FULLAPPLYSITE_TERMINATOR_INST
+#ifdef FULLAPPLYSITE_INST
+#define FULLAPPLYSITE_TERMINATOR_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE) \
+  FULLAPPLYSITE_INST(ID, PARENT)
+#else
+#define FULLAPPLYSITE_TERMINATOR_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE) \
+  APPLYSITE_TERMINATOR_INST(ID, NAME, PARENT, MEMBEHAVIOR, MAYRELEASE)
+#endif
+#endif
+
 /// ABSTRACT_NODE(ID, PARENT)
 ///
 ///   An abstract class in the SILNode hierarchy.   It does not have an
@@ -405,13 +525,13 @@
                     SingleValueInstruction, None, DoesNotRelease)
 
   // Function Application
-  SINGLE_VALUE_INST(ApplyInst, apply,
-                    SingleValueInstruction, MayHaveSideEffects, MayRelease)
+  FULLAPPLYSITE_SINGLE_VALUE_INST(ApplyInst, apply,
+                                  SingleValueInstruction, MayHaveSideEffects, MayRelease)
   SINGLE_VALUE_INST(BuiltinInst, builtin,
                     SingleValueInstruction, MayHaveSideEffects, MayRelease)
-  SINGLE_VALUE_INST(PartialApplyInst, partial_apply,
-                    SingleValueInstruction, MayHaveSideEffects, DoesNotRelease)
-  
+  APPLYSITE_SINGLE_VALUE_INST(PartialApplyInst, partial_apply,
+                              SingleValueInstruction, MayHaveSideEffects, DoesNotRelease)
+
   // Metatypes
   SINGLE_VALUE_INST(MetatypeInst, metatype,
                     SingleValueInstruction, None, DoesNotRelease)
@@ -508,8 +628,8 @@
              TermInst, MayHaveSideEffects, MayRelease)
   TERMINATOR(UnwindInst, unwind,
              TermInst, None, DoesNotRelease)
-  TERMINATOR(TryApplyInst, try_apply,
-             TermInst, MayHaveSideEffects, MayRelease)
+  FULLAPPLYSITE_TERMINATOR_INST(TryApplyInst, try_apply,
+                                TermInst, MayHaveSideEffects, MayRelease)
   TERMINATOR(BranchInst, br,
              TermInst, None, DoesNotRelease)
   TERMINATOR(CondBranchInst, cond_br,
@@ -647,12 +767,12 @@
 NODE_RANGE(NonValueInstruction, UnreachableInst, CondFailInst)
 
 ABSTRACT_INST(MultipleValueInstruction, SILInstruction)
-MULTIPLE_VALUE_INST(BeginApplyInst, begin_apply,
-                    SILInstruction, MayHaveSideEffects, MayRelease)
+FULLAPPLYSITE_MULTIPLE_VALUE_INST(BeginApplyInst, begin_apply,
+                                  MultipleValueInstruction, MayHaveSideEffects, MayRelease)
 MULTIPLE_VALUE_INST(DestructureStructInst, destructure_struct,
-                    SILInstruction, None, DoesNotRelease)
+                    MultipleValueInstruction, None, DoesNotRelease)
 MULTIPLE_VALUE_INST(DestructureTupleInst, destructure_tuple,
-                    SILInstruction, None, DoesNotRelease)
+                    MultipleValueInstruction, None, DoesNotRelease)
 INST_RANGE(MultipleValueInstruction, BeginApplyInst, DestructureTupleInst)
 
 NODE_RANGE(SILInstruction, AllocStackInst, DestructureTupleInst)
@@ -667,13 +787,21 @@
 #undef ABSTRACT_VALUE
 #undef ABSTRACT_NODE
 #undef ABSTRACT_VALUE_AND_INST
+#undef FULLAPPLYSITE_TERMINATOR_INST
+#undef APPLYSITE_TERMINATOR_INST
 #undef TERMINATOR
 #undef NON_VALUE_INST
 #undef MULTIPLE_VALUE_INST_RESULT
+#undef FULLAPPLYSITE_MULTIPLE_VALUE_INST
+#undef APPLYSITE_MULTIPLE_VALUE_INST
 #undef MULTIPLE_VALUE_INST
+#undef FULLAPPLYSITE_SINGLE_VALUE_INST
+#undef APPLYSITE_SINGLE_VALUE_INST
 #undef SINGLE_VALUE_INST
 #undef FULL_INST
 #undef INST
 #undef ARGUMENT
 #undef VALUE
 #undef NODE
+#undef APPLYSITE_INST
+#undef FULLAPPLYSITE_INST