Revert r103880 (thread-safe static initialization w/ exceptions),

because it's causing strange linker errors. Unfixes PR7144.

llvm-svn: 103890
This commit is contained in:
Douglas Gregor 2010-05-16 00:44:00 +00:00
parent 1b8b8bf25f
commit c278d1b3b9
4 changed files with 21 additions and 69 deletions

View File

@ -321,10 +321,6 @@ CodeGenFunction::EmitStaticCXXBlockVarDeclInit(const VarDecl &D,
EmitBlock(InitCheckBlock); EmitBlock(InitCheckBlock);
// Variables used when coping with thread-safe statics and exceptions.
llvm::BasicBlock *SavedLandingPad = 0;
llvm::BasicBlock *Abort = 0;
if (ThreadsafeStatics) { if (ThreadsafeStatics) {
// Call __cxa_guard_acquire. // Call __cxa_guard_acquire.
V = Builder.CreateCall(getGuardAcquireFn(*this), GuardVariable); V = Builder.CreateCall(getGuardAcquireFn(*this), GuardVariable);
@ -334,13 +330,14 @@ CodeGenFunction::EmitStaticCXXBlockVarDeclInit(const VarDecl &D,
Builder.CreateCondBr(Builder.CreateIsNotNull(V, "tobool"), Builder.CreateCondBr(Builder.CreateIsNotNull(V, "tobool"),
InitBlock, EndBlock); InitBlock, EndBlock);
if (Exceptions) {
SavedLandingPad = getInvokeDest();
Abort = createBasicBlock("guard.abort");
setInvokeDest(Abort);
}
EmitBlock(InitBlock); EmitBlock(InitBlock);
if (Exceptions) {
EHCleanupBlock Cleanup(*this);
// Call __cxa_guard_abort.
Builder.CreateCall(getGuardAbortFn(*this), GuardVariable);
}
} }
if (D.getType()->isReferenceType()) { if (D.getType()->isReferenceType()) {
@ -367,20 +364,5 @@ CodeGenFunction::EmitStaticCXXBlockVarDeclInit(const VarDecl &D,
if (!D.getType()->isReferenceType()) if (!D.getType()->isReferenceType())
EmitDeclDestroy(*this, D, GV); EmitDeclDestroy(*this, D, GV);
if (ThreadsafeStatics && Exceptions) {
// If an exception is thrown during initialization, call __cxa_guard_abort
// along the exceptional edge.
EmitBranch(EndBlock);
EmitBlock(Abort);
// Call __cxa_guard_abort along the exceptional edge.
Builder.CreateCall(getGuardAbortFn(*this), GuardVariable);
setInvokeDest(SavedLandingPad);
// Rethrow the current exception.
EmitRethrow();
}
EmitBlock(EndBlock); EmitBlock(EndBlock);
} }

View File

@ -239,7 +239,8 @@ static void CopyObject(CodeGenFunction &CGF, QualType ObjectType,
} }
} }
void CodeGenFunction::EmitRethrow() { void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) {
if (!E->getSubExpr()) {
if (getInvokeDest()) { if (getInvokeDest()) {
llvm::BasicBlock *Cont = createBasicBlock("invoke.cont"); llvm::BasicBlock *Cont = createBasicBlock("invoke.cont");
Builder.CreateInvoke(getReThrowFn(*this), Cont, getInvokeDest()) Builder.CreateInvoke(getReThrowFn(*this), Cont, getInvokeDest())
@ -251,11 +252,6 @@ void CodeGenFunction::EmitRethrow() {
// Clear the insertion point to indicate we are in unreachable code. // Clear the insertion point to indicate we are in unreachable code.
Builder.ClearInsertionPoint(); Builder.ClearInsertionPoint();
}
void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) {
if (!E->getSubExpr()) {
EmitRethrow();
return; return;
} }
@ -566,7 +562,6 @@ void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S,
// FIXME: we need to do this sooner so that the EH region for the // FIXME: we need to do this sooner so that the EH region for the
// cleanup doesn't start until after the ctor completes, use a decl // cleanup doesn't start until after the ctor completes, use a decl
// init? // init?
// FIXME: Alternatively, can we just elide this copy entirely?
CopyObject(*this, CatchParam->getType().getNonReferenceType(), CopyObject(*this, CatchParam->getType().getNonReferenceType(),
WasPointer, WasPointerReference, ExcObject, WasPointer, WasPointerReference, ExcObject,
GetAddrOfLocalVar(CatchParam)); GetAddrOfLocalVar(CatchParam));

View File

@ -1258,7 +1258,6 @@ public:
bool IsInitializer = false); bool IsInitializer = false);
void EmitCXXThrowExpr(const CXXThrowExpr *E); void EmitCXXThrowExpr(const CXXThrowExpr *E);
void EmitRethrow();
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Internal Helpers // Internal Helpers

View File

@ -1,24 +0,0 @@
// RUN: %clang_cc1 -emit-llvm -o - -fexceptions -triple x86_64-apple-darwin10 %s | FileCheck %s
struct X {
X();
~X();
};
struct Y { };
// CHECK: define void @_Z1fv
void f() {
// CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVZ1fvE1x)
// CHECK: invoke void @_ZN1XC1Ev
// CHECK: call void @__cxa_guard_release(i64* @_ZGVZ1fvE1x)
// CHECK: call i32 @__cxa_atexit
// CHECK: br
static X x;
// CHECK: call void @__cxa_guard_abort(i64* @_ZGVZ1fvE1x)
// CHECK: call void @__cxa_rethrow() noreturn
// CHECK: unreachable
// CHECK: call i8* @__cxa_allocate_exception
throw Y();
}