Rework the IR-generation of initialization and teach the

compiler to enter properly-scoped cleanups to destroy local
variables.

Swift SVN r1385
This commit is contained in:
John McCall
2012-04-11 03:00:08 +00:00
parent 828463aa8d
commit 5ad3782b01
19 changed files with 735 additions and 301 deletions

View File

@@ -53,6 +53,7 @@ IRGenModule::IRGenModule(ASTContext &Context,
AllocFn = nullptr;
RetainFn = nullptr;
ReleaseFn = nullptr;
DeallocFn = nullptr;
RefCountedStructTy =
llvm::StructType::create(getLLVMContext(), "swift.refcounted");
@@ -109,6 +110,15 @@ llvm::Constant *IRGenModule::getReleaseFn() {
return ReleaseFn;
}
llvm::Constant *IRGenModule::getDeallocFn() {
if (DeallocFn) return DeallocFn;
llvm::FunctionType *fnType =
llvm::FunctionType::get(VoidTy, RefCountedPtrTy, false);
DeallocFn = Module.getOrInsertFunction("swift_dealloc", fnType);
return DeallocFn;
}
void IRGenModule::unimplemented(SourceLoc Loc, StringRef Message) {
Context.Diags.diagnose(Loc, diag::irgen_unimplemented, Message);
}