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,35 @@ +; 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 } + +@lj12 = 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 + +; Function Attrs: nounwind uwtable +define i32 @main(i32 %argc, i8** nocapture readnone %argv) #0 { +entry: + tail call fastcc void @foo(%union.u* byval align 16 bitcast ({ { double, i16, i8, [5 x i8] } }* @lj12 to %union.u*)) + tail call fastcc void @baz(%union.u* byval align 16 bitcast ({ { double, i16, i8, [5 x i8] } }* @lj12 to %union.u*)) + ret i32 0 +} + +; CHECK-NOT: @foo(x86_fp80 +; Function Attrs: noinline nounwind uwtable +define internal fastcc void @foo(%union.u* byval nocapture readonly align 16 %ljp5) { +entry: + %lj6 = bitcast %union.u* %ljp5 to { double, i16, i8, [5 x i8] }* + ret void +} + +; CHECK: @baz(x86_fp80 +; Function Attrs: noinline nounwind uwtable +define internal fastcc void @baz(%union.u* byval nocapture readonly align 16 %ljp5) { + %gep = getelementptr inbounds %union.u* %ljp5, i64 0, i32 0 + %fp80 = load x86_fp80* %gep + call void @bar(x86_fp80 %fp80) + ret void +} + +declare void @bar(x86_fp80) \ No newline at end of file