Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 1 | //===- BugDriver.cpp - Top-Level BugPoint class implementation ------------===// |
Misha Brukman | 650ba8e | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 2 | // |
John Criswell | 09344dc | 2003-10-20 17:47:21 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 345353d | 2007-12-29 20:44:31 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | 650ba8e | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 7 | // |
John Criswell | 09344dc | 2003-10-20 17:47:21 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 9 | // |
| 10 | // This class contains all of the shared state and information that is used by |
| 11 | // the BugPoint tool to track down errors in optimizations. This class is the |
| 12 | // main driver class that invokes all sub-functionality. |
| 13 | // |
| 14 | //===----------------------------------------------------------------------===// |
| 15 | |
| 16 | #include "BugDriver.h" |
Chris Lattner | ffac286 | 2006-06-06 22:30:59 +0000 | [diff] [blame] | 17 | #include "ToolRunner.h" |
Rafael Espindola | f49a38f | 2015-12-04 22:08:53 +0000 | [diff] [blame] | 18 | #include "llvm/IR/DiagnosticPrinter.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 19 | #include "llvm/IR/Module.h" |
Duncan P. N. Exon Smith | 5fbcc46 | 2015-03-26 05:03:10 +0000 | [diff] [blame] | 20 | #include "llvm/IR/Verifier.h" |
Chandler Carruth | e60e57b | 2013-03-26 02:25:37 +0000 | [diff] [blame] | 21 | #include "llvm/IRReader/IRReader.h" |
Chandler Carruth | 6cc07df | 2014-03-06 03:42:23 +0000 | [diff] [blame] | 22 | #include "llvm/Linker/Linker.h" |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 23 | #include "llvm/Pass.h" |
Reid Spencer | 7c16caa | 2004-09-01 22:55:40 +0000 | [diff] [blame] | 24 | #include "llvm/Support/CommandLine.h" |
| 25 | #include "llvm/Support/FileUtilities.h" |
Chandler Carruth | 4d88a1c | 2012-12-04 10:44:52 +0000 | [diff] [blame] | 26 | #include "llvm/Support/Host.h" |
Chris Lattner | a76611a | 2009-07-02 22:46:18 +0000 | [diff] [blame] | 27 | #include "llvm/Support/SourceMgr.h" |
Chris Lattner | ac161bf | 2009-01-02 07:01:27 +0000 | [diff] [blame] | 28 | #include "llvm/Support/raw_ostream.h" |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 29 | #include <memory> |
Brian Gaeke | 960707c | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 30 | using namespace llvm; |
| 31 | |
Daniel Dunbar | 8575a60 | 2009-08-18 03:35:57 +0000 | [diff] [blame] | 32 | namespace llvm { |
| 33 | Triple TargetTriple; |
| 34 | } |
| 35 | |
Misha Brukman | d792c9b | 2003-07-24 18:17:43 +0000 | [diff] [blame] | 36 | // Anonymous namespace to define command line options for debugging. |
| 37 | // |
| 38 | namespace { |
| 39 | // Output - The user can specify a file containing the expected output of the |
| 40 | // program. If this filename is set, it is used as the reference diff source, |
| 41 | // otherwise the raw input run through an interpreter is used as the reference |
| 42 | // source. |
| 43 | // |
Misha Brukman | 650ba8e | 2005-04-22 00:00:37 +0000 | [diff] [blame] | 44 | cl::opt<std::string> |
Misha Brukman | d792c9b | 2003-07-24 18:17:43 +0000 | [diff] [blame] | 45 | OutputFile("output", cl::desc("Specify a reference program output " |
| 46 | "(for miscompilation detection)")); |
Misha Brukman | d792c9b | 2003-07-24 18:17:43 +0000 | [diff] [blame] | 47 | } |
| 48 | |
Chris Lattner | 327019b | 2004-02-18 21:24:48 +0000 | [diff] [blame] | 49 | /// setNewProgram - If we reduce or update the program somehow, call this method |
| 50 | /// to update bugdriver with it. This deletes the old module and sets the |
| 51 | /// specified one as the current program. |
| 52 | void BugDriver::setNewProgram(Module *M) { |
| 53 | delete Program; |
| 54 | Program = M; |
| 55 | } |
| 56 | |
| 57 | |
Chris Lattner | 16a4131 | 2003-04-24 17:02:17 +0000 | [diff] [blame] | 58 | /// getPassesString - Turn a list of passes into a string which indicates the |
| 59 | /// command line options that must be passed to add the passes. |
| 60 | /// |
Rafael Espindola | 33e81a8 | 2010-08-08 03:55:08 +0000 | [diff] [blame] | 61 | std::string llvm::getPassesString(const std::vector<std::string> &Passes) { |
Chris Lattner | 16a4131 | 2003-04-24 17:02:17 +0000 | [diff] [blame] | 62 | std::string Result; |
| 63 | for (unsigned i = 0, e = Passes.size(); i != e; ++i) { |
| 64 | if (i) Result += " "; |
| 65 | Result += "-"; |
Rafael Espindola | 33e81a8 | 2010-08-08 03:55:08 +0000 | [diff] [blame] | 66 | Result += Passes[i]; |
Chris Lattner | 16a4131 | 2003-04-24 17:02:17 +0000 | [diff] [blame] | 67 | } |
| 68 | return Result; |
| 69 | } |
| 70 | |
Rafael Espindola | bbdce49 | 2010-08-07 23:03:21 +0000 | [diff] [blame] | 71 | BugDriver::BugDriver(const char *toolname, bool find_bugs, |
Jeffrey Yasskin | 71bd0f4 | 2010-03-19 00:09:28 +0000 | [diff] [blame] | 72 | unsigned timeout, unsigned memlimit, bool use_valgrind, |
Owen Anderson | 2a15443 | 2009-07-01 23:13:44 +0000 | [diff] [blame] | 73 | LLVMContext& ctxt) |
Owen Anderson | 6773d38 | 2009-07-01 16:58:40 +0000 | [diff] [blame] | 74 | : Context(ctxt), ToolName(toolname), ReferenceOutputFile(OutputFile), |
Craig Topper | e6cb63e | 2014-04-25 04:24:47 +0000 | [diff] [blame] | 75 | Program(nullptr), Interpreter(nullptr), SafeInterpreter(nullptr), |
Davide Italiano | ab25621 | 2015-10-14 20:29:54 +0000 | [diff] [blame] | 76 | cc(nullptr), run_find_bugs(find_bugs), Timeout(timeout), |
Jeffrey Yasskin | 71bd0f4 | 2010-03-19 00:09:28 +0000 | [diff] [blame] | 77 | MemoryLimit(memlimit), UseValgrind(use_valgrind) {} |
Misha Brukman | d792c9b | 2003-07-24 18:17:43 +0000 | [diff] [blame] | 78 | |
Jeffrey Yasskin | a6eedc3 | 2010-03-22 05:23:37 +0000 | [diff] [blame] | 79 | BugDriver::~BugDriver() { |
| 80 | delete Program; |
David Blaikie | 37436ed | 2014-04-25 20:15:16 +0000 | [diff] [blame] | 81 | if (Interpreter != SafeInterpreter) |
| 82 | delete Interpreter; |
| 83 | delete SafeInterpreter; |
Davide Italiano | ab25621 | 2015-10-14 20:29:54 +0000 | [diff] [blame] | 84 | delete cc; |
Jeffrey Yasskin | a6eedc3 | 2010-03-22 05:23:37 +0000 | [diff] [blame] | 85 | } |
| 86 | |
Rafael Espindola | 28b351a | 2014-08-26 17:19:03 +0000 | [diff] [blame] | 87 | std::unique_ptr<Module> llvm::parseInputFile(StringRef Filename, |
| 88 | LLVMContext &Ctxt) { |
Chris Lattner | a76611a | 2009-07-02 22:46:18 +0000 | [diff] [blame] | 89 | SMDiagnostic Err; |
Rafael Espindola | d233b06 | 2014-08-26 17:29:46 +0000 | [diff] [blame] | 90 | std::unique_ptr<Module> Result = parseIRFile(Filename, Err, Ctxt); |
Duncan P. N. Exon Smith | 866aed7 | 2015-03-26 05:03:06 +0000 | [diff] [blame] | 91 | if (!Result) { |
Chris Lattner | a3a0681 | 2011-10-16 04:47:35 +0000 | [diff] [blame] | 92 | Err.print("bugpoint", errs()); |
Duncan P. N. Exon Smith | 866aed7 | 2015-03-26 05:03:06 +0000 | [diff] [blame] | 93 | return Result; |
| 94 | } |
Dan Gohman | 728a81a | 2009-09-03 16:32:58 +0000 | [diff] [blame] | 95 | |
Duncan P. N. Exon Smith | 5fbcc46 | 2015-03-26 05:03:10 +0000 | [diff] [blame] | 96 | if (verifyModule(*Result, &errs())) { |
Duncan P. N. Exon Smith | 4628282 | 2015-03-31 03:07:23 +0000 | [diff] [blame] | 97 | errs() << "bugpoint: " << Filename << ": error: input module is broken!\n"; |
Duncan P. N. Exon Smith | 5fbcc46 | 2015-03-26 05:03:10 +0000 | [diff] [blame] | 98 | return std::unique_ptr<Module>(); |
| 99 | } |
| 100 | |
Daniel Dunbar | 8575a60 | 2009-08-18 03:35:57 +0000 | [diff] [blame] | 101 | // If we don't have an override triple, use the first one to configure |
| 102 | // bugpoint, or use the host triple if none provided. |
Duncan P. N. Exon Smith | 866aed7 | 2015-03-26 05:03:06 +0000 | [diff] [blame] | 103 | if (TargetTriple.getTriple().empty()) { |
| 104 | Triple TheTriple(Result->getTargetTriple()); |
Daniel Dunbar | 8575a60 | 2009-08-18 03:35:57 +0000 | [diff] [blame] | 105 | |
Duncan P. N. Exon Smith | 866aed7 | 2015-03-26 05:03:06 +0000 | [diff] [blame] | 106 | if (TheTriple.getTriple().empty()) |
| 107 | TheTriple.setTriple(sys::getDefaultTargetTriple()); |
Michael J. Spencer | 3df5c04 | 2011-03-31 13:06:39 +0000 | [diff] [blame] | 108 | |
Duncan P. N. Exon Smith | 866aed7 | 2015-03-26 05:03:06 +0000 | [diff] [blame] | 109 | TargetTriple.setTriple(TheTriple.getTriple()); |
Daniel Dunbar | 8575a60 | 2009-08-18 03:35:57 +0000 | [diff] [blame] | 110 | } |
Duncan P. N. Exon Smith | 866aed7 | 2015-03-26 05:03:06 +0000 | [diff] [blame] | 111 | |
| 112 | Result->setTargetTriple(TargetTriple.getTriple()); // override the triple |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 113 | return Result; |
| 114 | } |
| 115 | |
Rafael Espindola | f49a38f | 2015-12-04 22:08:53 +0000 | [diff] [blame] | 116 | static void diagnosticHandler(const DiagnosticInfo &DI) { |
| 117 | DiagnosticPrinterRawOStream DP(errs()); |
| 118 | DI.print(DP); |
| 119 | errs() << '\n'; |
| 120 | } |
| 121 | |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 122 | // This method takes the specified list of LLVM input files, attempts to load |
Gabor Greif | 0e535c3c | 2007-07-04 21:55:50 +0000 | [diff] [blame] | 123 | // them, either as assembly or bitcode, then link them together. It returns |
| 124 | // true on failure (if, for example, an input bitcode file could not be |
Brian Gaeke | 61a05da | 2003-05-23 05:34:32 +0000 | [diff] [blame] | 125 | // parsed), and false on success. |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 126 | // |
| 127 | bool BugDriver::addSources(const std::vector<std::string> &Filenames) { |
Craig Topper | e73658d | 2014-04-28 04:05:08 +0000 | [diff] [blame] | 128 | assert(!Program && "Cannot call addSources multiple times!"); |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 129 | assert(!Filenames.empty() && "Must specify at least on input filename!"); |
| 130 | |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 131 | // Load the first input file. |
Rafael Espindola | 28b351a | 2014-08-26 17:19:03 +0000 | [diff] [blame] | 132 | Program = parseInputFile(Filenames[0], Context).release(); |
Craig Topper | e6cb63e | 2014-04-25 04:24:47 +0000 | [diff] [blame] | 133 | if (!Program) return true; |
Michael J. Spencer | 3df5c04 | 2011-03-31 13:06:39 +0000 | [diff] [blame] | 134 | |
Rafael Espindola | bbdce49 | 2010-08-07 23:03:21 +0000 | [diff] [blame] | 135 | outs() << "Read input file : '" << Filenames[0] << "'\n"; |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 136 | |
| 137 | for (unsigned i = 1, e = Filenames.size(); i != e; ++i) { |
Rafael Espindola | 28b351a | 2014-08-26 17:19:03 +0000 | [diff] [blame] | 138 | std::unique_ptr<Module> M = parseInputFile(Filenames[i], Context); |
Craig Topper | e6cb63e | 2014-04-25 04:24:47 +0000 | [diff] [blame] | 139 | if (!M.get()) return true; |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 140 | |
Rafael Espindola | bbdce49 | 2010-08-07 23:03:21 +0000 | [diff] [blame] | 141 | outs() << "Linking in input file: '" << Filenames[i] << "'\n"; |
Rafael Espindola | f49a38f | 2015-12-04 22:08:53 +0000 | [diff] [blame] | 142 | if (Linker::linkModules(*Program, *M, diagnosticHandler)) |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 143 | return true; |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 144 | } |
| 145 | |
Rafael Espindola | bbdce49 | 2010-08-07 23:03:21 +0000 | [diff] [blame] | 146 | outs() << "*** All input ok\n"; |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 147 | |
| 148 | // All input files read successfully! |
| 149 | return false; |
| 150 | } |
| 151 | |
| 152 | |
| 153 | |
| 154 | /// run - The top level method that is invoked after all of the instance |
| 155 | /// variables are set up from command line arguments. |
| 156 | /// |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 157 | bool BugDriver::run(std::string &ErrMsg) { |
Patrick Jenkins | c46c038 | 2006-08-15 16:40:49 +0000 | [diff] [blame] | 158 | if (run_find_bugs) { |
| 159 | // Rearrange the passes and apply them to the program. Repeat this process |
| 160 | // until the user kills the program or we find a bug. |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 161 | return runManyPasses(PassesToRun, ErrMsg); |
Patrick Jenkins | c46c038 | 2006-08-15 16:40:49 +0000 | [diff] [blame] | 162 | } |
Reid Spencer | 842118c | 2005-12-22 20:02:55 +0000 | [diff] [blame] | 163 | |
Michael J. Spencer | 3df5c04 | 2011-03-31 13:06:39 +0000 | [diff] [blame] | 164 | // If we're not running as a child, the first thing that we must do is |
| 165 | // determine what the problem is. Does the optimization series crash the |
| 166 | // compiler, or does it produce illegal code? We make the top-level |
Sylvestre Ledru | 35521e2 | 2012-07-23 08:51:15 +0000 | [diff] [blame] | 167 | // decision by trying to run all of the passes on the input program, |
Michael J. Spencer | 3df5c04 | 2011-03-31 13:06:39 +0000 | [diff] [blame] | 168 | // which should generate a bitcode file. If it does generate a bitcode |
| 169 | // file, then we know the compiler didn't crash, so try to diagnose a |
Reid Spencer | 842118c | 2005-12-22 20:02:55 +0000 | [diff] [blame] | 170 | // miscompilation. |
Chris Lattner | 6ca0b87 | 2003-10-13 21:04:26 +0000 | [diff] [blame] | 171 | if (!PassesToRun.empty()) { |
Dan Gohman | ee05152 | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 172 | outs() << "Running selected passes on program to test for crash: "; |
Rafael Espindola | 37302ea | 2010-08-05 02:16:32 +0000 | [diff] [blame] | 173 | if (runPasses(Program, PassesToRun)) |
Chris Lattner | ead1dff | 2004-02-18 21:02:04 +0000 | [diff] [blame] | 174 | return debugOptimizerCrash(); |
Chris Lattner | 6ca0b87 | 2003-10-13 21:04:26 +0000 | [diff] [blame] | 175 | } |
Misha Brukman | d792c9b | 2003-07-24 18:17:43 +0000 | [diff] [blame] | 176 | |
Gabor Greif | 0e535c3c | 2007-07-04 21:55:50 +0000 | [diff] [blame] | 177 | // Set up the execution environment, selecting a method to run LLVM bitcode. |
Misha Brukman | d792c9b | 2003-07-24 18:17:43 +0000 | [diff] [blame] | 178 | if (initializeExecutionEnvironment()) return true; |
| 179 | |
Chris Lattner | 5e9868a | 2004-02-19 17:03:49 +0000 | [diff] [blame] | 180 | // Test to see if we have a code generator crash. |
Dan Gohman | ee05152 | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 181 | outs() << "Running the code generator to test for a crash: "; |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 182 | std::string Error; |
| 183 | compileProgram(Program, &Error); |
| 184 | if (!Error.empty()) { |
| 185 | outs() << Error; |
| 186 | return debugCodeGeneratorCrash(ErrMsg); |
Chris Lattner | 5e9868a | 2004-02-19 17:03:49 +0000 | [diff] [blame] | 187 | } |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 188 | outs() << '\n'; |
Chris Lattner | 5e9868a | 2004-02-19 17:03:49 +0000 | [diff] [blame] | 189 | |
Misha Brukman | d792c9b | 2003-07-24 18:17:43 +0000 | [diff] [blame] | 190 | // Run the raw input to see where we are coming from. If a reference output |
| 191 | // was specified, make sure that the raw output matches it. If not, it's a |
| 192 | // problem in the front-end or the code generator. |
| 193 | // |
Chris Lattner | d1123fd | 2003-08-22 18:57:43 +0000 | [diff] [blame] | 194 | bool CreatedOutput = false; |
Misha Brukman | d792c9b | 2003-07-24 18:17:43 +0000 | [diff] [blame] | 195 | if (ReferenceOutputFile.empty()) { |
Dan Gohman | ee05152 | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 196 | outs() << "Generating reference output from raw program: "; |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 197 | if (!createReferenceFile(Program)) { |
| 198 | return debugCodeGeneratorCrash(ErrMsg); |
Chris Lattner | ead1dff | 2004-02-18 21:02:04 +0000 | [diff] [blame] | 199 | } |
Patrick Jenkins | c46c038 | 2006-08-15 16:40:49 +0000 | [diff] [blame] | 200 | CreatedOutput = true; |
Misha Brukman | d792c9b | 2003-07-24 18:17:43 +0000 | [diff] [blame] | 201 | } |
| 202 | |
Chris Lattner | 2ed0642 | 2003-10-14 20:52:55 +0000 | [diff] [blame] | 203 | // Make sure the reference output file gets deleted on exit from this |
| 204 | // function, if appropriate. |
Rafael Espindola | 319d975 | 2013-06-18 16:21:54 +0000 | [diff] [blame] | 205 | std::string ROF(ReferenceOutputFile); |
| 206 | FileRemover RemoverInstance(ROF, CreatedOutput && !SaveTemps); |
Chris Lattner | 2ed0642 | 2003-10-14 20:52:55 +0000 | [diff] [blame] | 207 | |
| 208 | // Diff the output of the raw program against the reference output. If it |
Michael J. Spencer | 3df5c04 | 2011-03-31 13:06:39 +0000 | [diff] [blame] | 209 | // matches, then we assume there is a miscompilation bug and try to |
Patrick Jenkins | c46c038 | 2006-08-15 16:40:49 +0000 | [diff] [blame] | 210 | // diagnose it. |
Dan Gohman | ee05152 | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 211 | outs() << "*** Checking the code generator...\n"; |
Rafael Espindola | c89b1ef | 2010-07-30 14:19:00 +0000 | [diff] [blame] | 212 | bool Diff = diffProgram(Program, "", "", false, &Error); |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 213 | if (!Error.empty()) { |
| 214 | errs() << Error; |
| 215 | return debugCodeGeneratorCrash(ErrMsg); |
| 216 | } |
| 217 | if (!Diff) { |
| 218 | outs() << "\n*** Output matches: Debugging miscompilation!\n"; |
| 219 | debugMiscompilation(&Error); |
| 220 | if (!Error.empty()) { |
| 221 | errs() << Error; |
| 222 | return debugCodeGeneratorCrash(ErrMsg); |
Chris Lattner | ead1dff | 2004-02-18 21:02:04 +0000 | [diff] [blame] | 223 | } |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 224 | return false; |
Chris Lattner | 2ed0642 | 2003-10-14 20:52:55 +0000 | [diff] [blame] | 225 | } |
| 226 | |
Dan Gohman | ee05152 | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 227 | outs() << "\n*** Input program does not match reference diff!\n"; |
| 228 | outs() << "Debugging code generator problem!\n"; |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 229 | bool Failure = debugCodeGenerator(&Error); |
| 230 | if (!Error.empty()) { |
| 231 | errs() << Error; |
| 232 | return debugCodeGeneratorCrash(ErrMsg); |
Chris Lattner | 5e9868a | 2004-02-19 17:03:49 +0000 | [diff] [blame] | 233 | } |
Nick Lewycky | 6ba630b | 2010-04-12 05:08:25 +0000 | [diff] [blame] | 234 | return Failure; |
Misha Brukman | d792c9b | 2003-07-24 18:17:43 +0000 | [diff] [blame] | 235 | } |
| 236 | |
Chris Lattner | fd72bed | 2004-03-14 20:50:42 +0000 | [diff] [blame] | 237 | void llvm::PrintFunctionList(const std::vector<Function*> &Funcs) { |
| 238 | unsigned NumPrint = Funcs.size(); |
| 239 | if (NumPrint > 10) NumPrint = 10; |
| 240 | for (unsigned i = 0; i != NumPrint; ++i) |
Dan Gohman | ee05152 | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 241 | outs() << " " << Funcs[i]->getName(); |
Chris Lattner | fd72bed | 2004-03-14 20:50:42 +0000 | [diff] [blame] | 242 | if (NumPrint < Funcs.size()) |
Dan Gohman | ee05152 | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 243 | outs() << "... <" << Funcs.size() << " total>"; |
| 244 | outs().flush(); |
Chris Lattner | 73a6bdd | 2002-11-20 22:28:10 +0000 | [diff] [blame] | 245 | } |
Bill Wendling | 3f83343 | 2006-10-25 18:36:14 +0000 | [diff] [blame] | 246 | |
| 247 | void llvm::PrintGlobalVariableList(const std::vector<GlobalVariable*> &GVs) { |
| 248 | unsigned NumPrint = GVs.size(); |
| 249 | if (NumPrint > 10) NumPrint = 10; |
| 250 | for (unsigned i = 0; i != NumPrint; ++i) |
Dan Gohman | ee05152 | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 251 | outs() << " " << GVs[i]->getName(); |
Bill Wendling | 3f83343 | 2006-10-25 18:36:14 +0000 | [diff] [blame] | 252 | if (NumPrint < GVs.size()) |
Dan Gohman | ee05152 | 2009-07-16 15:30:09 +0000 | [diff] [blame] | 253 | outs() << "... <" << GVs.size() << " total>"; |
| 254 | outs().flush(); |
Bill Wendling | 3f83343 | 2006-10-25 18:36:14 +0000 | [diff] [blame] | 255 | } |