7
7
// ===----------------------------------------------------------------------===//
8
8
//
9
9
// This file implements a function which calls the Generic Delta pass in order
10
- // to reduce uninteresting Arguments from defined functions.
10
+ // to reduce uninteresting Arguments from declared and defined functions.
11
11
//
12
12
// ===----------------------------------------------------------------------===//
13
13
14
14
#include " ReduceArguments.h"
15
15
#include " Delta.h"
16
16
#include " llvm/ADT/SmallVector.h"
17
+ #include " llvm/IR/Intrinsics.h"
17
18
#include < set>
18
19
#include < vector>
19
20
@@ -38,6 +39,14 @@ static void replaceFunctionCalls(Function &OldF, Function &NewF,
38
39
}
39
40
}
40
41
42
+ // / Returns whether or not this function should be considered a candidate for
43
+ // / argument removal. Currently, functions with no arguments and intrinsics are
44
+ // / not considered. Intrinsics aren't considered because their signatures are
45
+ // / fixed.
46
+ static bool shouldRemoveArguments (const Function &F) {
47
+ return !F.arg_empty () && !F.isIntrinsic ();
48
+ }
49
+
41
50
// / Removes out-of-chunk arguments from functions, and modifies their calls
42
51
// / accordingly. It also removes allocations of out-of-chunk arguments.
43
52
static void extractArgumentsFromModule (std::vector<Chunk> ChunksToKeep,
@@ -48,7 +57,7 @@ static void extractArgumentsFromModule(std::vector<Chunk> ChunksToKeep,
48
57
std::vector<Function *> Funcs;
49
58
// Get inside-chunk arguments, as well as their parent function
50
59
for (auto &F : *Program)
51
- if (!F. arg_empty ( )) {
60
+ if (shouldRemoveArguments (F )) {
52
61
Funcs.push_back (&F);
53
62
for (auto &A : F.args ())
54
63
if (O.shouldKeep ())
@@ -100,15 +109,15 @@ static void extractArgumentsFromModule(std::vector<Chunk> ChunksToKeep,
100
109
}
101
110
}
102
111
103
- // / Counts the amount of arguments in non-declaration functions and prints their
104
- // / respective name, index, and parent function name
112
+ // / Counts the amount of arguments in functions and prints their respective
113
+ // / name, index, and parent function name
105
114
static int countArguments (Module *Program) {
106
115
// TODO: Silence index with --quiet flag
107
116
outs () << " ----------------------------\n " ;
108
117
outs () << " Param Index Reference:\n " ;
109
118
int ArgsCount = 0 ;
110
119
for (auto &F : *Program)
111
- if (!F. arg_empty ( )) {
120
+ if (shouldRemoveArguments (F )) {
112
121
outs () << " " << F.getName () << " \n " ;
113
122
for (auto &A : F.args ())
114
123
outs () << " \t " << ++ArgsCount << " : " << A.getName () << " \n " ;
0 commit comments