Index: lib/Transforms/IPO/ArgumentPromotion.cpp =================================================================== --- lib/Transforms/IPO/ArgumentPromotion.cpp +++ lib/Transforms/IPO/ArgumentPromotion.cpp @@ -183,10 +183,12 @@ continue; } - // If all the elements are single-value types, we can promote it. + // If all the elements are single-value types, we can promote it, unless + // its alloca size differs from its size in bits bool AllSimple = true; for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { - if (!STy->getElementType(i)->isSingleValueType()) { + Type *ElTy = STy->getElementType(i); + if (!ElTy->isSingleValueType() || ElTy->isX86_FP80Ty()) { AllSimple = false; break; } Index: test/Transforms/ArgumentPromotion/fp80.ll =================================================================== --- test/Transforms/ArgumentPromotion/fp80.ll +++ test/Transforms/ArgumentPromotion/fp80.ll @@ -0,0 +1,45 @@ +; RUN: opt < %s -argpromotion -S | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%union.u = type { x86_fp80 } + +@b = internal global { { double, i16, i8, [5 x i8] } } { { double, i16, i8, [5 x i8] } { double 3.14, i16 9439, i8 25, [5 x i8] undef } }, align 16 + +%struct.Foo = type { i32, i64 } +@a = internal global %struct.Foo { i32 1, i64 2 }, align 8 + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture readnone %argv) { +entry: + tail call fastcc i8 @foo(%union.u* byval align 16 bitcast ({ { double, i16, i8, [5 x i8] } }* @b to %union.u*)) + tail call fastcc x86_fp80 @baz(%union.u* byval align 16 bitcast ({ { double, i16, i8, [5 x i8] } }* @b to %union.u*)) + call i64 @qux(%struct.Foo* @a) + ret i32 0 +} + +; CHECK: @foo(%union.u* byval +; Function Attrs: noinline nounwind uwtable +define internal fastcc i8 @foo(%union.u* byval nocapture readonly align 16 %arg) { +entry: + %bitcast = bitcast %union.u* %arg to { double, i16, i8, [5 x i8] }* + %gep = getelementptr inbounds { double, i16, i8, [5 x i8] }* %bitcast, i64 0, i32 2 + %result = load i8* %gep + ret i8 %result +} + +; CHECK: @baz(x86_fp80 +; Function Attrs: noinline nounwind uwtable +define internal fastcc x86_fp80 @baz(%union.u* byval nocapture readonly align 16 %arg) { + %gep = getelementptr inbounds %union.u* %arg, i64 0, i32 0 + %fp80 = load x86_fp80* %gep + ret x86_fp80 %fp80 +} + +; CHECK: @qux(i32 {{.*}} i64 +define internal i64 @qux(%struct.Foo* byval %a) { + %p = bitcast %struct.Foo* %a to i64* + %v = load i64* %p + ret i64 %v +}