From 1bce6ea7b79cbceab5cd0d458a552fd6bf805c09 Mon Sep 17 00:00:00 2001 From: Igor Breger Date: Sun, 20 Aug 2017 06:26:22 +0000 Subject: [PATCH] [GlobalIsel] Fix undefined behavior if Action not set (release), it aslo crashing in debug mode. Differential Revision: https://reviews.llvm.org/D34978 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@311272 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/GlobalISel/LegalizerInfo.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h b/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h index c259e93fdd3..b229411c814 100644 --- a/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h +++ b/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; -- 2.40.0