r239643 - [CodeGen] Use IRBuilder to create llvm.lifetime intrinsics.
Alexey Samsonov
vonosmas at gmail.com
Fri Jun 12 15:31:33 PDT 2015
Author: samsonov
Date: Fri Jun 12 17:31:32 2015
New Revision: 239643
URL: http://llvm.org/viewvc/llvm-project?rev=239643&view=rev
Log:
[CodeGen] Use IRBuilder to create llvm.lifetime intrinsics.
Summary:
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.
Test Plan: regression test suite
Reviewers: aadg, dblaikie
Subscribers: cfe-commits, majnemer
Differential Revision: http://reviews.llvm.org/D10418
Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/test/CodeGen/cleanup-destslot-simple.c
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=239643&r1=239642&r2=239643&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Fri Jun 12 17:31:32 2015
@@ -864,20 +864,17 @@ llvm::Value *CodeGenFunction::EmitLifeti
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::CallInst *C =
+ Builder.CreateCall(CGM.getLLVMLifetimeStartFn(), {SizeV, Addr});
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::CallInst *C =
+ Builder.CreateCall(CGM.getLLVMLifetimeEndFn(), {Size, Addr});
C->setDoesNotThrow();
}
Modified: cfe/trunk/test/CodeGen/cleanup-destslot-simple.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cleanup-destslot-simple.c?rev=239643&r1=239642&r2=239643&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/cleanup-destslot-simple.c (original)
+++ cfe/trunk/test/CodeGen/cleanup-destslot-simple.c Fri Jun 12 17:31:32 2015
@@ -13,7 +13,9 @@ int test() {
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
}
More information about the cfe-commits
mailing list