[PATCH] [CodeGen] Use IRBuilder to create llvm.lifetime intrinsics.
David Blaikie
dblaikie at gmail.com
Fri Jun 12 14:24:07 PDT 2015
On Fri, Jun 12, 2015 at 2:11 PM, Alexey Samsonov <vonosmas at gmail.com> wrote:
> Hi aadg, dblaikie,
>
> In addition to easier syntax, IRBuilder makes sure to set correct
> debug locations for newly added instructions (bitcast and
> llvm.lifetime itself). This restores the original behavior, which
> was modified by r234581 (reapplied as r235553).
>
> Extend one of the tests to check for debug locations.
>
> http://reviews.llvm.org/D10418
>
> Files:
> lib/CodeGen/CGDecl.cpp
> test/CodeGen/cleanup-destslot-simple.c
>
> Index: lib/CodeGen/CGDecl.cpp
> ===================================================================
> --- lib/CodeGen/CGDecl.cpp
> +++ lib/CodeGen/CGDecl.cpp
> @@ -864,20 +864,17 @@
> return nullptr;
>
> llvm::Value *SizeV = llvm::ConstantInt::get(Int64Ty, Size);
> - llvm::Value *Args[] = {
> - SizeV,
> - new llvm::BitCastInst(Addr, Int8PtrTy, "",
> Builder.GetInsertBlock())};
> - llvm::CallInst *C =
> llvm::CallInst::Create(CGM.getLLVMLifetimeStartFn(), Args,
> - "",
> Builder.GetInsertBlock());
> + Addr = Builder.CreateBitCast(Addr, Int8PtrTy);
> + llvm::Value *Args[] = {SizeV, Addr};
> + llvm::CallInst *C = Builder.CreateCall(CGM.getLLVMLifetimeStartFn(),
> Args);
>
Seems simple enough/good to me. Please commit.
(if anyone feels like simplifying this code a bit, it could be written as:
... CreateCall(..., {SizeV, Addr});
& drop the Args variable entirely.
> C->setDoesNotThrow();
> return SizeV;
> }
>
> void CodeGenFunction::EmitLifetimeEnd(llvm::Value *Size, llvm::Value
> *Addr) {
> - llvm::Value *Args[] = {Size, new llvm::BitCastInst(Addr, Int8PtrTy, "",
> -
> Builder.GetInsertBlock())};
> - llvm::CallInst *C = llvm::CallInst::Create(CGM.getLLVMLifetimeEndFn(),
> Args,
> - "",
> Builder.GetInsertBlock());
> + Addr = Builder.CreateBitCast(Addr, Int8PtrTy);
> + llvm::Value *Args[] = {Size, Addr};
> + llvm::CallInst *C = Builder.CreateCall(CGM.getLLVMLifetimeEndFn(),
> Args);
> C->setDoesNotThrow();
> }
>
> Index: test/CodeGen/cleanup-destslot-simple.c
> ===================================================================
> --- test/CodeGen/cleanup-destslot-simple.c
> +++ test/CodeGen/cleanup-destslot-simple.c
> @@ -13,7 +13,9 @@
> return *p;
> // CHECK: [[X:%.*]] = alloca i32
> // CHECK: [[P:%.*]] = alloca i32*
> -// LIFETIME: call void @llvm.lifetime.start(i64 4, i8* %{{.*}})
> -// LIFETIME: call void @llvm.lifetime.start(i64 8, i8* %{{.*}})
> +// LIFETIME: call void @llvm.lifetime.start(i64 4, i8* %{{.*}}){{(
> #[0-9]+)?}}, !dbg
> +// LIFETIME: call void @llvm.lifetime.start(i64 8, i8* %{{.*}}){{(
> #[0-9]+)?}}, !dbg
> // CHECK-NOT: store i32 %{{.*}}, i32* %cleanup.dest.slot
> +// LIFETIME: call void @llvm.lifetime.end(i64 8, {{.*}}){{( #[0-9]+)?}},
> !dbg
> +// LIFETIME: call void @llvm.lifetime.end(i64 4, {{.*}}){{( #[0-9]+)?}},
> !dbg
> }
>
> EMAIL PREFERENCES
> http://reviews.llvm.org/settings/panel/emailpreferences/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150612/6cea98e1/attachment.html>
More information about the cfe-commits
mailing list