Debian Codegraph @

llvm-project/llvm/tools/llvm-reduce/deltas/ReduceInvokes.cpp

raw
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-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // Try to replace invokes with calls.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "ReduceInvokes.h"
14 #include "Delta.h"
15 #include "llvm/IR/Instructions.h"
16 #include "llvm/Transforms/Utils/Local.h"
17
18 using namespace llvm;
19
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())
24 changeToCall(Invoke);
25 }
26
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
29 // reduction.
30 }
31
32 static void reduceInvokesInModule(Oracle &O, ReducerWorkItem &WorkItem) {
33 for (Function &F : WorkItem.getModule()) {
34 if (F.hasPersonalityFn())
35 reduceInvokesInFunction(O, F);
36 }
37 }
38
39 void llvm::reduceInvokesDeltaPass(TestRunner &Test) {
40 runDeltaPass(Test, reduceInvokesInModule, "Reducing Invokes");
41 }