[PATCH] D34978: [GlobalIsel] fix undefined behavior if Action not set.

Igor Breger via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 4 04:15:58 PDT 2017


igorb created this revision.
Herald added subscribers: kristof.beyls, rovka.

It aslo crashing in debug mode.


https://reviews.llvm.org/D34978

Files:
  include/llvm/CodeGen/GlobalISel/LegalizerInfo.h


Index: include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
===================================================================
--- include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
+++ include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
@@ -162,6 +162,9 @@
   /// on Ty until we find a legal type for this operation.
   Optional<LLT> findLegalizableSize(const InstrAspect &Aspect,
                                     function_ref<LLT(LLT)> 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34978.105151.patch
Type: text/x-patch
Size: 662 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170704/e3d14d0a/attachment.bin>


More information about the llvm-commits mailing list