xref: /netbsd-src/external/apache2/llvm/dist/llvm/tools/llvm-reduce/deltas/ReduceModuleInlineAsm.cpp (revision 82d56013d7b633d116a93943de88e08335357a7c)
1 //===- ReduceModuleInlineAsm.cpp ------------------------------------------===//
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 // This file implements a function which calls the Generic Delta pass to reduce
10 // module inline asm.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "ReduceModuleInlineAsm.h"
15 #include "llvm/IR/Constants.h"
16 #include "llvm/IR/GlobalValue.h"
17 
18 using namespace llvm;
19 
clearModuleInlineAsm(std::vector<Chunk> ChunksToKeep,Module * Program)20 static void clearModuleInlineAsm(std::vector<Chunk> ChunksToKeep,
21                                  Module *Program) {
22   Oracle O(ChunksToKeep);
23 
24   // TODO: clear line by line rather than all at once
25   if (!O.shouldKeep())
26     Program->setModuleInlineAsm("");
27 }
28 
reduceModuleInlineAsmDeltaPass(TestRunner & Test)29 void llvm::reduceModuleInlineAsmDeltaPass(TestRunner &Test) {
30   outs() << "*** Reducing Module Inline Asm...\n";
31   runDeltaPass(Test, 1, clearModuleInlineAsm);
32 }
33