From 3a1fd170271da25e7ce9b0a329adf47483378229 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sat, 29 Jan 2022 16:08:06 +0000 Subject: [PATCH] [WebAssembly] Use cast<> instead of dyn_cast<> to avoid dereference of nullptr The pointers are dereferenced immediately, so assert the cast is correct instead of returning nullptr --- llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp index 8a63c7c..b6c43be 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyLowerEmscriptenEHSjLj.cpp @@ -875,7 +875,7 @@ static void nullifySetjmp(Function *F) { SmallVector ToErase; for (User *U : make_early_inc_range(SetjmpF->users())) { - auto *CB = dyn_cast(U); + auto *CB = cast(U); BasicBlock *BB = CB->getParent(); if (BB->getParent() != F) // in other function continue; @@ -1320,7 +1320,7 @@ bool WebAssemblyLowerEmscriptenEHSjLj::runSjLjOnFunction(Function &F) { SmallVector SetjmpRetPHIs; Function *SetjmpF = M.getFunction("setjmp"); for (auto *U : make_early_inc_range(SetjmpF->users())) { - auto *CB = dyn_cast(U); + auto *CB = cast(U); BasicBlock *BB = CB->getParent(); if (BB->getParent() != &F) // in other function continue; -- 2.7.4