|
23 | 23 |
|
24 | 24 | using namespace llvm; |
25 | 25 |
|
| 26 | +static bool callingConvRequiresArgument(const Function &F, |
| 27 | + const Argument &Arg) { |
| 28 | + switch (F.getCallingConv()) { |
| 29 | + case CallingConv::X86_INTR: |
| 30 | + // If there are any arguments, the first one must by byval. |
| 31 | + return Arg.getArgNo() == 0 && F.arg_size() != 1; |
| 32 | + default: |
| 33 | + return false; |
| 34 | + } |
| 35 | + |
| 36 | + llvm_unreachable("covered calling conv switch"); |
| 37 | +} |
| 38 | + |
26 | 39 | /// Goes over OldF calls and replaces them with a call to NewF |
27 | 40 | static void replaceFunctionCalls(Function &OldF, Function &NewF, |
28 | 41 | const std::set<int> &ArgIndexesToKeep) { |
@@ -60,14 +73,18 @@ static void extractArgumentsFromModule(Oracle &O, ReducerWorkItem &WorkItem) { |
60 | 73 | Module &Program = WorkItem.getModule(); |
61 | 74 | std::vector<Argument *> InitArgsToKeep; |
62 | 75 | std::vector<Function *> Funcs; |
| 76 | + |
63 | 77 | // Get inside-chunk arguments, as well as their parent function |
64 | | - for (auto &F : Program) |
65 | | - if (shouldRemoveArguments(F)) { |
66 | | - Funcs.push_back(&F); |
67 | | - for (auto &A : F.args()) |
68 | | - if (O.shouldKeep()) |
69 | | - InitArgsToKeep.push_back(&A); |
| 78 | + for (auto &F : Program) { |
| 79 | + if (!shouldRemoveArguments(F)) |
| 80 | + continue; |
| 81 | + |
| 82 | + Funcs.push_back(&F); |
| 83 | + for (auto &A : F.args()) { |
| 84 | + if (callingConvRequiresArgument(F, A) || O.shouldKeep()) |
| 85 | + InitArgsToKeep.push_back(&A); |
70 | 86 | } |
| 87 | + } |
71 | 88 |
|
72 | 89 | // We create a vector first, then convert it to a set, so that we don't have |
73 | 90 | // to pay the cost of rebalancing the set frequently if the order we insert |
|
0 commit comments