diff options
author | Reid Kleckner <rnk@google.com> | 2015-10-07 21:03:41 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2015-10-07 21:03:41 +0000 |
commit | 1f88e93973024e8e59611553ad63fc913f6699e4 (patch) | |
tree | f7142c0d9a6a146fa08ddb2e88836a20ece8d738 | |
parent | 4462c6190e7164009bce6d6f0d2f37f14a41eabd (diff) | |
download | bcm5719-llvm-1f88e93973024e8e59611553ad63fc913f6699e4.tar.gz bcm5719-llvm-1f88e93973024e8e59611553ad63fc913f6699e4.zip |
[WinEH] Don't use lifetime markers for MS catch parameters
We don't have a good place to put them. Our previous spot was causing us
to optimize loads from the exception object to undef, because it was
after the catchpad instruction that models the write to the catch
object.
llvm-svn: 249616
-rw-r--r-- | clang/lib/CodeGen/CGDecl.cpp | 8 | ||||
-rw-r--r-- | clang/test/CodeGenCXX/microsoft-abi-eh-catch.cpp | 12 |
2 files changed, 18 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp index 07684f91449..3cff635f94e 100644 --- a/clang/lib/CodeGen/CGDecl.cpp +++ b/clang/lib/CodeGen/CGDecl.cpp @@ -974,9 +974,15 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) { address = CreateTempAlloca(allocaTy, allocaAlignment); address.getPointer()->setName(D.getName()); + // Don't emit lifetime markers for MSVC catch parameters. The lifetime of + // the catch parameter starts in the catchpad instruction, and we can't + // insert code in those basic blocks. + bool IsMSCatchParam = + D.isExceptionVariable() && getTarget().getCXXABI().isMicrosoft(); + // Emit a lifetime intrinsic if meaningful. There's no point // in doing this if we don't have a valid insertion point (?). - if (HaveInsertPoint()) { + if (HaveInsertPoint() && !IsMSCatchParam) { uint64_t size = CGM.getDataLayout().getTypeAllocSize(allocaTy); emission.SizeForLifetimeMarkers = EmitLifetimeStart(size, address.getPointer()); diff --git a/clang/test/CodeGenCXX/microsoft-abi-eh-catch.cpp b/clang/test/CodeGenCXX/microsoft-abi-eh-catch.cpp index d14edf8986b..e742f8b1c4a 100644 --- a/clang/test/CodeGenCXX/microsoft-abi-eh-catch.cpp +++ b/clang/test/CodeGenCXX/microsoft-abi-eh-catch.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - -triple=x86_64-pc-windows-msvc \ // RUN: -mconstructor-aliases -fexceptions -fcxx-exceptions -fnew-ms-eh \ +// RUN: -O1 -disable-llvm-optzns \ // RUN: | FileCheck -check-prefix WIN64 %s extern "C" void might_throw(); @@ -47,8 +48,17 @@ extern "C" void catch_int() { // WIN64-LABEL: define void @catch_int() // WIN64: catchpad [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i32* %[[e_addr:[^\]]*]]] +// +// The catchpad instruction starts the lifetime of 'e'. Unfortunately, that +// leaves us with nowhere to put lifetime.start, so we don't emit lifetime +// markers for now. +// WIN64-NOT: lifetime.start +// // WIN64: %[[e_i8:[^ ]*]] = bitcast i32* %[[e_addr]] to i8* -// WIN64: call void @handle_exception(i8* %[[e_i8]]) +// WIN64-NOT: lifetime.start +// WIN64: call void @handle_exception +// WIN64-SAME: (i8* %[[e_i8]]) +// WIN64-NOT: lifetime.end // WIN64: catchret extern "C" void catch_int_unnamed() { |