diff --git a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h index c259e93fdd36..b229411c8148 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h @@ -162,6 +162,9 @@ public: /// on Ty until we find a legal type for this operation. Optional findLegalizableSize(const InstrAspect &Aspect, function_ref NextType) const { + if (Aspect.Idx >= Actions[Aspect.Opcode - FirstOp].size()) + return None; + LegalizeAction Action; const TypeMap &Map = Actions[Aspect.Opcode - FirstOp][Aspect.Idx]; LLT Ty = Aspect.Type;