Index: include/llvm/Analysis/EHPersonalities.h =================================================================== --- include/llvm/Analysis/EHPersonalities.h +++ include/llvm/Analysis/EHPersonalities.h @@ -25,7 +25,8 @@ MSVC_X86SEH, MSVC_Win64SEH, MSVC_CXX, - CoreCLR + CoreCLR, + Token_LP }; /// \brief See if the given exception handling personality function is one Index: lib/Analysis/EHPersonalities.cpp =================================================================== --- lib/Analysis/EHPersonalities.cpp +++ lib/Analysis/EHPersonalities.cpp @@ -29,6 +29,7 @@ .Case("__C_specific_handler", EHPersonality::MSVC_Win64SEH) .Case("__CxxFrameHandler3", EHPersonality::MSVC_CXX) .Case("ProcessCLRException", EHPersonality::CoreCLR) + .Case("ProcessTokenLandingPad",EHPersonality::Token_LP) .Default(EHPersonality::Unknown); } Index: lib/Target/X86/X86ISelLowering.cpp =================================================================== --- lib/Target/X86/X86ISelLowering.cpp +++ lib/Target/X86/X86ISelLowering.cpp @@ -17432,6 +17432,11 @@ unsigned X86TargetLowering::getExceptionPointerRegister( const Constant *PersonalityFn) const { + // LandingPad of token type currently doesn't support exception pointer + // extraction. + if (classifyEHPersonality(PersonalityFn) == EHPersonality::Token_LP) + return 0; + if (classifyEHPersonality(PersonalityFn) == EHPersonality::CoreCLR) return Subtarget->isTarget64BitLP64() ? X86::RDX : X86::EDX; @@ -17442,6 +17447,11 @@ const Constant *PersonalityFn) const { // Funclet personalities don't use selectors (the runtime does the selection). assert(!isFuncletEHPersonality(classifyEHPersonality(PersonalityFn))); + // LandingPad of token type currently doesn't support selector value + // extraction. + if (classifyEHPersonality(PersonalityFn) == EHPersonality::Token_LP) + return 0; + return Subtarget->isTarget64BitLP64() ? X86::RDX : X86::EDX; } Index: test/CodeGen/X86/token_landingpad.ll =================================================================== --- /dev/null +++ test/CodeGen/X86/token_landingpad.ll @@ -0,0 +1,22 @@ +; RUN: llc < %s | FileCheck %s + +; This test verify that SelectionDAG can handle landingPad of token type. + +define void @test() personality i32 (...)* @ProcessTokenLandingPad { +; CHECK: .cfi_personality 155, _ProcessTokenLanding +entry: + invoke void @dummy() + to label %return unwind label %unwind + +unwind: ; preds = %entry + %lp = landingpad token + cleanup + br label %return + +return: ; preds = %entry + ret void +} + +declare void @dummy() + +declare i32 @ProcessTokenLandingPad(...)