[PATCH] D49442: [GlobalISel] Fix offsets to valueIsSplit

Amara Emerson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 14 05:05:14 PDT 2018


This revision was not accepted when it landed; it landed in state "Needs Revision".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL339674: [GlobalISel][IRTranslator] Fix a bug in handling repeating struct types during… (authored by aemerson, committed by ).
Herald added a reviewer: javed.absar.

Changed prior to commit:
  https://reviews.llvm.org/D49442?vs=155934&id=160559#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49442

Files:
  llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h
  llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/trunk/test/CodeGen/AArch64/GlobalISel/irtranslator-duplicate-types-param.ll


Index: llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h
===================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h
@@ -232,6 +232,7 @@
 
   /// Returns true if the value should be split into multiple LLTs.
   /// If \p Offsets is given then the split type's offsets will be stored in it.
+  /// If \p Offsets is not empty it will be cleared first.
   bool valueIsSplit(const Value &V,
                     SmallVectorImpl<uint64_t> *Offsets = nullptr);
 
Index: llvm/trunk/test/CodeGen/AArch64/GlobalISel/irtranslator-duplicate-types-param.ll
===================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/irtranslator-duplicate-types-param.ll
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/irtranslator-duplicate-types-param.ll
@@ -0,0 +1,15 @@
+; RUN: llc -O0 -o - -verify-machineinstrs %s | FileCheck %s
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-gnu"
+
+; Check we don't crash due to encountering the same struct param type twice.
+; CHECK-LABEL: param_two_struct
+; CHECK: add
+; CHECK: ret
+define i64 @param_two_struct([2 x i64] %t.coerce, [2 x i64] %s.coerce) {
+entry:
+  %t.coerce.fca.0.extract = extractvalue [2 x i64] %t.coerce, 0
+  %s.coerce.fca.1.extract = extractvalue [2 x i64] %s.coerce, 1
+  %add = add nsw i64 %s.coerce.fca.1.extract, %t.coerce.fca.0.extract
+  ret i64 %add
+}
Index: llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -1457,6 +1457,8 @@
 bool IRTranslator::valueIsSplit(const Value &V,
                                 SmallVectorImpl<uint64_t> *Offsets) {
   SmallVector<LLT, 4> SplitTys;
+  if (Offsets && !Offsets->empty())
+    Offsets->clear();
   computeValueLLTs(*DL, *V.getType(), SplitTys, Offsets);
   return SplitTys.size() > 1;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49442.160559.patch
Type: text/x-patch
Size: 2128 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180814/d8c56af4/attachment.bin>


More information about the llvm-commits mailing list