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