Index: llvm/lib/Transforms/Scalar/Reg2Mem.cpp =================================================================== --- llvm/lib/Transforms/Scalar/Reg2Mem.cpp +++ llvm/lib/Transforms/Scalar/Reg2Mem.cpp @@ -40,6 +40,9 @@ STATISTIC(NumPhisDemoted, "Number of phi-nodes demoted"); static bool valueEscapes(const Instruction &Inst) { + if(Inst.getType()->isTokenTy()){ + return false; + } const BasicBlock *BB = Inst.getParent(); for (const User *U : Inst.users()) { const Instruction *UI = cast(U); Index: llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll =================================================================== --- /dev/null +++ llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll @@ -0,0 +1,33 @@ +; RUN: opt -passes=reg2mem -disable-output < %s + +; ModuleID = 'bugpoint-reduced-simplified.bc' +source_filename = "Test.cpp" +target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc19.29.30140" + +declare dso_local void @"?read_mem@@YAXPEAD0_K@Z"() local_unnamed_addr #0 + +define dso_local void @"?memcpy_seh@@YA_NPEAX_KPEBX1@Z"() local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) { +entry: + invoke void @"?read_mem@@YAXPEAD0_K@Z"() #1 + to label %cleanup unwind label %catch.dispatch + +catch.dispatch: ; preds = %entry + %0 = catchswitch within none [label %__except] unwind to caller + +__except: ; preds = %catch.dispatch + %1 = catchpad within %0 [i8* null] + unreachable + +cleanup: ; preds = %entry + ret void +} + +declare dso_local i32 @__C_specific_handler(...) + +attributes #0 = { "tune-cpu"="generic" } +attributes #1 = { noinline } + +!llvm.ident = !{!0} + +!0 = !{!"clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)"} \ No newline at end of file