From 339591e0a94b45f469405191d99115ebbd98524a Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Fri, 23 Jan 2015 23:51:25 +0000 Subject: [PATCH] Fix assertion when C++ EH filters are present in functions using SEH Should fix PR22305. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226969 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/Win64Exception.cpp | 4 ++-- test/CodeGen/X86/seh-filter.ll | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 test/CodeGen/X86/seh-filter.ll diff --git a/lib/CodeGen/AsmPrinter/Win64Exception.cpp b/lib/CodeGen/AsmPrinter/Win64Exception.cpp index a1719a51889..ff12d5d3247 100644 --- a/lib/CodeGen/AsmPrinter/Win64Exception.cpp +++ b/lib/CodeGen/AsmPrinter/Win64Exception.cpp @@ -221,12 +221,11 @@ void Win64Exception::emitCSpecificHandlerTable() { // Do a parallel iteration across typeids and clause labels, skipping filter // clauses. - assert(LPad->TypeIds.size() == LPad->ClauseLabels.size()); + size_t NextClauseLabel = 0; for (size_t I = 0, E = LPad->TypeIds.size(); I < E; ++I) { // AddLandingPadInfo stores the clauses in reverse, but there is a FIXME // to change that. int Selector = LPad->TypeIds[E - I - 1]; - MCSymbol *ClauseLabel = LPad->ClauseLabels[I]; // Ignore C++ filter clauses in SEH. // FIXME: Implement cleanup clauses. @@ -243,6 +242,7 @@ void Win64Exception::emitCSpecificHandlerTable() { else // Otherwise, this is a "catch i8* null", or catch all. Asm->OutStreamer.EmitIntValue(1, 4); } + MCSymbol *ClauseLabel = LPad->ClauseLabels[NextClauseLabel++]; Asm->OutStreamer.EmitValue(createImageRel32(ClauseLabel), 4); } } diff --git a/test/CodeGen/X86/seh-filter.ll b/test/CodeGen/X86/seh-filter.ll new file mode 100644 index 00000000000..6a3a23edb1a --- /dev/null +++ b/test/CodeGen/X86/seh-filter.ll @@ -0,0 +1,21 @@ +; RUN: llc -O0 -mtriple=x86_64-windows-msvc < %s | FileCheck %s + +declare void @g() +define void @f() { + invoke void @g() to label %return unwind label %lpad + +return: + ret void + +lpad: + %ehptrs = landingpad {i8*, i32} personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) + filter [0 x i8*] zeroinitializer + call void @__cxa_call_unexpected(i8* null) + unreachable +} +declare i32 @__C_specific_handler(...) +declare void @__cxa_call_unexpected(i8*) + +; We don't emit entries for filters. +; CHECK: .seh_handlerdata +; CHECK: .long 0 -- 2.34.1