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