//===-- WebAssemblyCleanCodeAfterTrap.cpp - Clean Code After Trap ---------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// /// \file /// This file remove instruction after trap. /// ``llvm.trap`` will be convert as ``unreachable`` which is terminator. /// Instruction after terminator will cause validation failed. /// //===----------------------------------------------------------------------===// #include "WebAssembly.h" #include "WebAssemblyUtilities.h" #include "llvm/ADT/SmallVector.h" #include "llvm/CodeGen/MachineBlockFrequencyInfo.h" #include "llvm/CodeGen/Passes.h" #include "llvm/MC/MCInstrDesc.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; #define DEBUG_TYPE … namespace { class WebAssemblyCleanCodeAfterTrap final : public MachineFunctionPass { … }; } // end anonymous namespace char WebAssemblyCleanCodeAfterTrap::ID = …; INITIALIZE_PASS(…) FunctionPass *llvm::createWebAssemblyCleanCodeAfterTrap() { … } bool WebAssemblyCleanCodeAfterTrap::runOnMachineFunction(MachineFunction &MF) { … }