From d5efcc98f8c0f78681b1e22f06d4282a2e63f35f Mon Sep 17 00:00:00 2001 From: George Burgess IV Date: Tue, 6 Mar 2018 23:07:00 +0000 Subject: [PATCH] [CodeGen] Don't emit lifetime.end without lifetime.start EmitLifetimeStart returns a non-null `size` pointer if it actually emits a lifetime.start. Later in this function, we use `tempSize`'s nullness to determine whether or not we should emit a lifetime.end. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326844 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGCall.cpp | 4 +--- test/CodeGen/64bit-swiftcall.c | 9 +++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index ebba2501ce..187697ee0b 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -4010,13 +4010,11 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, auto scalarSize = CGM.getDataLayout().getTypeAllocSize(scalarType); auto scalarAlign = CGM.getDataLayout().getPrefTypeAlignment(scalarType); - tempSize = llvm::ConstantInt::get(CGM.Int64Ty, scalarSize); - // Materialize to a temporary. addr = CreateTempAlloca(RV.getScalarVal()->getType(), CharUnits::fromQuantity(std::max(layout->getAlignment(), scalarAlign))); - EmitLifetimeStart(scalarSize, addr.getPointer()); + tempSize = EmitLifetimeStart(scalarSize, addr.getPointer()); Builder.CreateStore(RV.getScalarVal(), addr); } diff --git a/test/CodeGen/64bit-swiftcall.c b/test/CodeGen/64bit-swiftcall.c index c5944b99b5..2eed2a4b29 100644 --- a/test/CodeGen/64bit-swiftcall.c +++ b/test/CodeGen/64bit-swiftcall.c @@ -1032,3 +1032,12 @@ typedef union { TEST(union_hom_fp_partial2) // X86-64-LABEL: take_union_hom_fp_partial2(i64, float) // ARM64-LABEL: take_union_hom_fp_partial2(i64, float) + +// At one point, we emitted lifetime.ends without a matching lifetime.begin for +// CoerceAndExpanded args. Since we're not performing optimizations, neither +// intrinsic should be emitted. +// CHECK-LABEL: define void @no_lifetime_markers +void no_lifetime_markers() { + // CHECK-NOT: call void @llvm.lifetime. + take_int5(return_int5()); +} -- 2.50.1