1f4a2713aSLionel Sambuc //===- BugDriver.h - Top-Level BugPoint class -------------------*- C++ -*-===//
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc //                     The LLVM Compiler Infrastructure
4f4a2713aSLionel Sambuc //
5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7f4a2713aSLionel Sambuc //
8f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9f4a2713aSLionel Sambuc //
10f4a2713aSLionel Sambuc // This class contains all of the shared state and information that is used by
11f4a2713aSLionel Sambuc // the BugPoint tool to track down errors in optimizations.  This class is the
12f4a2713aSLionel Sambuc // main driver class that invokes all sub-functionality.
13f4a2713aSLionel Sambuc //
14f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
15f4a2713aSLionel Sambuc 
16*0a6a1f1dSLionel Sambuc #ifndef LLVM_TOOLS_BUGPOINT_BUGDRIVER_H
17*0a6a1f1dSLionel Sambuc #define LLVM_TOOLS_BUGPOINT_BUGDRIVER_H
18f4a2713aSLionel Sambuc 
19*0a6a1f1dSLionel Sambuc #include "llvm/IR/ValueMap.h"
20f4a2713aSLionel Sambuc #include "llvm/Transforms/Utils/ValueMapper.h"
21*0a6a1f1dSLionel Sambuc #include <memory>
22f4a2713aSLionel Sambuc #include <string>
23f4a2713aSLionel Sambuc #include <vector>
24f4a2713aSLionel Sambuc 
25f4a2713aSLionel Sambuc namespace llvm {
26f4a2713aSLionel Sambuc 
27f4a2713aSLionel Sambuc class Value;
28f4a2713aSLionel Sambuc class PassInfo;
29f4a2713aSLionel Sambuc class Module;
30f4a2713aSLionel Sambuc class GlobalVariable;
31f4a2713aSLionel Sambuc class Function;
32f4a2713aSLionel Sambuc class BasicBlock;
33f4a2713aSLionel Sambuc class AbstractInterpreter;
34f4a2713aSLionel Sambuc class Instruction;
35f4a2713aSLionel Sambuc class LLVMContext;
36f4a2713aSLionel Sambuc 
37f4a2713aSLionel Sambuc class DebugCrashes;
38f4a2713aSLionel Sambuc 
39f4a2713aSLionel Sambuc class GCC;
40f4a2713aSLionel Sambuc 
41f4a2713aSLionel Sambuc extern bool DisableSimplifyCFG;
42f4a2713aSLionel Sambuc 
43f4a2713aSLionel Sambuc /// BugpointIsInterrupted - Set to true when the user presses ctrl-c.
44f4a2713aSLionel Sambuc ///
45f4a2713aSLionel Sambuc extern bool BugpointIsInterrupted;
46f4a2713aSLionel Sambuc 
47f4a2713aSLionel Sambuc class BugDriver {
48f4a2713aSLionel Sambuc   LLVMContext& Context;
49f4a2713aSLionel Sambuc   const char *ToolName;            // argv[0] of bugpoint
50f4a2713aSLionel Sambuc   std::string ReferenceOutputFile; // Name of `good' output file
51f4a2713aSLionel Sambuc   Module *Program;             // The raw program, linked together
52f4a2713aSLionel Sambuc   std::vector<std::string> PassesToRun;
53f4a2713aSLionel Sambuc   AbstractInterpreter *Interpreter;   // How to run the program
54f4a2713aSLionel Sambuc   AbstractInterpreter *SafeInterpreter;  // To generate reference output, etc.
55f4a2713aSLionel Sambuc   GCC *gcc;
56f4a2713aSLionel Sambuc   bool run_find_bugs;
57f4a2713aSLionel Sambuc   unsigned Timeout;
58f4a2713aSLionel Sambuc   unsigned MemoryLimit;
59f4a2713aSLionel Sambuc   bool UseValgrind;
60f4a2713aSLionel Sambuc 
61f4a2713aSLionel Sambuc   // FIXME: sort out public/private distinctions...
62f4a2713aSLionel Sambuc   friend class ReducePassList;
63f4a2713aSLionel Sambuc   friend class ReduceMisCodegenFunctions;
64f4a2713aSLionel Sambuc 
65f4a2713aSLionel Sambuc public:
66f4a2713aSLionel Sambuc   BugDriver(const char *toolname, bool find_bugs,
67f4a2713aSLionel Sambuc             unsigned timeout, unsigned memlimit, bool use_valgrind,
68f4a2713aSLionel Sambuc             LLVMContext& ctxt);
69f4a2713aSLionel Sambuc   ~BugDriver();
70f4a2713aSLionel Sambuc 
getToolName()71f4a2713aSLionel Sambuc   const char *getToolName() const { return ToolName; }
72f4a2713aSLionel Sambuc 
getContext()73f4a2713aSLionel Sambuc   LLVMContext& getContext() const { return Context; }
74f4a2713aSLionel Sambuc 
75f4a2713aSLionel Sambuc   // Set up methods... these methods are used to copy information about the
76f4a2713aSLionel Sambuc   // command line arguments into instance variables of BugDriver.
77f4a2713aSLionel Sambuc   //
78f4a2713aSLionel Sambuc   bool addSources(const std::vector<std::string> &FileNames);
addPass(std::string p)79f4a2713aSLionel Sambuc   void addPass(std::string p) { PassesToRun.push_back(p); }
setPassesToRun(const std::vector<std::string> & PTR)80f4a2713aSLionel Sambuc   void setPassesToRun(const std::vector<std::string> &PTR) {
81f4a2713aSLionel Sambuc     PassesToRun = PTR;
82f4a2713aSLionel Sambuc   }
getPassesToRun()83f4a2713aSLionel Sambuc   const std::vector<std::string> &getPassesToRun() const {
84f4a2713aSLionel Sambuc     return PassesToRun;
85f4a2713aSLionel Sambuc   }
86f4a2713aSLionel Sambuc 
87f4a2713aSLionel Sambuc   /// run - The top level method that is invoked after all of the instance
88f4a2713aSLionel Sambuc   /// variables are set up from command line arguments. The \p as_child argument
89f4a2713aSLionel Sambuc   /// indicates whether the driver is to run in parent mode or child mode.
90f4a2713aSLionel Sambuc   ///
91f4a2713aSLionel Sambuc   bool run(std::string &ErrMsg);
92f4a2713aSLionel Sambuc 
93f4a2713aSLionel Sambuc   /// debugOptimizerCrash - This method is called when some optimizer pass
94f4a2713aSLionel Sambuc   /// crashes on input.  It attempts to prune down the testcase to something
95f4a2713aSLionel Sambuc   /// reasonable, and figure out exactly which pass is crashing.
96f4a2713aSLionel Sambuc   ///
97f4a2713aSLionel Sambuc   bool debugOptimizerCrash(const std::string &ID = "passes");
98f4a2713aSLionel Sambuc 
99f4a2713aSLionel Sambuc   /// debugCodeGeneratorCrash - This method is called when the code generator
100f4a2713aSLionel Sambuc   /// crashes on an input.  It attempts to reduce the input as much as possible
101f4a2713aSLionel Sambuc   /// while still causing the code generator to crash.
102f4a2713aSLionel Sambuc   bool debugCodeGeneratorCrash(std::string &Error);
103f4a2713aSLionel Sambuc 
104f4a2713aSLionel Sambuc   /// debugMiscompilation - This method is used when the passes selected are not
105f4a2713aSLionel Sambuc   /// crashing, but the generated output is semantically different from the
106f4a2713aSLionel Sambuc   /// input.
107f4a2713aSLionel Sambuc   void debugMiscompilation(std::string *Error);
108f4a2713aSLionel Sambuc 
109f4a2713aSLionel Sambuc   /// debugPassMiscompilation - This method is called when the specified pass
110f4a2713aSLionel Sambuc   /// miscompiles Program as input.  It tries to reduce the testcase to
111f4a2713aSLionel Sambuc   /// something that smaller that still miscompiles the program.
112f4a2713aSLionel Sambuc   /// ReferenceOutput contains the filename of the file containing the output we
113f4a2713aSLionel Sambuc   /// are to match.
114f4a2713aSLionel Sambuc   ///
115f4a2713aSLionel Sambuc   bool debugPassMiscompilation(const PassInfo *ThePass,
116f4a2713aSLionel Sambuc                                const std::string &ReferenceOutput);
117f4a2713aSLionel Sambuc 
118f4a2713aSLionel Sambuc   /// compileSharedObject - This method creates a SharedObject from a given
119f4a2713aSLionel Sambuc   /// BitcodeFile for debugging a code generator.
120f4a2713aSLionel Sambuc   ///
121f4a2713aSLionel Sambuc   std::string compileSharedObject(const std::string &BitcodeFile,
122f4a2713aSLionel Sambuc                                   std::string &Error);
123f4a2713aSLionel Sambuc 
124f4a2713aSLionel Sambuc   /// debugCodeGenerator - This method narrows down a module to a function or
125f4a2713aSLionel Sambuc   /// set of functions, using the CBE as a ``safe'' code generator for other
126f4a2713aSLionel Sambuc   /// functions that are not under consideration.
127f4a2713aSLionel Sambuc   bool debugCodeGenerator(std::string *Error);
128f4a2713aSLionel Sambuc 
129f4a2713aSLionel Sambuc   /// isExecutingJIT - Returns true if bugpoint is currently testing the JIT
130f4a2713aSLionel Sambuc   ///
131f4a2713aSLionel Sambuc   bool isExecutingJIT();
132f4a2713aSLionel Sambuc 
133f4a2713aSLionel Sambuc   /// runPasses - Run all of the passes in the "PassesToRun" list, discard the
134f4a2713aSLionel Sambuc   /// output, and return true if any of the passes crashed.
runPasses(Module * M)135f4a2713aSLionel Sambuc   bool runPasses(Module *M) const {
136f4a2713aSLionel Sambuc     return runPasses(M, PassesToRun);
137f4a2713aSLionel Sambuc   }
138f4a2713aSLionel Sambuc 
getProgram()139f4a2713aSLionel Sambuc   Module *getProgram() const { return Program; }
140f4a2713aSLionel Sambuc 
141f4a2713aSLionel Sambuc   /// swapProgramIn - Set the current module to the specified module, returning
142f4a2713aSLionel Sambuc   /// the old one.
swapProgramIn(Module * M)143f4a2713aSLionel Sambuc   Module *swapProgramIn(Module *M) {
144f4a2713aSLionel Sambuc     Module *OldProgram = Program;
145f4a2713aSLionel Sambuc     Program = M;
146f4a2713aSLionel Sambuc     return OldProgram;
147f4a2713aSLionel Sambuc   }
148f4a2713aSLionel Sambuc 
switchToSafeInterpreter()149f4a2713aSLionel Sambuc   AbstractInterpreter *switchToSafeInterpreter() {
150f4a2713aSLionel Sambuc     AbstractInterpreter *Old = Interpreter;
151f4a2713aSLionel Sambuc     Interpreter = (AbstractInterpreter*)SafeInterpreter;
152f4a2713aSLionel Sambuc     return Old;
153f4a2713aSLionel Sambuc   }
154f4a2713aSLionel Sambuc 
switchToInterpreter(AbstractInterpreter * AI)155f4a2713aSLionel Sambuc   void switchToInterpreter(AbstractInterpreter *AI) {
156f4a2713aSLionel Sambuc     Interpreter = AI;
157f4a2713aSLionel Sambuc   }
158f4a2713aSLionel Sambuc 
159f4a2713aSLionel Sambuc   /// setNewProgram - If we reduce or update the program somehow, call this
160f4a2713aSLionel Sambuc   /// method to update bugdriver with it.  This deletes the old module and sets
161f4a2713aSLionel Sambuc   /// the specified one as the current program.
162f4a2713aSLionel Sambuc   void setNewProgram(Module *M);
163f4a2713aSLionel Sambuc 
164f4a2713aSLionel Sambuc   /// compileProgram - Try to compile the specified module, returning false and
165f4a2713aSLionel Sambuc   /// setting Error if an error occurs.  This is used for code generation
166f4a2713aSLionel Sambuc   /// crash testing.
167f4a2713aSLionel Sambuc   ///
168f4a2713aSLionel Sambuc   void compileProgram(Module *M, std::string *Error) const;
169f4a2713aSLionel Sambuc 
170f4a2713aSLionel Sambuc   /// executeProgram - This method runs "Program", capturing the output of the
171f4a2713aSLionel Sambuc   /// program to a file.  A recommended filename may be optionally specified.
172f4a2713aSLionel Sambuc   ///
173f4a2713aSLionel Sambuc   std::string executeProgram(const Module *Program,
174f4a2713aSLionel Sambuc                              std::string OutputFilename,
175f4a2713aSLionel Sambuc                              std::string Bitcode,
176f4a2713aSLionel Sambuc                              const std::string &SharedObjects,
177f4a2713aSLionel Sambuc                              AbstractInterpreter *AI,
178f4a2713aSLionel Sambuc                              std::string *Error) const;
179f4a2713aSLionel Sambuc 
180f4a2713aSLionel Sambuc   /// executeProgramSafely - Used to create reference output with the "safe"
181f4a2713aSLionel Sambuc   /// backend, if reference output is not provided.  If there is a problem with
182f4a2713aSLionel Sambuc   /// the code generator (e.g., llc crashes), this will return false and set
183f4a2713aSLionel Sambuc   /// Error.
184f4a2713aSLionel Sambuc   ///
185f4a2713aSLionel Sambuc   std::string executeProgramSafely(const Module *Program,
186f4a2713aSLionel Sambuc                                    std::string OutputFile,
187f4a2713aSLionel Sambuc                                    std::string *Error) const;
188f4a2713aSLionel Sambuc 
189f4a2713aSLionel Sambuc   /// createReferenceFile - calls compileProgram and then records the output
190f4a2713aSLionel Sambuc   /// into ReferenceOutputFile. Returns true if reference file created, false
191f4a2713aSLionel Sambuc   /// otherwise. Note: initializeExecutionEnvironment should be called BEFORE
192f4a2713aSLionel Sambuc   /// this function.
193f4a2713aSLionel Sambuc   ///
194f4a2713aSLionel Sambuc   bool createReferenceFile(Module *M, const std::string &Filename
195f4a2713aSLionel Sambuc                                             = "bugpoint.reference.out-%%%%%%%");
196f4a2713aSLionel Sambuc 
197f4a2713aSLionel Sambuc   /// diffProgram - This method executes the specified module and diffs the
198f4a2713aSLionel Sambuc   /// output against the file specified by ReferenceOutputFile.  If the output
199f4a2713aSLionel Sambuc   /// is different, 1 is returned.  If there is a problem with the code
200f4a2713aSLionel Sambuc   /// generator (e.g., llc crashes), this will return -1 and set Error.
201f4a2713aSLionel Sambuc   ///
202f4a2713aSLionel Sambuc   bool diffProgram(const Module *Program,
203f4a2713aSLionel Sambuc                    const std::string &BitcodeFile = "",
204f4a2713aSLionel Sambuc                    const std::string &SharedObj = "",
205f4a2713aSLionel Sambuc                    bool RemoveBitcode = false,
206*0a6a1f1dSLionel Sambuc                    std::string *Error = nullptr) const;
207f4a2713aSLionel Sambuc 
208f4a2713aSLionel Sambuc   /// EmitProgressBitcode - This function is used to output M to a file named
209f4a2713aSLionel Sambuc   /// "bugpoint-ID.bc".
210f4a2713aSLionel Sambuc   ///
211f4a2713aSLionel Sambuc   void EmitProgressBitcode(const Module *M, const std::string &ID,
212f4a2713aSLionel Sambuc                            bool NoFlyer = false) const;
213f4a2713aSLionel Sambuc 
214*0a6a1f1dSLionel Sambuc   /// This method clones the current Program and deletes the specified
215*0a6a1f1dSLionel Sambuc   /// instruction from the cloned module.  It then runs a series of cleanup
216*0a6a1f1dSLionel Sambuc   /// passes (ADCE and SimplifyCFG) to eliminate any code which depends on the
217*0a6a1f1dSLionel Sambuc   /// value. The modified module is then returned.
218f4a2713aSLionel Sambuc   ///
219*0a6a1f1dSLionel Sambuc   std::unique_ptr<Module> deleteInstructionFromProgram(const Instruction *I,
220*0a6a1f1dSLionel Sambuc                                                        unsigned Simp);
221f4a2713aSLionel Sambuc 
222*0a6a1f1dSLionel Sambuc   /// This method clones the current Program and performs a series of cleanups
223*0a6a1f1dSLionel Sambuc   /// intended to get rid of extra cruft on the module. If the
224*0a6a1f1dSLionel Sambuc   /// MayModifySemantics argument is true, then the cleanups is allowed to
225f4a2713aSLionel Sambuc   /// modify how the code behaves.
226f4a2713aSLionel Sambuc   ///
227*0a6a1f1dSLionel Sambuc   std::unique_ptr<Module> performFinalCleanups(Module *M,
228*0a6a1f1dSLionel Sambuc                                                bool MayModifySemantics = false);
229f4a2713aSLionel Sambuc 
230*0a6a1f1dSLionel Sambuc   /// Given a module, extract up to one loop from it into a new function. This
231*0a6a1f1dSLionel Sambuc   /// returns null if there are no extractable loops in the program or if the
232*0a6a1f1dSLionel Sambuc   /// loop extractor crashes.
233*0a6a1f1dSLionel Sambuc   std::unique_ptr<Module> extractLoop(Module *M);
234f4a2713aSLionel Sambuc 
235*0a6a1f1dSLionel Sambuc   /// Extract all but the specified basic blocks into their own functions. The
236*0a6a1f1dSLionel Sambuc   /// only detail is that M is actually a module cloned from the one the BBs are
237*0a6a1f1dSLionel Sambuc   /// in, so some mapping needs to be performed. If this operation fails for
238*0a6a1f1dSLionel Sambuc   /// some reason (ie the implementation is buggy), this function should return
239*0a6a1f1dSLionel Sambuc   /// null, otherwise it returns a new Module.
240*0a6a1f1dSLionel Sambuc   std::unique_ptr<Module>
241*0a6a1f1dSLionel Sambuc   extractMappedBlocksFromModule(const std::vector<BasicBlock *> &BBs,
242f4a2713aSLionel Sambuc                                 Module *M);
243f4a2713aSLionel Sambuc 
244*0a6a1f1dSLionel Sambuc   /// Carefully run the specified set of pass on the specified/ module,
245*0a6a1f1dSLionel Sambuc   /// returning the transformed module on success, or a null pointer on failure.
246*0a6a1f1dSLionel Sambuc   /// If AutoDebugCrashes is set to true, then bugpoint will automatically
247*0a6a1f1dSLionel Sambuc   /// attempt to track down a crashing pass if one exists, and this method will
248*0a6a1f1dSLionel Sambuc   /// never return null.
249*0a6a1f1dSLionel Sambuc   std::unique_ptr<Module> runPassesOn(Module *M,
250*0a6a1f1dSLionel Sambuc                                       const std::vector<std::string> &Passes,
251*0a6a1f1dSLionel Sambuc                                       bool AutoDebugCrashes = false,
252*0a6a1f1dSLionel Sambuc                                       unsigned NumExtraArgs = 0,
253*0a6a1f1dSLionel Sambuc                                       const char *const *ExtraArgs = nullptr);
254f4a2713aSLionel Sambuc 
255f4a2713aSLionel Sambuc   /// runPasses - Run the specified passes on Program, outputting a bitcode
256f4a2713aSLionel Sambuc   /// file and writting the filename into OutputFile if successful.  If the
257f4a2713aSLionel Sambuc   /// optimizations fail for some reason (optimizer crashes), return true,
258f4a2713aSLionel Sambuc   /// otherwise return false.  If DeleteOutput is set to true, the bitcode is
259f4a2713aSLionel Sambuc   /// deleted on success, and the filename string is undefined.  This prints to
260f4a2713aSLionel Sambuc   /// outs() a single line message indicating whether compilation was successful
261f4a2713aSLionel Sambuc   /// or failed, unless Quiet is set.  ExtraArgs specifies additional arguments
262f4a2713aSLionel Sambuc   /// to pass to the child bugpoint instance.
263f4a2713aSLionel Sambuc   ///
264f4a2713aSLionel Sambuc   bool runPasses(Module *Program,
265f4a2713aSLionel Sambuc                  const std::vector<std::string> &PassesToRun,
266f4a2713aSLionel Sambuc                  std::string &OutputFilename, bool DeleteOutput = false,
267f4a2713aSLionel Sambuc                  bool Quiet = false, unsigned NumExtraArgs = 0,
268*0a6a1f1dSLionel Sambuc                  const char * const *ExtraArgs = nullptr) const;
269f4a2713aSLionel Sambuc 
270f4a2713aSLionel Sambuc   /// runManyPasses - Take the specified pass list and create different
271f4a2713aSLionel Sambuc   /// combinations of passes to compile the program with. Compile the program with
272f4a2713aSLionel Sambuc   /// each set and mark test to see if it compiled correctly. If the passes
273f4a2713aSLionel Sambuc   /// compiled correctly output nothing and rearrange the passes into a new order.
274f4a2713aSLionel Sambuc   /// If the passes did not compile correctly, output the command required to
275f4a2713aSLionel Sambuc   /// recreate the failure. This returns true if a compiler error is found.
276f4a2713aSLionel Sambuc   ///
277f4a2713aSLionel Sambuc   bool runManyPasses(const std::vector<std::string> &AllPasses,
278f4a2713aSLionel Sambuc                      std::string &ErrMsg);
279f4a2713aSLionel Sambuc 
280f4a2713aSLionel Sambuc   /// writeProgramToFile - This writes the current "Program" to the named
281f4a2713aSLionel Sambuc   /// bitcode file.  If an error occurs, true is returned.
282f4a2713aSLionel Sambuc   ///
283f4a2713aSLionel Sambuc   bool writeProgramToFile(const std::string &Filename, const Module *M) const;
284f4a2713aSLionel Sambuc   bool writeProgramToFile(const std::string &Filename, int FD,
285f4a2713aSLionel Sambuc                           const Module *M) const;
286f4a2713aSLionel Sambuc 
287f4a2713aSLionel Sambuc private:
288f4a2713aSLionel Sambuc   /// runPasses - Just like the method above, but this just returns true or
289f4a2713aSLionel Sambuc   /// false indicating whether or not the optimizer crashed on the specified
290f4a2713aSLionel Sambuc   /// input (true = crashed).
291f4a2713aSLionel Sambuc   ///
292f4a2713aSLionel Sambuc   bool runPasses(Module *M,
293f4a2713aSLionel Sambuc                  const std::vector<std::string> &PassesToRun,
294f4a2713aSLionel Sambuc                  bool DeleteOutput = true) const {
295f4a2713aSLionel Sambuc     std::string Filename;
296f4a2713aSLionel Sambuc     return runPasses(M, PassesToRun, Filename, DeleteOutput);
297f4a2713aSLionel Sambuc   }
298f4a2713aSLionel Sambuc 
299f4a2713aSLionel Sambuc   /// initializeExecutionEnvironment - This method is used to set up the
300f4a2713aSLionel Sambuc   /// environment for executing LLVM programs.
301f4a2713aSLionel Sambuc   ///
302f4a2713aSLionel Sambuc   bool initializeExecutionEnvironment();
303f4a2713aSLionel Sambuc };
304f4a2713aSLionel Sambuc 
305*0a6a1f1dSLionel Sambuc ///  Given a bitcode or assembly input filename, parse and return it, or return
306*0a6a1f1dSLionel Sambuc ///  null if not possible.
307f4a2713aSLionel Sambuc ///
308*0a6a1f1dSLionel Sambuc std::unique_ptr<Module> parseInputFile(StringRef InputFilename,
309f4a2713aSLionel Sambuc                                        LLVMContext &ctxt);
310f4a2713aSLionel Sambuc 
311f4a2713aSLionel Sambuc /// getPassesString - Turn a list of passes into a string which indicates the
312f4a2713aSLionel Sambuc /// command line options that must be passed to add the passes.
313f4a2713aSLionel Sambuc ///
314f4a2713aSLionel Sambuc std::string getPassesString(const std::vector<std::string> &Passes);
315f4a2713aSLionel Sambuc 
316f4a2713aSLionel Sambuc /// PrintFunctionList - prints out list of problematic functions
317f4a2713aSLionel Sambuc ///
318f4a2713aSLionel Sambuc void PrintFunctionList(const std::vector<Function*> &Funcs);
319f4a2713aSLionel Sambuc 
320f4a2713aSLionel Sambuc /// PrintGlobalVariableList - prints out list of problematic global variables
321f4a2713aSLionel Sambuc ///
322f4a2713aSLionel Sambuc void PrintGlobalVariableList(const std::vector<GlobalVariable*> &GVs);
323f4a2713aSLionel Sambuc 
324f4a2713aSLionel Sambuc // DeleteFunctionBody - "Remove" the function by deleting all of it's basic
325f4a2713aSLionel Sambuc // blocks, making it external.
326f4a2713aSLionel Sambuc //
327f4a2713aSLionel Sambuc void DeleteFunctionBody(Function *F);
328f4a2713aSLionel Sambuc 
329f4a2713aSLionel Sambuc /// SplitFunctionsOutOfModule - Given a module and a list of functions in the
330f4a2713aSLionel Sambuc /// module, split the functions OUT of the specified module, and place them in
331f4a2713aSLionel Sambuc /// the new module.
332f4a2713aSLionel Sambuc Module *SplitFunctionsOutOfModule(Module *M, const std::vector<Function*> &F,
333f4a2713aSLionel Sambuc                                   ValueToValueMapTy &VMap);
334f4a2713aSLionel Sambuc 
335f4a2713aSLionel Sambuc } // End llvm namespace
336f4a2713aSLionel Sambuc 
337f4a2713aSLionel Sambuc #endif
338