37 lines · cpp
1//===- ReduceInvokes.cpp - Specialized Delta Pass -------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8//9// Try to replace invokes with calls.10//11//===----------------------------------------------------------------------===//12 13#include "ReduceInvokes.h"14#include "llvm/IR/Instructions.h"15#include "llvm/Transforms/Utils/Local.h"16 17using namespace llvm;18 19static void reduceInvokesInFunction(Oracle &O, Function &F) {20 for (BasicBlock &BB : F) {21 InvokeInst *Invoke = dyn_cast<InvokeInst>(BB.getTerminator());22 if (Invoke && !O.shouldKeep())23 changeToCall(Invoke);24 }25 26 // TODO: We most likely are leaving behind dead landingpad blocks. Should we27 // delete unreachable blocks now, or leave that for the unreachable block28 // reduction.29}30 31void llvm::reduceInvokesDeltaPass(Oracle &O, ReducerWorkItem &WorkItem) {32 for (Function &F : WorkItem.getModule()) {33 if (F.hasPersonalityFn())34 reduceInvokesInFunction(O, F);35 }36}37