switch the frontend to generate swift_retain_noresult calls instead of

swift_retain calls.  The pertinent difference is that the former can be
marked nocapture, allowing general LLVM optimizations more flexibility.

With this change, early-cse is able to zap 9 more instructions, and 3
more functions are able to be marked nocapture by functionattrs in the
stdlib.


Swift SVN r2043
This commit is contained in:
Chris Lattner
2012-05-28 20:20:07 +00:00
parent 71b4f04ee3
commit 16cf77644f
8 changed files with 36 additions and 37 deletions

View File

@@ -51,7 +51,7 @@ IRGenModule::IRGenModule(ASTContext &Context,
SizeTy = TargetData.getIntPtrType(getLLVMContext());
MemCpyFn = nullptr;
AllocObjectFn = nullptr;
RetainFn = nullptr;
RetainNoResultFn = nullptr;
ReleaseFn = nullptr;
DeallocObjectFn = nullptr;
ObjCRetainFn = nullptr;
@@ -154,19 +154,24 @@ llvm::Constant *IRGenModule::getSlowRawDeallocFn() {
return SlowRawDeallocFn;
}
llvm::Constant *IRGenModule::getRetainFn() {
if (RetainFn) return RetainFn;
llvm::Constant *IRGenModule::getRetainNoResultFn() {
if (RetainNoResultFn) return RetainNoResultFn;
RetainFn = Module.getOrInsertFunction("swift_retain", RefCountedPtrTy,
RefCountedPtrTy, NULL);
return RetainFn;
llvm::AttributeWithIndex Attrs[] = {
{ llvm::Attribute::NoCapture, 1 },
{ llvm::Attribute::NoUnwind, ~0U },
};
auto AttrList = llvm::AttrListPtr::get(Attrs);
return RetainNoResultFn =
Module.getOrInsertFunction("swift_retain_noresult", AttrList,
VoidTy, RefCountedPtrTy, NULL);
}
llvm::Constant *IRGenModule::getReleaseFn() {
if (ReleaseFn) return ReleaseFn;
llvm::AttributeWithIndex AttrList[] = {
llvm::AttributeWithIndex::get(1, llvm::Attribute::NoCapture)
{ llvm::Attribute::NoCapture, 1 },
};
auto Attrs = llvm::AttrListPtr::get(AttrList);
ReleaseFn = Module.getOrInsertFunction("swift_release", Attrs, VoidTy,