mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-16 14:31:59 +00:00
Fix a bug in ComputeLinearIndex computation handling multi-level
aggregate types. Don't increment the current index after reaching the end of a struct, as it will already be pointing at one-past-the end. This fixes PR3288. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61828 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5d31598954
commit
2c91d102ec
@ -63,7 +63,7 @@ LimitFPPrecision("limit-float-precision",
|
|||||||
cl::init(0));
|
cl::init(0));
|
||||||
|
|
||||||
/// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence
|
/// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence
|
||||||
/// insertvalue or extractvalue indices that identify a member, return
|
/// of insertvalue or extractvalue indices that identify a member, return
|
||||||
/// the linearized index of the start of the member.
|
/// the linearized index of the start of the member.
|
||||||
///
|
///
|
||||||
static unsigned ComputeLinearIndex(const TargetLowering &TLI, const Type *Ty,
|
static unsigned ComputeLinearIndex(const TargetLowering &TLI, const Type *Ty,
|
||||||
@ -84,6 +84,7 @@ static unsigned ComputeLinearIndex(const TargetLowering &TLI, const Type *Ty,
|
|||||||
return ComputeLinearIndex(TLI, *EI, Indices+1, IndicesEnd, CurIndex);
|
return ComputeLinearIndex(TLI, *EI, Indices+1, IndicesEnd, CurIndex);
|
||||||
CurIndex = ComputeLinearIndex(TLI, *EI, 0, 0, CurIndex);
|
CurIndex = ComputeLinearIndex(TLI, *EI, 0, 0, CurIndex);
|
||||||
}
|
}
|
||||||
|
return CurIndex;
|
||||||
}
|
}
|
||||||
// Given an array type, recursively traverse the elements.
|
// Given an array type, recursively traverse the elements.
|
||||||
else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
|
else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
|
||||||
@ -93,6 +94,7 @@ static unsigned ComputeLinearIndex(const TargetLowering &TLI, const Type *Ty,
|
|||||||
return ComputeLinearIndex(TLI, EltTy, Indices+1, IndicesEnd, CurIndex);
|
return ComputeLinearIndex(TLI, EltTy, Indices+1, IndicesEnd, CurIndex);
|
||||||
CurIndex = ComputeLinearIndex(TLI, EltTy, 0, 0, CurIndex);
|
CurIndex = ComputeLinearIndex(TLI, EltTy, 0, 0, CurIndex);
|
||||||
}
|
}
|
||||||
|
return CurIndex;
|
||||||
}
|
}
|
||||||
// We haven't found the type we're looking for, so keep searching.
|
// We haven't found the type we're looking for, so keep searching.
|
||||||
return CurIndex + 1;
|
return CurIndex + 1;
|
||||||
|
67
test/CodeGen/Generic/pr3288.ll
Normal file
67
test/CodeGen/Generic/pr3288.ll
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
; RUN: llvm-as < %s | llc
|
||||||
|
; PR3288
|
||||||
|
|
||||||
|
define void @a() {
|
||||||
|
%i = insertvalue [2 x [2 x i32]] undef, [2 x i32] undef, 1
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @b() {
|
||||||
|
%i = insertvalue {{i32,float},{i16,double}} undef, {i16,double} undef, 1
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @c() {
|
||||||
|
%i = insertvalue [2 x [2 x i32]] zeroinitializer, [2 x i32] zeroinitializer, 1
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @d() {
|
||||||
|
%i = insertvalue {{i32,float},{i16,double}} zeroinitializer, {i16,double} zeroinitializer, 1
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @e() {
|
||||||
|
%i = insertvalue [2 x [2 x i32]] undef, [2 x i32] undef, 0
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @f() {
|
||||||
|
%i = insertvalue {{i32,float},{i16,double}} undef, {i32,float} undef, 0
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @g() {
|
||||||
|
%i = insertvalue [2 x [2 x i32]] zeroinitializer, [2 x i32] zeroinitializer, 0
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @h() {
|
||||||
|
%i = insertvalue {{i32,float},{i16,double}} zeroinitializer, {i32,float} zeroinitializer, 0
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @ax() {
|
||||||
|
%i = insertvalue [2 x [2 x i32]] undef, i32 undef, 1, 1
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @bx() {
|
||||||
|
%i = insertvalue {{i32,float},{i16,double}} undef, double undef, 1, 1
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @cx() {
|
||||||
|
%i = insertvalue [2 x [2 x i32]] zeroinitializer, i32 zeroinitializer, 1, 1
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @dx() {
|
||||||
|
%i = insertvalue {{i32,float},{i16,double}} zeroinitializer, double zeroinitializer, 1, 1
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @ex() {
|
||||||
|
%i = insertvalue [2 x [2 x i32]] undef, i32 undef, 0, 1
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @fx() {
|
||||||
|
%i = insertvalue {{i32,float},{i16,double}} undef, float undef, 0, 1
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @gx() {
|
||||||
|
%i = insertvalue [2 x [2 x i32]] zeroinitializer, i32 zeroinitializer, 0, 1
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
define void @hx() {
|
||||||
|
%i = insertvalue {{i32,float},{i16,double}} zeroinitializer, float zeroinitializer, 0, 1
|
||||||
|
ret void
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user