[CodeGen] Correctly handle base classes which are passed in memory

We didn't correctly process the case where a base class is classified as
MEMORY.  This would cause us to trip over an assertion.

This fixes PR24020.

Differential Revision: http://reviews.llvm.org/D10907

llvm-svn: 241667
This commit is contained in:
David Majnemer
2015-07-08 05:14:29 +00:00
parent 699dd04a13
commit cefbc7cfcb
2 changed files with 20 additions and 2 deletions

View File

@@ -2073,8 +2073,10 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase,
classify(I.getType(), Offset, FieldLo, FieldHi, isNamedArg);
Lo = merge(Lo, FieldLo);
Hi = merge(Hi, FieldHi);
if (Lo == Memory || Hi == Memory)
break;
if (Lo == Memory || Hi == Memory) {
postMerge(Size, Lo, Hi);
return;
}
}
}

View File

@@ -196,3 +196,19 @@ namespace test9 {
return sret;
}
}
namespace test10 {
#pragma pack(1)
struct BasePacked {
char one;
short two;
};
#pragma pack()
struct DerivedPacked : public BasePacked {
int three;
};
// CHECK-LABEL: define i32 @_ZN6test1020FuncForDerivedPackedENS_13DerivedPackedE({{.*}}* byval align 8
int FuncForDerivedPacked(DerivedPacked d) {
return d.three;
}
}