From ff03f23be8bc6df701efd9e1093779fbcf382d87 Mon Sep 17 00:00:00 2001 From: Congcong Cai Date: Sat, 27 Apr 2024 22:11:47 +0800 Subject: [WebAssembly] remove instruction after builtin trap (#90207) `llvm.trap` will be convert as `unreachable` which is terminator. Instruction after terminator will cause validation failed. This PR introduces a pass to clean instruction after terminator. Fixes: #68770. --- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp') diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index cdd39eeb6bbb..de342e896573 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -512,6 +512,10 @@ bool WebAssemblyPassConfig::addInstSelector() { // Eliminate range checks and add default targets to br_table instructions. addPass(createWebAssemblyFixBrTableDefaults()); + // unreachable is terminator, non-terminator instruction after it is not + // allowed. + addPass(createWebAssemblyCleanCodeAfterTrap()); + return false; } -- cgit v1.2.3