Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 0904155

Browse files
committed
[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
1 parent 62fcc62 commit 0904155

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

include/llvm/CodeGen/GlobalISel/IRTranslator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ class IRTranslator : public MachineFunctionPass {
232232

233233
/// Returns true if the value should be split into multiple LLTs.
234234
/// If \p Offsets is given then the split type's offsets will be stored in it.
235+
/// If \p Offsets is not empty it will be cleared first.
235236
bool valueIsSplit(const Value &V,
236237
SmallVectorImpl<uint64_t> *Offsets = nullptr);
237238

lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,6 +1457,8 @@ void IRTranslator::finishPendingPhis() {
14571457
bool IRTranslator::valueIsSplit(const Value &V,
14581458
SmallVectorImpl<uint64_t> *Offsets) {
14591459
SmallVector<LLT, 4> SplitTys;
1460+
if (Offsets && !Offsets->empty())
1461+
Offsets->clear();
14601462
computeValueLLTs(*DL, *V.getType(), SplitTys, Offsets);
14611463
return SplitTys.size() > 1;
14621464
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; RUN: llc -O0 -o - -verify-machineinstrs %s | FileCheck %s
2+
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
3+
target triple = "aarch64-unknown-linux-gnu"
4+
5+
; Check we don't crash due to encountering the same struct param type twice.
6+
; CHECK-LABEL: param_two_struct
7+
; CHECK: add
8+
; CHECK: ret
9+
define i64 @param_two_struct([2 x i64] %t.coerce, [2 x i64] %s.coerce) {
10+
entry:
11+
%t.coerce.fca.0.extract = extractvalue [2 x i64] %t.coerce, 0
12+
%s.coerce.fca.1.extract = extractvalue [2 x i64] %s.coerce, 1
13+
%add = add nsw i64 %s.coerce.fca.1.extract, %t.coerce.fca.0.extract
14+
ret i64 %add
15+
}

0 commit comments

Comments
 (0)