1 //===- ReduceInvokes.cpp - Specialized Delta Pass -------------------------===//
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-exception
7 //===----------------------------------------------------------------------===//
9 // Try to replace invokes with calls.
11 //===----------------------------------------------------------------------===//
13 #include "ReduceInvokes.h"
15 #include "llvm/IR/Instructions.h"
16 #include "llvm/Transforms/Utils/Local.h"
20 static void reduceInvokesInFunction(Oracle
&O
, Function
&F
) {
21 for (BasicBlock
&BB
: F
) {
22 InvokeInst
*Invoke
= dyn_cast
<InvokeInst
>(BB
.getTerminator());
23 if (Invoke
&& !O
.shouldKeep())
27 // TODO: We most likely are leaving behind dead landingpad blocks. Should we
28 // delete unreachable blocks now, or leave that for the unreachable block
32 static void reduceInvokesInModule(Oracle
&O
, ReducerWorkItem
&WorkItem
) {
33 for (Function
&F
: WorkItem
.getModule()) {
34 if (F
.hasPersonalityFn())
35 reduceInvokesInFunction(O
, F
);
39 void llvm::reduceInvokesDeltaPass(TestRunner
&Test
) {
40 runDeltaPass(Test
, reduceInvokesInModule
, "Reducing Invokes");