From: Amara Emerson Date: Tue, 14 Aug 2018 12:04:25 +0000 (+0000) Subject: [GlobalISel][IRTranslator] Fix a bug in handling repeating struct types during argume... X-Git-Tag: android-x86-9.0-r1~14344 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0904155b95bcc1d71d73710d18243c2cbaa2dcfd;p=android-x86%2Fexternal-llvm.git [GlobalISel][IRTranslator] Fix a bug in handling repeating struct types during argument lowering. Differential Revision: https://reviews.llvm.org/D49442 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339674 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/CodeGen/GlobalISel/IRTranslator.h b/include/llvm/CodeGen/GlobalISel/IRTranslator.h index f3553966fcd..2498ee93321 100644 --- a/include/llvm/CodeGen/GlobalISel/IRTranslator.h +++ b/include/llvm/CodeGen/GlobalISel/IRTranslator.h @@ -232,6 +232,7 @@ private: /// 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 *Offsets = nullptr); diff --git a/lib/CodeGen/GlobalISel/IRTranslator.cpp b/lib/CodeGen/GlobalISel/IRTranslator.cpp index 765d58c91d2..8559d6055cc 100644 --- a/lib/CodeGen/GlobalISel/IRTranslator.cpp +++ b/lib/CodeGen/GlobalISel/IRTranslator.cpp @@ -1457,6 +1457,8 @@ void IRTranslator::finishPendingPhis() { bool IRTranslator::valueIsSplit(const Value &V, SmallVectorImpl *Offsets) { SmallVector SplitTys; + if (Offsets && !Offsets->empty()) + Offsets->clear(); computeValueLLTs(*DL, *V.getType(), SplitTys, Offsets); return SplitTys.size() > 1; } diff --git a/test/CodeGen/AArch64/GlobalISel/irtranslator-duplicate-types-param.ll b/test/CodeGen/AArch64/GlobalISel/irtranslator-duplicate-types-param.ll new file mode 100644 index 00000000000..c20b855c8e7 --- /dev/null +++ b/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 +}