From 3ad4bc1445427520e4c7a2d43f78594adb85a3bb Mon Sep 17 00:00:00 2001 From: Andrew Kaylor Date: Thu, 23 Apr 2015 22:38:36 +0000 Subject: [PATCH] [WinEH] Ignore filter clauses while mapping landing pad blocks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235656 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/WinEHPrepare.cpp | 6 ++++++ test/CodeGen/X86/seh-filter.ll | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 test/CodeGen/X86/seh-filter.ll diff --git a/lib/CodeGen/WinEHPrepare.cpp b/lib/CodeGen/WinEHPrepare.cpp index a1da1aefd8f..b1eea7dbb07 100644 --- a/lib/CodeGen/WinEHPrepare.cpp +++ b/lib/CodeGen/WinEHPrepare.cpp @@ -1666,6 +1666,12 @@ void WinEHPrepare::mapLandingPadBlocks(LandingPadInst *LPad, while (HandlersFound != NumClauses) { BasicBlock *NextBB = nullptr; + // Skip over filter clauses. + if (LPad->isFilter(HandlersFound)) { + ++HandlersFound; + continue; + } + // See if the clause we're looking for is a catch-all. // If so, the catch begins immediately. Constant *ExpectedSelector = LPad->getClause(HandlersFound)->stripPointerCasts(); 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