1 //===- ReduceFunctions.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 // This file implements a function which calls the Generic Delta pass in order
10 // to reduce function bodies in the provided Module.
12 //===----------------------------------------------------------------------===//
14 #include "ReduceFunctionBodies.h"
17 #include "llvm/IR/GlobalValue.h"
18 #include "llvm/IR/Instructions.h"
22 /// Removes all the bodies of defined functions that aren't inside any of the
24 static void extractFunctionBodiesFromModule(Oracle
&O
,
25 ReducerWorkItem
&WorkItem
) {
26 // Delete out-of-chunk function bodies
27 for (auto &F
: WorkItem
.getModule()) {
28 if (!F
.isDeclaration() && !hasAliasUse(F
) && !O
.shouldKeep()) {
35 void llvm::reduceFunctionBodiesDeltaPass(TestRunner
&Test
) {
36 runDeltaPass(Test
, extractFunctionBodiesFromModule
,
37 "Reducing Function Bodies");
40 static void reduceFunctionData(Oracle
&O
, ReducerWorkItem
&WorkItem
) {
41 for (Function
&F
: WorkItem
.getModule()) {
42 if (F
.hasPersonalityFn()) {
44 [](const BasicBlock
&BB
) {
45 return BB
.isEHPad() || isa
<ResumeInst
>(BB
.getTerminator());
48 F
.setPersonalityFn(nullptr);
52 if (F
.hasPrefixData() && !O
.shouldKeep())
53 F
.setPrefixData(nullptr);
55 if (F
.hasPrologueData() && !O
.shouldKeep())
56 F
.setPrologueData(nullptr);
60 void llvm::reduceFunctionDataDeltaPass(TestRunner
&Test
) {
61 runDeltaPass(Test
, reduceFunctionData
, "Reducing Function Data");