//===- LowerInvoke.cpp - Eliminate Invoke instructions --------------------===// // // 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 // //===----------------------------------------------------------------------===// // // This transformation is designed for use by code generators which do not yet // support stack unwinding. This pass converts 'invoke' instructions to 'call' // instructions, so that any exception-handling 'landingpad' blocks become dead // code (which can be removed by running the '-simplifycfg' pass afterwards). // //===----------------------------------------------------------------------===// #include "llvm/Transforms/Utils/LowerInvoke.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" #include "llvm/IR/Instructions.h" #include "llvm/InitializePasses.h" #include "llvm/Pass.h" #include "llvm/Transforms/Utils.h" usingnamespacellvm; #define DEBUG_TYPE … STATISTIC(NumInvokes, "Number of invokes replaced"); namespace { class LowerInvokeLegacyPass : public FunctionPass { … }; } char LowerInvokeLegacyPass::ID = …; INITIALIZE_PASS(…) static bool runImpl(Function &F) { … } bool LowerInvokeLegacyPass::runOnFunction(Function &F) { … } namespace llvm { char &LowerInvokePassID = …; // Public Interface To the LowerInvoke pass. FunctionPass *createLowerInvokePass() { … } PreservedAnalyses LowerInvokePass::run(Function &F, FunctionAnalysisManager &AM) { … } }