diff options
author | John McCall <rjmccall@apple.com> | 2010-07-21 00:41:47 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-07-21 00:41:47 +0000 |
commit | c20acd31f735e83ea617ac8da7c6d251ca548137 (patch) | |
tree | d4de856c2f7bff588f0ffea19227e35192215cce /clang/lib/CodeGen/CGObjCGNU.cpp | |
parent | 8f510411849599853e94cf010bb06f34a879452c (diff) | |
download | bcm5719-llvm-c20acd31f735e83ea617ac8da7c6d251ca548137.tar.gz bcm5719-llvm-c20acd31f735e83ea617ac8da7c6d251ca548137.zip |
Convert the ObjC @synchronized cleanups to laziness. This is not actually
a big deal, except that I want to eliminate the shared-code EH cleanups
in preparation for a significant algorithmic fix.
llvm-svn: 108973
Diffstat (limited to 'clang/lib/CodeGen/CGObjCGNU.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGObjCGNU.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index 1b8705055ea..567b8c3d7de 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -1855,6 +1855,19 @@ llvm::Constant *CGObjCGNU::EnumerationMutationFunction() { return CGM.CreateRuntimeFunction(FTy, "objc_enumerationMutation"); } +namespace { + struct CallSyncExit : EHScopeStack::LazyCleanup { + llvm::Value *SyncExitFn; + llvm::Value *SyncArg; + CallSyncExit(llvm::Value *SyncExitFn, llvm::Value *SyncArg) + : SyncExitFn(SyncExitFn), SyncArg(SyncArg) {} + + void Emit(CodeGenFunction &CGF, bool IsForEHCleanup) { + CGF.Builder.CreateCall(SyncExitFn, SyncArg)->setDoesNotThrow(); + } + }; +} + void CGObjCGNU::EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtSynchronizedStmt &S) { std::vector<const llvm::Type*> Args(1, IdTy); @@ -1871,13 +1884,9 @@ void CGObjCGNU::EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF, CGF.Builder.CreateCall(SyncEnter, SyncArg); // Register an all-paths cleanup to release the lock. - { - CodeGenFunction::CleanupBlock ReleaseScope(CGF, NormalAndEHCleanup); - - llvm::Value *SyncExit = CGM.CreateRuntimeFunction(FTy, "objc_sync_exit"); - SyncArg = CGF.Builder.CreateBitCast(SyncArg, IdTy); - CGF.Builder.CreateCall(SyncExit, SyncArg); - } + llvm::Value *SyncExit = CGM.CreateRuntimeFunction(FTy, "objc_sync_exit"); + CGF.EHStack.pushLazyCleanup<CallSyncExit>(NormalAndEHCleanup, + SyncExit, SyncArg); // Emit the body of the statement. CGF.EmitStmt(S.getSynchBody()); |