Index: lib/CodeGen/TargetInfo.cpp =================================================================== --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -2073,8 +2073,10 @@ 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; + } } } Index: test/CodeGenCXX/x86_64-arguments.cpp =================================================================== --- test/CodeGenCXX/x86_64-arguments.cpp +++ test/CodeGenCXX/x86_64-arguments.cpp @@ -196,3 +196,19 @@ 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; +} +}