llvm.org GIT mirror llvm / 65f57c2
Use errs() instead of std::cerr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75791 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
20 changed file(s) with 249 addition(s) and 242 deletion(s). Raw diff Collapse all Expand all
116116 std::cout << "Linking in input file: '" << Filenames[i] << "'\n";
117117 std::string ErrorMessage;
118118 if (Linker::LinkModules(Program, M.get(), &ErrorMessage)) {
119 std::cerr << ToolName << ": error linking in '" << Filenames[i] << "': "
120 << ErrorMessage << '\n';
119 errs() << ToolName << ": error linking in '" << Filenames[i] << "': "
120 << ErrorMessage << '\n';
121121 return true;
122122 }
123123 }
124124 } catch (const std::string &Error) {
125 std::cerr << ToolName << ": error reading input '" << Error << "'\n";
125 errs() << ToolName << ": error reading input '" << Error << "'\n";
126126 return true;
127127 }
128128
208208 return debugMiscompilation();
209209 }
210210 } catch (ToolExecutionError &TEE) {
211 std::cerr << TEE.what();
211 errs() << TEE.what();
212212 return debugCodeGeneratorCrash();
213213 }
214214
217217 try {
218218 return debugCodeGenerator();
219219 } catch (ToolExecutionError &TEE) {
220 std::cerr << TEE.what();
220 errs() << TEE.what();
221221 return debugCodeGeneratorCrash();
222222 }
223223 }
2727 #include "llvm/Transforms/Utils/Cloning.h"
2828 #include "llvm/Support/FileUtilities.h"
2929 #include "llvm/Support/CommandLine.h"
30 #include
3031 #include
3132 #include
3233 using namespace llvm;
7475
7576 BD.Program = ParseInputFile(PrefixOutput.toString(), BD.getContext());
7677 if (BD.Program == 0) {
77 std::cerr << BD.getToolName() << ": Error reading bitcode file '"
78 << PrefixOutput << "'!\n";
78 errs() << BD.getToolName() << ": Error reading bitcode file '"
79 << PrefixOutput << "'!\n";
7980 exit(1);
8081 }
8182 PrefixOutput.eraseFromDisk();
630631 static bool TestForCodeGenCrash(BugDriver &BD, Module *M) {
631632 try {
632633 BD.compileProgram(M);
633 std::cerr << '\n';
634 errs() << '\n';
634635 return false;
635636 } catch (ToolExecutionError &) {
636 std::cerr << "\n";
637 errs() << "\n";
637638 return true; // Tool is still crashing.
638639 }
639640 }
642643 /// crashes on an input. It attempts to reduce the input as much as possible
643644 /// while still causing the code generator to crash.
644645 bool BugDriver::debugCodeGeneratorCrash() {
645 std::cerr << "*** Debugging code generator crash!\n";
646 errs() << "*** Debugging code generator crash!\n";
646647
647648 return DebugACrash(*this, TestForCodeGenCrash);
648649 }
185185 break;
186186 }
187187 if (!Interpreter)
188 std::cerr << Message;
188 errs() << Message;
189189 else // Display informational messages on stdout instead of stderr
190190 std::cout << Message;
191191
277277 sys::Path BitcodeFile ("bugpoint-test-program.bc");
278278 std::string ErrMsg;
279279 if (BitcodeFile.makeUnique(true,&ErrMsg)) {
280 std::cerr << ToolName << ": Error making unique filename: " << ErrMsg
281 << "\n";
280 errs() << ToolName << ": Error making unique filename: " << ErrMsg
281 << "\n";
282282 exit(1);
283283 }
284284 if (writeProgramToFile(BitcodeFile.toString(), M)) {
285 std::cerr << ToolName << ": Error emitting bitcode to file '"
286 << BitcodeFile << "'!\n";
285 errs() << ToolName << ": Error emitting bitcode to file '"
286 << BitcodeFile << "'!\n";
287287 exit(1);
288288 }
289289
312312 // Emit the program to a bitcode file...
313313 sys::Path uniqueFilename("bugpoint-test-program.bc");
314314 if (uniqueFilename.makeUnique(true, &ErrMsg)) {
315 std::cerr << ToolName << ": Error making unique filename: "
316 << ErrMsg << "!\n";
315 errs() << ToolName << ": Error making unique filename: "
316 << ErrMsg << "!\n";
317317 exit(1);
318318 }
319319 BitcodeFile = uniqueFilename.toString();
320320
321321 if (writeProgramToFile(BitcodeFile, Program)) {
322 std::cerr << ToolName << ": Error emitting bitcode to file '"
323 << BitcodeFile << "'!\n";
322 errs() << ToolName << ": Error emitting bitcode to file '"
323 << BitcodeFile << "'!\n";
324324 exit(1);
325325 }
326326 CreatedBitcode = true;
335335 // Check to see if this is a valid output filename...
336336 sys::Path uniqueFile(OutputFile);
337337 if (uniqueFile.makeUnique(true, &ErrMsg)) {
338 std::cerr << ToolName << ": Error making unique filename: "
339 << ErrMsg << "\n";
338 errs() << ToolName << ": Error making unique filename: "
339 << ErrMsg << "\n";
340340 exit(1);
341341 }
342342 OutputFile = uniqueFile.toString();
351351 Timeout, MemoryLimit);
352352
353353 if (RetVal == -1) {
354 std::cerr << "";
354 errs() << "";
355355 static bool FirstTimeout = true;
356356 if (FirstTimeout) {
357357 std::cout << "\n"
419419 ReferenceOutputFile = executeProgramSafely(Filename);
420420 std::cout << "\nReference output is: " << ReferenceOutputFile << "\n\n";
421421 } catch (ToolExecutionError &TEE) {
422 std::cerr << TEE.what();
422 errs() << TEE.what();
423423 if (Interpreter != SafeInterpreter) {
424 std::cerr << "*** There is a bug running the \"safe\" backend. Either"
425 << " debug it (for example with the -run-cbe bugpoint option,"
426 << " if CBE is being used as the \"safe\" backend), or fix the"
427 << " error some other way.\n";
424 errs() << "*** There is a bug running the \"safe\" backend. Either"
425 << " debug it (for example with the -run-cbe bugpoint option,"
426 << " if CBE is being used as the \"safe\" backend), or fix the"
427 << " error some other way.\n";
428428 }
429429 return false;
430430 }
451451 sys::Path(Output.toString()),
452452 AbsTolerance, RelTolerance, &Error)) {
453453 if (Diff == 2) {
454 std::cerr << "While diffing output: " << Error << '\n';
454 errs() << "While diffing output: " << Error << '\n';
455455 exit(1);
456456 }
457457 FilesDifferent = true;
126126
127127 Module *New = runPassesOn(M, CleanupPasses);
128128 if (New == 0) {
129 std::cerr << "Final cleanups failed. Sorry. :( Please report a bug!\n";
129 errs() << "Final cleanups failed. Sorry. :( Please report a bug!\n";
130130 return M;
131131 }
132132 delete M;
287287 std::set TestFunctions;
288288 for (unsigned i = 0, e = F.size(); i != e; ++i) {
289289 Function *TNOF = cast(ValueMap[F[i]]);
290 DEBUG(std::cerr << "Removing function ");
291 DEBUG(WriteAsOperand(std::cerr, TNOF, false));
292 DEBUG(std::cerr << "\n");
290 DEBUG(errs() << "Removing function ");
291 DEBUG(WriteAsOperand(errs(), TNOF, false));
292 DEBUG(errs() << "\n");
293293 TestFunctions.insert(cast(NewValueMap[TNOF]));
294294 DeleteFunctionBody(TNOF); // Function is now external in this module!
295295 }
327327 std::string ErrMsg;
328328 if (uniqueFilename.createTemporaryFileOnDisk(true, &ErrMsg)) {
329329 std::cout << "*** Basic Block extraction failed!\n";
330 std::cerr << "Error creating temporary file: " << ErrMsg << "\n";
330 errs() << "Error creating temporary file: " << ErrMsg << "\n";
331331 M = swapProgramIn(M);
332332 EmitProgressBitcode("basicblockextractfail", true);
333333 swapProgramIn(M);
338338 std::ofstream BlocksToNotExtractFile(uniqueFilename.c_str());
339339 if (!BlocksToNotExtractFile) {
340340 std::cout << "*** Basic Block extraction failed!\n";
341 std::cerr << "Error writing list of blocks to not extract: " << ErrMsg
342 << "\n";
341 errs() << "Error writing list of blocks to not extract: " << ErrMsg
342 << "\n";
343343 M = swapProgramIn(M);
344344 EmitProgressBitcode("basicblockextractfail", true);
345345 swapProgramIn(M);
9696 std::cout << "\n*** diff'd output matches!\n";
9797 }
9898 } catch (ToolExecutionError &TEE) {
99 std::cerr << TEE.what();
99 errs() << TEE.what();
100100 debugCodeGeneratorCrash();
101101 return true;
102102 }
1414 #ifndef BUGPOINT_LIST_REDUCER_H
1515 #define BUGPOINT_LIST_REDUCER_H
1616
17 #include "llvm/Support/raw_ostream.h"
1718 #include
18 #include
1919 #include
2020 #include
2121
5757
5858 case KeepSuffix:
5959 // cannot be reached!
60 std::cerr << "bugpoint ListReducer internal error: selected empty set.\n";
60 errs() << "bugpoint ListReducer internal error: selected empty set.\n";
6161 abort();
6262
6363 case NoFailure:
7676 while (MidTop > 1) { // Binary split reduction loop
7777 // Halt if the user presses ctrl-c.
7878 if (BugpointIsInterrupted) {
79 std::cerr << "\n\n*** Reduction Interrupted, cleaning up...\n\n";
79 errs() << "\n\n*** Reduction Interrupted, cleaning up...\n\n";
8080 return true;
8181 }
8282
8787 NumOfIterationsWithoutProgress > MaxIterations) {
8888 std::vector ShuffledList(TheList);
8989 std::random_shuffle(ShuffledList.begin(), ShuffledList.end());
90 std::cerr << "\n\n*** Testing shuffled set...\n\n";
90 errs() << "\n\n*** Testing shuffled set...\n\n";
9191 // Check that random shuffle doesn't loose the bug
9292 if (doTest(ShuffledList, empty) == KeepPrefix) {
9393 // If the bug is still here, use the shuffled list.
9696 // Must increase the shuffling treshold to avoid the small
9797 // probability of inifinite looping without making progress.
9898 MaxIterations += 2;
99 std::cerr << "\n\n*** Shuffling does not hide the bug...\n\n";
99 errs() << "\n\n*** Shuffling does not hide the bug...\n\n";
100100 } else {
101101 ShufflingEnabled = false; // Disable shuffling further on
102 std::cerr << "\n\n*** Shuffling hides the bug...\n\n";
102 errs() << "\n\n*** Shuffling hides the bug...\n\n";
103103 }
104104 NumOfIterationsWithoutProgress = 0;
105105 }
159159
160160 for (unsigned i = 1; i < TheList.size()-1; ++i) { // Check interior elts
161161 if (BugpointIsInterrupted) {
162 std::cerr << "\n\n*** Reduction Interrupted, cleaning up...\n\n";
162 errs() << "\n\n*** Reduction Interrupted, cleaning up...\n\n";
163163 return true;
164164 }
165165
2525 #include "llvm/Support/CommandLine.h"
2626 #include "llvm/Support/FileUtilities.h"
2727 #include "llvm/Config/config.h" // for HAVE_LINK_R
28 #include
2829 using namespace llvm;
2930
3031 namespace llvm {
6061
6162 std::string BitcodeResult;
6263 if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
63 std::cerr << " Error running this sequence of passes"
64 << " on the input program!\n";
64 errs() << " Error running this sequence of passes"
65 << " on the input program!\n";
6566 BD.setPassesToRun(Suffix);
6667 BD.EmitProgressBitcode("pass-error", false);
6768 exit(BD.debugOptimizerCrash());
7172 if (BD.diffProgram(BitcodeResult, "", true /*delete bitcode*/)) {
7273 std::cout << " nope.\n";
7374 if (Suffix.empty()) {
74 std::cerr << BD.getToolName() << ": I'm confused: the test fails when "
75 << "no passes are run, nondeterministic program?\n";
75 errs() << BD.getToolName() << ": I'm confused: the test fails when "
76 << "no passes are run, nondeterministic program?\n";
7677 exit(1);
7778 }
7879 return KeepSuffix; // Miscompilation detected!
9394 // prefix passes, then discard the prefix passes.
9495 //
9596 if (BD.runPasses(Prefix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
96 std::cerr << " Error running this sequence of passes"
97 << " on the input program!\n";
97 errs() << " Error running this sequence of passes"
98 << " on the input program!\n";
9899 BD.setPassesToRun(Prefix);
99100 BD.EmitProgressBitcode("pass-error", false);
100101 exit(BD.debugOptimizerCrash());
113114 //
114115 Module *PrefixOutput = ParseInputFile(BitcodeResult, BD.getContext());
115116 if (PrefixOutput == 0) {
116 std::cerr << BD.getToolName() << ": Error reading bitcode file '"
117 << BitcodeResult << "'!\n";
117 errs() << BD.getToolName() << ": Error reading bitcode file '"
118 << BitcodeResult << "'!\n";
118119 exit(1);
119120 }
120121 sys::Path(BitcodeResult).eraseFromDisk(); // No longer need the file on disk
129130
130131 Module *OriginalInput = BD.swapProgramIn(PrefixOutput);
131132 if (BD.runPasses(Suffix, BitcodeResult, false/*delete*/, true/*quiet*/)) {
132 std::cerr << " Error running this sequence of passes"
133 << " on the input program!\n";
133 errs() << " Error running this sequence of passes"
134 << " on the input program!\n";
134135 BD.setPassesToRun(Suffix);
135136 BD.EmitProgressBitcode("pass-error", false);
136137 exit(BD.debugOptimizerCrash());
186187 M2 = CloneModule(M2);
187188 }
188189 if (Linker::LinkModules(M1, M2, &ErrorMsg)) {
189 std::cerr << BD.getToolName() << ": Error linking modules together:"
190 << ErrorMsg << '\n';
190 errs() << BD.getToolName() << ": Error linking modules together:"
191 << ErrorMsg << '\n';
191192 exit(1);
192193 }
193194 delete M2; // We are done with this module.
278279 return MadeChange;
279280 }
280281
281 std::cerr << "Extracted a loop from the breaking portion of the program.\n";
282 errs() << "Extracted a loop from the breaking portion of the program.\n";
282283
283284 // Bugpoint is intentionally not very trusting of LLVM transformations. In
284285 // particular, we're not going to assume that the loop extractor works, so
290291 BD.switchToInterpreter(AI);
291292
292293 // Merged program doesn't work anymore!
293 std::cerr << " *** ERROR: Loop extraction broke the program. :("
294 << " Please report a bug!\n";
295 std::cerr << " Continuing on with un-loop-extracted version.\n";
294 errs() << " *** ERROR: Loop extraction broke the program. :("
295 << " Please report a bug!\n";
296 errs() << " Continuing on with un-loop-extracted version.\n";
296297
297298 BD.writeProgramToFile("bugpoint-loop-extract-fail-tno.bc", ToNotOptimize);
298299 BD.writeProgramToFile("bugpoint-loop-extract-fail-to.bc", ToOptimize);
299300 BD.writeProgramToFile("bugpoint-loop-extract-fail-to-le.bc",
300301 ToOptimizeLoopExtracted);
301302
302 std::cerr << "Please submit the bugpoint-loop-extract-fail-*.bc files.\n";
303 errs() << "Please submit the bugpoint-loop-extract-fail-*.bc files.\n";
303304 delete ToOptimize;
304305 delete ToNotOptimize;
305306 delete ToOptimizeLoopExtracted;
338339 // extract another loop.
339340 std::string ErrorMsg;
340341 if (Linker::LinkModules(ToNotOptimize, ToOptimizeLoopExtracted, &ErrorMsg)){
341 std::cerr << BD.getToolName() << ": Error linking modules together:"
342 << ErrorMsg << '\n';
342 errs() << BD.getToolName() << ": Error linking modules together:"
343 << ErrorMsg << '\n';
343344 exit(1);
344345 }
345346 delete ToOptimizeLoopExtracted;
461462 Module *Extracted = BD.ExtractMappedBlocksFromModule(Blocks, ToExtract);
462463 if (Extracted == 0) {
463464 // Weird, extraction should have worked.
464 std::cerr << "Nondeterministic problem extracting blocks??\n";
465 errs() << "Nondeterministic problem extracting blocks??\n";
465466 delete ProgClone;
466467 delete ToExtract;
467468 return false;
480481
481482 std::string ErrorMsg;
482483 if (Linker::LinkModules(ProgClone, Extracted, &ErrorMsg)) {
483 std::cerr << BD.getToolName() << ": Error linking modules together:"
484 << ErrorMsg << '\n';
484 errs() << BD.getToolName() << ": Error linking modules together:"
485 << ErrorMsg << '\n';
485486 exit(1);
486487 }
487488 delete Extracted;
605606 // Make sure something was miscompiled...
606607 if (!BugpointIsInterrupted)
607608 if (!ReduceMiscompilingPasses(*this).reduceList(PassesToRun)) {
608 std::cerr << "*** Optimized program matches reference output! No problem"
609 << " detected...\nbugpoint can't help you with your problem!\n";
609 errs() << "*** Optimized program matches reference output! No problem"
610 << " detected...\nbugpoint can't help you with your problem!\n";
610611 return false;
611612 }
612613
795796 }
796797
797798 if (verifyModule(*Test) || verifyModule(*Safe)) {
798 std::cerr << "Bugpoint has a bug, which corrupted a module!!\n";
799 errs() << "Bugpoint has a bug, which corrupted a module!!\n";
799800 abort();
800801 }
801802 }
812813 sys::Path TestModuleBC("bugpoint.test.bc");
813814 std::string ErrMsg;
814815 if (TestModuleBC.makeUnique(true, &ErrMsg)) {
815 std::cerr << BD.getToolName() << "Error making unique filename: "
816 << ErrMsg << "\n";
816 errs() << BD.getToolName() << "Error making unique filename: "
817 << ErrMsg << "\n";
817818 exit(1);
818819 }
819820 if (BD.writeProgramToFile(TestModuleBC.toString(), Test)) {
820 std::cerr << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
821 errs() << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
821822 exit(1);
822823 }
823824 delete Test;
825826 // Make the shared library
826827 sys::Path SafeModuleBC("bugpoint.safe.bc");
827828 if (SafeModuleBC.makeUnique(true, &ErrMsg)) {
828 std::cerr << BD.getToolName() << "Error making unique filename: "
829 << ErrMsg << "\n";
829 errs() << BD.getToolName() << "Error making unique filename: "
830 << ErrMsg << "\n";
830831 exit(1);
831832 }
832833
833834 if (BD.writeProgramToFile(SafeModuleBC.toString(), Safe)) {
834 std::cerr << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
835 errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
835836 exit(1);
836837 }
837838 std::string SharedObject = BD.compileSharedObject(SafeModuleBC.toString());
842843 int Result = BD.diffProgram(TestModuleBC.toString(), SharedObject, false);
843844
844845 if (Result)
845 std::cerr << ": still failing!\n";
846 errs() << ": still failing!\n";
846847 else
847 std::cerr << ": didn't fail.\n";
848 errs() << ": didn't fail.\n";
848849 TestModuleBC.eraseFromDisk();
849850 SafeModuleBC.eraseFromDisk();
850851 sys::Path(SharedObject).eraseFromDisk();
884885 sys::Path TestModuleBC("bugpoint.test.bc");
885886 std::string ErrMsg;
886887 if (TestModuleBC.makeUnique(true, &ErrMsg)) {
887 std::cerr << getToolName() << "Error making unique filename: "
888 << ErrMsg << "\n";
888 errs() << getToolName() << "Error making unique filename: "
889 << ErrMsg << "\n";
889890 exit(1);
890891 }
891892
892893 if (writeProgramToFile(TestModuleBC.toString(), ToCodeGen)) {
893 std::cerr << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
894 errs() << "Error writing bitcode to `" << TestModuleBC << "'\nExiting.";
894895 exit(1);
895896 }
896897 delete ToCodeGen;
898899 // Make the shared library
899900 sys::Path SafeModuleBC("bugpoint.safe.bc");
900901 if (SafeModuleBC.makeUnique(true, &ErrMsg)) {
901 std::cerr << getToolName() << "Error making unique filename: "
902 << ErrMsg << "\n";
902 errs() << getToolName() << "Error making unique filename: "
903 << ErrMsg << "\n";
903904 exit(1);
904905 }
905906
906907 if (writeProgramToFile(SafeModuleBC.toString(), ToNotCodeGen)) {
907 std::cerr << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
908 errs() << "Error writing bitcode to `" << SafeModuleBC << "'\nExiting.";
908909 exit(1);
909910 }
910911 std::string SharedObject = compileSharedObject(SafeModuleBC.toString());
6262 redirects[2] = &StdErrFile;
6363
6464 if (0) {
65 std::cerr << "RUN:";
65 errs() << "RUN:";
6666 for (unsigned i = 0; Args[i]; ++i)
67 std::cerr << " " << Args[i];
68 std::cerr << "\n";
67 errs() << " " << Args[i];
68 errs() << "\n";
6969 }
7070
7171 return
8686 sys::Path ErrorFilename("bugpoint.program_error_messages");
8787 std::string ErrMsg;
8888 if (ErrorFilename.makeUnique(true, &ErrMsg)) {
89 std::cerr << "Error making unique filename: " << ErrMsg << "\n";
89 errs() << "Error making unique filename: " << ErrMsg << "\n";
9090 exit(1);
9191 }
9292 RunProgramWithTimeout(ProgPath, Args, sys::Path(""), ErrorFilename,
158158 LLIArgs.push_back(0);
159159
160160 std::cout << "" << std::flush;
161 DEBUG(std::cerr << "\nAbout to run:\t";
161 DEBUG(errs() << "\nAbout to run:\t";
162162 for (unsigned i=0, e = LLIArgs.size()-1; i != e; ++i)
163 std::cerr << " " << LLIArgs[i];
164 std::cerr << "\n";
163 errs() << " " << LLIArgs[i];
164 errs() << "\n";
165165 );
166166 return RunProgramWithTimeout(sys::Path(LLIPath), &LLIArgs[0],
167167 sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
294294 sys::Path uniqueFile(Bitcode+".llc.s");
295295 std::string ErrMsg;
296296 if (uniqueFile.makeUnique(true, &ErrMsg)) {
297 std::cerr << "Error making unique filename: " << ErrMsg << "\n";
297 errs() << "Error making unique filename: " << ErrMsg << "\n";
298298 exit(1);
299299 }
300300 OutputAsmFile = uniqueFile;
312312 LLCArgs.push_back (0);
313313
314314 std::cout << "" << std::flush;
315 DEBUG(std::cerr << "\nAbout to run:\t";
315 DEBUG(errs() << "\nAbout to run:\t";
316316 for (unsigned i=0, e = LLCArgs.size()-1; i != e; ++i)
317 std::cerr << " " << LLCArgs[i];
318 std::cerr << "\n";
317 errs() << " " << LLCArgs[i];
318 errs() << "\n";
319319 );
320320 if (RunProgramWithTimeout(sys::Path(LLCPath), &LLCArgs[0],
321321 sys::Path(), sys::Path(), sys::Path()))
368368 Message = "Found llc: " + LLCPath + "\n";
369369 GCC *gcc = GCC::create(ProgramPath, Message, GCCArgs);
370370 if (!gcc) {
371 std::cerr << Message << "\n";
371 errs() << Message << "\n";
372372 exit(1);
373373 }
374374 return new LLC(LLCPath, gcc, Args, GCCArgs);
429429 JITArgs.push_back(0);
430430
431431 std::cout << "" << std::flush;
432 DEBUG(std::cerr << "\nAbout to run:\t";
432 DEBUG(errs() << "\nAbout to run:\t";
433433 for (unsigned i=0, e = JITArgs.size()-1; i != e; ++i)
434 std::cerr << " " << JITArgs[i];
435 std::cerr << "\n";
434 errs() << " " << JITArgs[i];
435 errs() << "\n";
436436 );
437 DEBUG(std::cerr << "\nSending output to " << OutputFile << "\n");
437 DEBUG(errs() << "\nSending output to " << OutputFile << "\n");
438438 return RunProgramWithTimeout(sys::Path(LLIPath), &JITArgs[0],
439439 sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
440440 Timeout, MemoryLimit);
459459 sys::Path uniqueFile(Bitcode+".cbe.c");
460460 std::string ErrMsg;
461461 if (uniqueFile.makeUnique(true, &ErrMsg)) {
462 std::cerr << "Error making unique filename: " << ErrMsg << "\n";
462 errs() << "Error making unique filename: " << ErrMsg << "\n";
463463 exit(1);
464464 }
465465 OutputCFile = uniqueFile;
478478 LLCArgs.push_back (0);
479479
480480 std::cout << "" << std::flush;
481 DEBUG(std::cerr << "\nAbout to run:\t";
481 DEBUG(errs() << "\nAbout to run:\t";
482482 for (unsigned i=0, e = LLCArgs.size()-1; i != e; ++i)
483 std::cerr << " " << LLCArgs[i];
484 std::cerr << "\n";
483 errs() << " " << LLCArgs[i];
484 errs() << "\n";
485485 );
486486 if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], sys::Path(), sys::Path(),
487487 sys::Path()))
532532 Message = "Found llc: " + LLCPath.toString() + "\n";
533533 GCC *gcc = GCC::create(ProgramPath, Message, GCCArgs);
534534 if (!gcc) {
535 std::cerr << Message << "\n";
535 errs() << Message << "\n";
536536 exit(1);
537537 }
538538 return new CBE(LLCPath, gcc, Args);
598598 sys::Path OutputBinary (ProgramFile+".gcc.exe");
599599 std::string ErrMsg;
600600 if (OutputBinary.makeUnique(true, &ErrMsg)) {
601 std::cerr << "Error making unique filename: " << ErrMsg << "\n";
601 errs() << "Error making unique filename: " << ErrMsg << "\n";
602602 exit(1);
603603 }
604604 GCCArgs.push_back(OutputBinary.c_str()); // Output to the right file...
621621 GCCArgs.push_back(0); // NULL terminator
622622
623623 std::cout << "" << std::flush;
624 DEBUG(std::cerr << "\nAbout to run:\t";
624 DEBUG(errs() << "\nAbout to run:\t";
625625 for (unsigned i=0, e = GCCArgs.size()-1; i != e; ++i)
626 std::cerr << " " << GCCArgs[i];
627 std::cerr << "\n";
626 errs() << " " << GCCArgs[i];
627 errs() << "\n";
628628 );
629629 if (RunProgramWithTimeout(GCCPath, &GCCArgs[0], sys::Path(), sys::Path(),
630630 sys::Path())) {
665665
666666 // Now that we have a binary, run it!
667667 std::cout << "" << std::flush;
668 DEBUG(std::cerr << "\nAbout to run:\t";
668 DEBUG(errs() << "\nAbout to run:\t";
669669 for (unsigned i=0, e = ProgramArgs.size()-1; i != e; ++i)
670 std::cerr << " " << ProgramArgs[i];
671 std::cerr << "\n";
670 errs() << " " << ProgramArgs[i];
671 errs() << "\n";
672672 );
673673
674674 FileRemover OutputBinaryRemover(OutputBinary);
675675
676676 if (RemoteClientPath.isEmpty()) {
677 DEBUG(std::cerr << "" << std::flush;);
677 DEBUG(errs() << "";);
678678 return RunProgramWithTimeout(OutputBinary, &ProgramArgs[0],
679679 sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile),
680680 Timeout, MemoryLimit);
684684 &ProgramArgs[0], sys::Path(InputFile), sys::Path(OutputFile),
685685 sys::Path(OutputFile), Timeout, MemoryLimit);
686686 if (RemoteClientStatus != 0) {
687 std::cerr << "Remote Client failed with an error: " <<
688 RemoteClientStatus << ".\n" << std::flush;
687 errs() << "Remote Client failed with an error: " <<
688 RemoteClientStatus << ".\n";
689689 }
690690 }
691691
698698 sys::Path uniqueFilename(InputFile+LTDL_SHLIB_EXT);
699699 std::string ErrMsg;
700700 if (uniqueFilename.makeUnique(true, &ErrMsg)) {
701 std::cerr << "Error making unique filename: " << ErrMsg << "\n";
701 errs() << "Error making unique filename: " << ErrMsg << "\n";
702702 exit(1);
703703 }
704704 OutputFile = uniqueFilename.toString();
756756
757757
758758 std::cout << "" << std::flush;
759 DEBUG(std::cerr << "\nAbout to run:\t";
759 DEBUG(errs() << "\nAbout to run:\t";
760760 for (unsigned i=0, e = GCCArgs.size()-1; i != e; ++i)
761 std::cerr << " " << GCCArgs[i];
762 std::cerr << "\n";
761 errs() << " " << GCCArgs[i];
762 errs() << "\n";
763763 );
764764 if (RunProgramWithTimeout(GCCPath, &GCCArgs[0], sys::Path(), sys::Path(),
765765 sys::Path())) {
8686 try {
8787 return D.run();
8888 } catch (ToolExecutionError &TEE) {
89 std::cerr << "Tool execution error: " << TEE.what() << '\n';
89 errs() << "Tool execution error: " << TEE.what() << '\n';
9090 } catch (const std::string& msg) {
91 std::cerr << argv[0] << ": " << msg << "\n";
91 errs() << argv[0] << ": " << msg << "\n";
9292 } catch (const std::bad_alloc &e) {
93 std::cerr << "Oh no, a bugpoint process ran out of memory!\n"
94 "To increase the allocation limits for bugpoint child\n"
95 "processes, use the -mlimit option.\n";
93 errs() << "Oh no, a bugpoint process ran out of memory!\n"
94 "To increase the allocation limits for bugpoint child\n"
95 "processes, use the -mlimit option.\n";
9696 } catch (const std::exception &e) {
97 std::cerr << "Whoops, a std::exception leaked out of bugpoint: "
98 << e.what() << "\n"
99 << "This is a bug in bugpoint!\n";
97 errs() << "Whoops, a std::exception leaked out of bugpoint: "
98 << e.what() << "\n"
99 << "This is a bug in bugpoint!\n";
100100 } catch (...) {
101 std::cerr << "Whoops, an exception leaked out of bugpoint. "
102 << "This is a bug in bugpoint!\n";
101 errs() << "Whoops, an exception leaked out of bugpoint. "
102 << "This is a bug in bugpoint!\n";
103103 }
104104 return 1;
105105 }
136136 // Specified an output filename?
137137 if (!Force && std::ifstream(OutputFilename.c_str())) {
138138 // If force is not specified, make sure not to overwrite a file!
139 std::cerr << ProgName << ": error opening '" << OutputFilename
140 << "': file exists!\n"
141 << "Use -f command line argument to force output\n";
139 errs() << ProgName << ": error opening '" << OutputFilename
140 << "': file exists!\n"
141 << "Use -f command line argument to force output\n";
142142 return 0;
143143 }
144144 // Make sure that the Out file gets unlinked from the disk if we get a
151151 formatted_raw_ostream *Out =
152152 new formatted_raw_ostream(*FDOut, formatted_raw_ostream::DELETE_STREAM);
153153 if (!error.empty()) {
154 std::cerr << error << '\n';
154 errs() << error << '\n';
155155 delete Out;
156156 return 0;
157157 }
191191
192192 if (!Force && std::ifstream(OutputFilename.c_str())) {
193193 // If force is not specified, make sure not to overwrite a file!
194 std::cerr << ProgName << ": error opening '" << OutputFilename
195 << "': file exists!\n"
196 << "Use -f command line argument to force output\n";
194 errs() << ProgName << ": error opening '" << OutputFilename
195 << "': file exists!\n"
196 << "Use -f command line argument to force output\n";
197197 return 0;
198198 }
199199
207207 formatted_raw_ostream *Out =
208208 new formatted_raw_ostream(*FDOut, formatted_raw_ostream::DELETE_STREAM);
209209 if (!error.empty()) {
210 std::cerr << error << '\n';
210 errs() << error << '\n';
211211 delete Out;
212212 return 0;
213213 }
236236 if (Buffer.get())
237237 M.reset(ParseBitcodeFile(Buffer.get(), Context, &ErrorMessage));
238238 if (M.get() == 0) {
239 std::cerr << argv[0] << ": bitcode didn't read correctly.\n";
240 std::cerr << "Reason: " << ErrorMessage << "\n";
239 errs() << argv[0] << ": bitcode didn't read correctly.\n";
240 errs() << "Reason: " << ErrorMessage << "\n";
241241 return 1;
242242 }
243243 Module &mod = *M.get();
255255 std::string Err;
256256 TheTarget = TargetRegistry::getClosestStaticTargetForModule(mod, Err);
257257 if (TheTarget == 0) {
258 std::cerr << argv[0] << ": error auto-selecting target for module '"
259 << Err << "'. Please use the -march option to explicitly "
260 << "pick a target.\n";
258 errs() << argv[0] << ": error auto-selecting target for module '"
259 << Err << "'. Please use the -march option to explicitly "
260 << "pick a target.\n";
261261 return 1;
262262 }
263263 }
284284 CodeGenOpt::Level OLvl = CodeGenOpt::Default;
285285 switch (OptLevel) {
286286 default:
287 std::cerr << argv[0] << ": invalid optimization level.\n";
287 errs() << argv[0] << ": invalid optimization level.\n";
288288 return 1;
289289 case ' ': break;
290290 case '0': OLvl = CodeGenOpt::None; break;
303303
304304 // Ask the target to add backend passes as necessary.
305305 if (Target.addPassesToEmitWholeFile(PM, *Out, FileType, OLvl)) {
306 std::cerr << argv[0] << ": target does not support generation of this"
307 << " file type!\n";
306 errs() << argv[0] << ": target does not support generation of this"
307 << " file type!\n";
308308 if (Out != &fouts()) delete Out;
309309 // And the Out file is empty and useless, so remove it now.
310310 sys::Path(OutputFilename).eraseFromDisk();
333333 assert(0 && "Invalid file model!");
334334 return 1;
335335 case FileModel::Error:
336 std::cerr << argv[0] << ": target does not support generation of this"
337 << " file type!\n";
336 errs() << argv[0] << ": target does not support generation of this"
337 << " file type!\n";
338338 if (Out != &fouts()) delete Out;
339339 // And the Out file is empty and useless, so remove it now.
340340 sys::Path(OutputFilename).eraseFromDisk();
350350 }
351351
352352 if (Target.addPassesToEmitFileFinish(Passes, OCE, OLvl)) {
353 std::cerr << argv[0] << ": target does not support generation of this"
354 << " file type!\n";
353 errs() << argv[0] << ": target does not support generation of this"
354 << " file type!\n";
355355 if (Out != &fouts()) delete Out;
356356 // And the Out file is empty and useless, so remove it now.
357357 sys::Path(OutputFilename).eraseFromDisk();
111111 }
112112
113113 if (!MP) {
114 std::cerr << argv[0] << ": error loading program '" << InputFile << "': "
115 << ErrorMsg << "\n";
114 errs() << argv[0] << ": error loading program '" << InputFile << "': "
115 << ErrorMsg << "\n";
116116 exit(1);
117117 }
118118
120120 Module *Mod = NoLazyCompilation
121121 ? MP->materializeModule(&ErrorMsg) : MP->getModule();
122122 if (!Mod) {
123 std::cerr << argv[0] << ": bitcode didn't read correctly.\n";
124 std::cerr << "Reason: " << ErrorMsg << "\n";
123 errs() << argv[0] << ": bitcode didn't read correctly.\n";
124 errs() << "Reason: " << ErrorMsg << "\n";
125125 exit(1);
126126 }
127127
132132 CodeGenOpt::Level OLvl = CodeGenOpt::Default;
133133 switch (OptLevel) {
134134 default:
135 std::cerr << argv[0] << ": invalid optimization level.\n";
135 errs() << argv[0] << ": invalid optimization level.\n";
136136 return 1;
137137 case ' ': break;
138138 case '0': OLvl = CodeGenOpt::None; break;
148148 EE = ExecutionEngine::create(MP, ForceInterpreter, &ErrorMsg, OLvl);
149149 if (!EE) {
150150 if (!ErrorMsg.empty())
151 std::cerr << argv[0] << ": error creating EE: " << ErrorMsg << "\n";
151 errs() << argv[0] << ": error creating EE: " << ErrorMsg << "\n";
152152 else
153 std::cerr << argv[0] << ": unknown error creating EE!\n";
153 errs() << argv[0] << ": unknown error creating EE!\n";
154154 exit(1);
155155 }
156156
181181 //
182182 Function *EntryFn = Mod->getFunction(EntryFunc);
183183 if (!EntryFn) {
184 std::cerr << '\'' << EntryFunc << "\' function not found in module.\n";
184 errs() << '\'' << EntryFunc << "\' function not found in module.\n";
185185 return -1;
186186 }
187187
218218 ResultGV.IntVal = APInt(32, Result);
219219 Args.push_back(ResultGV);
220220 EE->runFunction(ExitF, Args);
221 std::cerr << "ERROR: exit(" << Result << ") returned!\n";
221 errs() << "ERROR: exit(" << Result << ") returned!\n";
222222 abort();
223223 } else {
224 std::cerr << "ERROR: exit defined with wrong prototype!\n";
224 errs() << "ERROR: exit defined with wrong prototype!\n";
225225 abort();
226226 }
227227 }
1717 #include "llvm/Support/CommandLine.h"
1818 #include "llvm/Support/ManagedStatic.h"
1919 #include "llvm/Support/PrettyStackTrace.h"
20 #include "llvm/Support/raw_ostream.h"
2021 #include "llvm/System/Signals.h"
2122 #include
2223 #include
717718 if (!ArchivePath.exists()) {
718719 // Produce a warning if we should and we're creating the archive
719720 if (!Create)
720 std::cerr << argv[0] << ": creating " << ArchivePath.toString() << "\n";
721 errs() << argv[0] << ": creating " << ArchivePath.toString() << "\n";
721722 TheArchive = Archive::CreateEmpty(ArchivePath, Context);
722723 TheArchive->writeToDisk();
723724 } else {
724725 std::string Error;
725726 TheArchive = Archive::OpenAndLoad(ArchivePath, Context, &Error);
726727 if (TheArchive == 0) {
727 std::cerr << argv[0] << ": error loading '" << ArchivePath << "': "
728 << Error << "!\n";
728 errs() << argv[0] << ": error loading '" << ArchivePath << "': "
729 << Error << "!\n";
729730 return 1;
730731 }
731732 }
748749 case DisplayTable: haveError = doDisplayTable(&ErrMsg); break;
749750 case Extract: haveError = doExtract(&ErrMsg); break;
750751 case NoOperation:
751 std::cerr << argv[0] << ": No operation was selected.\n";
752 errs() << argv[0] << ": No operation was selected.\n";
752753 break;
753754 }
754755 if (haveError) {
755 std::cerr << argv[0] << ": " << ErrMsg << "\n";
756 errs() << argv[0] << ": " << ErrMsg << "\n";
756757 return 1;
757758 }
758759 } catch (const char*msg) {
759760 // These errors are usage errors, thrown only by the various checks in the
760761 // code above.
761 std::cerr << argv[0] << ": " << msg << "\n\n";
762 errs() << argv[0] << ": " << msg << "\n\n";
762763 cl::PrintHelpMessage();
763764 exitCode = 1;
764765 } catch (const std::string& msg) {
765766 // These errors are thrown by LLVM libraries (e.g. lib System) and represent
766767 // a more serious error so we bump the exitCode and don't print the usage.
767 std::cerr << argv[0] << ": " << msg << "\n";
768 errs() << argv[0] << ": " << msg << "\n";
768769 exitCode = 2;
769770 } catch (...) {
770771 // This really shouldn't happen, but just in case ....
771 std::cerr << argv[0] << ": An unexpected unknown exception occurred.\n";
772 errs() << argv[0] << ": An unexpected unknown exception occurred.\n";
772773 exitCode = 3;
773774 }
774775
288288 /// Error - All bitcode analysis errors go through this function, making this a
289289 /// good place to breakpoint if debugging.
290290 static bool Error(const std::string &Err) {
291 std::cerr << Err << "\n";
291 errs() << Err << "\n";
292292 return true;
293293 }
294294
305305
306306 // BLOCKINFO is a special part of the stream.
307307 if (BlockID == bitc::BLOCKINFO_BLOCK_ID) {
308 if (Dump) std::cerr << Indent << "\n";
308 if (Dump) errs() << Indent << "\n";
309309 if (Stream.ReadBlockInfoBlock())
310310 return Error("Malformed BlockInfoBlock");
311311 uint64_t BlockBitEnd = Stream.GetCurrentBitNo();
319319
320320 const char *BlockName = 0;
321321 if (Dump) {
322 std::cerr << Indent << "<";
322 errs() << Indent << "<";
323323 if ((BlockName = GetBlockName(BlockID, *Stream.getBitStreamReader())))
324 std::cerr << BlockName;
324 errs() << BlockName;
325325 else
326 std::cerr << "UnknownBlock" << BlockID;
326 errs() << "UnknownBlock" << BlockID;
327327
328328 if (NonSymbolic && BlockName)
329 std::cerr << " BlockID=" << BlockID;
330
331 std::cerr << " NumWords=" << NumWords
332 << " BlockCodeSize=" << Stream.GetAbbrevIDWidth() << ">\n";
329 errs() << " BlockID=" << BlockID;
330
331 errs() << " NumWords=" << NumWords
332 << " BlockCodeSize=" << Stream.GetAbbrevIDWidth() << ">\n";
333333 }
334334
335335 SmallVector Record;
350350 uint64_t BlockBitEnd = Stream.GetCurrentBitNo();
351351 BlockStats.NumBits += BlockBitEnd-BlockBitStart;
352352 if (Dump) {
353 std::cerr << Indent << "
353 errs() << Indent << "
354354 if (BlockName)
355 std::cerr << BlockName << ">\n";
355 errs() << BlockName << ">\n";
356356 else
357 std::cerr << "UnknownBlock" << BlockID << ">\n";
357 errs() << "UnknownBlock" << BlockID << ">\n";
358358 }
359359 return false;
360360 }
396396 BlockStats.CodeFreq[Code].NumAbbrev++;
397397
398398 if (Dump) {
399 std::cerr << Indent << " <";
399 errs() << Indent << " <";
400400 if (const char *CodeName =
401401 GetCodeName(Code, BlockID, *Stream.getBitStreamReader()))
402 std::cerr << CodeName;
402 errs() << CodeName;
403403 else
404 std::cerr << "UnknownCode" << Code;
404 errs() << "UnknownCode" << Code;
405405 if (NonSymbolic &&
406406 GetCodeName(Code, BlockID, *Stream.getBitStreamReader()))
407 std::cerr << " codeid=" << Code;
407 errs() << " codeid=" << Code;
408408 if (AbbrevID != bitc::UNABBREV_RECORD)
409 std::cerr << " abbrevid=" << AbbrevID;
409 errs() << " abbrevid=" << AbbrevID;
410410
411411 for (unsigned i = 0, e = Record.size(); i != e; ++i)
412 std::cerr << " op" << i << "=" << (int64_t)Record[i];
413
414 std::cerr << "/>";
412 errs() << " op" << i << "=" << (int64_t)Record[i];
413
414 errs() << "/>";
415415
416416 if (BlobStart) {
417 std::cerr << " blob data = ";
417 errs() << " blob data = ";
418418 bool BlobIsPrintable = true;
419419 for (unsigned i = 0; i != BlobLen; ++i)
420420 if (!isprint(BlobStart[i])) {
423423 }
424424
425425 if (BlobIsPrintable)
426 std::cerr << "'" << std::string(BlobStart, BlobStart+BlobLen) <<"'";
426 errs() << "'" << std::string(BlobStart, BlobStart+BlobLen) <<"'";
427427 else
428 std::cerr << "unprintable, " << BlobLen << " bytes.";
428 errs() << "unprintable, " << BlobLen << " bytes.";
429429 }
430430
431 std::cerr << "\n";
431 errs() << "\n";
432432 }
433433
434434 break;
498498 ++NumTopBlocks;
499499 }
500500
501 if (Dump) std::cerr << "\n\n";
501 if (Dump) errs() << "\n\n";
502502
503503 uint64_t BufferSizeBits = (EndBufPtr-BufPtr)*CHAR_BIT;
504504 // Print a summary of the read file.
505 std::cerr << "Summary of " << InputFilename << ":\n";
506 std::cerr << " Total size: ";
505 errs() << "Summary of " << InputFilename << ":\n";
506 errs() << " Total size: ";
507507 PrintSize(BufferSizeBits);
508 std::cerr << "\n";
509 std::cerr << " Stream type: ";
508 errs() << "\n";
509 errs() << " Stream type: ";
510510 switch (CurStreamType) {
511511 default: assert(0 && "Unknown bitstream type");
512 case UnknownBitstream: std::cerr << "unknown\n"; break;
513 case LLVMIRBitstream: std::cerr << "LLVM IR\n"; break;
514 }
515 std::cerr << " # Toplevel Blocks: " << NumTopBlocks << "\n";
516 std::cerr << "\n";
512 case UnknownBitstream: errs() << "unknown\n"; break;
513 case LLVMIRBitstream: errs() << "LLVM IR\n"; break;
514 }
515 errs() << " # Toplevel Blocks: " << NumTopBlocks << "\n";
516 errs() << "\n";
517517
518518 // Emit per-block stats.
519 std::cerr << "Per-block Summary:\n";
519 errs() << "Per-block Summary:\n";
520520 for (std::map::iterator I = BlockIDStats.begin(),
521521 E = BlockIDStats.end(); I != E; ++I) {
522 std::cerr << " Block ID #" << I->first;
522 errs() << " Block ID #" << I->first;
523523 if (const char *BlockName = GetBlockName(I->first, StreamFile))
524 std::cerr << " (" << BlockName << ")";
525 std::cerr << ":\n";
524 errs() << " (" << BlockName << ")";
525 errs() << ":\n";
526526
527527 const PerBlockIDStats &Stats = I->second;
528 std::cerr << " Num Instances: " << Stats.NumInstances << "\n";
529 std::cerr << " Total Size: ";
528 errs() << " Num Instances: " << Stats.NumInstances << "\n";
529 errs() << " Total Size: ";
530530 PrintSize(Stats.NumBits);
531 std::cerr << "\n";
532 std::cerr << " % of file: "
533 << Stats.NumBits/(double)BufferSizeBits*100 << "\n";
531 errs() << "\n";
532 errs() << " % of file: "
533 << Stats.NumBits/(double)BufferSizeBits*100 << "\n";
534534 if (Stats.NumInstances > 1) {
535 std::cerr << " Average Size: ";
535 errs() << " Average Size: ";
536536 PrintSize(Stats.NumBits/(double)Stats.NumInstances);
537 std::cerr << "\n";
538 std::cerr << " Tot/Avg SubBlocks: " << Stats.NumSubBlocks << "/"
539 << Stats.NumSubBlocks/(double)Stats.NumInstances << "\n";
540 std::cerr << " Tot/Avg Abbrevs: " << Stats.NumAbbrevs << "/"
541 << Stats.NumAbbrevs/(double)Stats.NumInstances << "\n";
542 std::cerr << " Tot/Avg Records: " << Stats.NumRecords << "/"
543 << Stats.NumRecords/(double)Stats.NumInstances << "\n";
537 errs() << "\n";
538 errs() << " Tot/Avg SubBlocks: " << Stats.NumSubBlocks << "/"
539 << Stats.NumSubBlocks/(double)Stats.NumInstances << "\n";
540 errs() << " Tot/Avg Abbrevs: " << Stats.NumAbbrevs << "/"
541 << Stats.NumAbbrevs/(double)Stats.NumInstances << "\n";
542 errs() << " Tot/Avg Records: " << Stats.NumRecords << "/"
543 << Stats.NumRecords/(double)Stats.NumInstances << "\n";
544544 } else {
545 std::cerr << " Num SubBlocks: " << Stats.NumSubBlocks << "\n";
546 std::cerr << " Num Abbrevs: " << Stats.NumAbbrevs << "\n";
547 std::cerr << " Num Records: " << Stats.NumRecords << "\n";
545 errs() << " Num SubBlocks: " << Stats.NumSubBlocks << "\n";
546 errs() << " Num Abbrevs: " << Stats.NumAbbrevs << "\n";
547 errs() << " Num Records: " << Stats.NumRecords << "\n";
548548 }
549549 if (Stats.NumRecords)
550 std::cerr << " % Abbrev Recs: " << (Stats.NumAbbreviatedRecords/
551 (double)Stats.NumRecords)*100 << "\n";
552 std::cerr << "\n";
550 errs() << " % Abbrev Recs: " << (Stats.NumAbbreviatedRecords/
551 (double)Stats.NumRecords)*100 << "\n";
552 errs() << "\n";
553553
554554 // Print a histogram of the codes we see.
555555 if (!NoHistogram && !Stats.CodeFreq.empty()) {
560560 std::stable_sort(FreqPairs.begin(), FreqPairs.end());
561561 std::reverse(FreqPairs.begin(), FreqPairs.end());
562562
563 std::cerr << "\tRecord Histogram:\n";
563 errs() << "\tRecord Histogram:\n";
564564 fprintf(stderr, "\t\t Count # Bits %% Abv Record Kind\n");
565565 for (unsigned i = 0, e = FreqPairs.size(); i != e; ++i) {
566566 const PerRecordStats &RecStats = Stats.CodeFreq[FreqPairs[i].second];
580580 else
581581 fprintf(stderr, "UnknownCode%d\n", FreqPairs[i].second);
582582 }
583 std::cerr << "\n";
583 errs() << "\n";
584584
585585 }
586586 }
499499 if (File == 0)
500500 throw "Unknown file to place breakpoint!";
501501
502 std::cerr << "Break: " << File->getFilename() << ":" << LineNo << "\n";
502 errs() << "Break: " << File->getFilename() << ":" << LineNo << "\n";
503503
504504 throw "breakpoints not implemented yet!";
505505 }
9393 // Now that we have initialized the debugger, run it.
9494 return D.run();
9595 } catch (const std::string& msg) {
96 std::cerr << argv[0] << ": " << msg << "\n";
96 errs() << argv[0] << ": " << msg << "\n";
9797 } catch (...) {
98 std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
98 errs() << argv[0] << ": Unexpected unknown exception occurred.\n";
9999 }
100100 return 1;
101101 }
1717 #include "llvm/Analysis/Verifier.h"
1818 #include "llvm/Support/CommandLine.h"
1919 #include "llvm/Support/StandardPasses.h"
20 #include "llvm/Support/raw_ostream.h"
2021 #include "llvm/System/DynamicLibrary.h"
2122 #include "llvm/Target/TargetData.h"
2223 #include "llvm/Target/TargetMachine.h"
108109 if (Opt->getNormalCtor())
109110 addPass(Passes, Opt->getNormalCtor()());
110111 else
111 std::cerr << "llvm-ld: cannot create pass: " << Opt->getPassName()
112 << "\n";
112 errs() << "llvm-ld: cannot create pass: " << Opt->getPassName()
113 << "\n";
113114 }
114115
115116 // The user's passes may leave cruft around. Clean up after them them but
2323 #include "llvm/Support/ManagedStatic.h"
2424 #include "llvm/Support/MemoryBuffer.h"
2525 #include "llvm/Support/PrettyStackTrace.h"
26 #include "llvm/Support/raw_ostream.h"
2627 #include "llvm/System/Signals.h"
2728 #include
2829 #include
146147 if (Result)
147148 DumpSymbolNamesFromModule(Result);
148149 else {
149 std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
150 errs() << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
150151 return;
151152 }
152153
155156 Archive* archive = Archive::OpenAndLoad(sys::Path(Filename), Context,
156157 &ErrorMessage);
157158 if (!archive)
158 std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
159 errs() << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
159160 std::vector Modules;
160161 if (archive->getAllModules(Modules, &ErrorMessage)) {
161 std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
162 errs() << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
162163 return;
163164 }
164165 MultipleFiles = true;
165166 std::for_each (Modules.begin(), Modules.end(), DumpSymbolNamesFromModule);
166167 } else {
167 std::cerr << ToolName << ": " << Filename << ": "
168 << "unrecognizable file type\n";
168 errs() << ToolName << ": " << Filename << ": "
169 << "unrecognizable file type\n";
169170 return;
170171 }
171172 }
269269 delete Buffer;
270270 }
271271 if (M == 0) {
272 std::cerr << argv[0] << ": " << BitcodeFile << ": "
272 errs() << argv[0] << ": " << BitcodeFile << ": "
273273 << ErrorMessage << "\n";
274274 return 1;
275275 }
288288
289289 return 0;
290290 } catch (const std::string& msg) {
291 std::cerr << argv[0] << ": " << msg << "\n";
291 errs() << argv[0] << ": " << msg << "\n";
292292 } catch (...) {
293 std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
293 errs() << argv[0] << ": Unexpected unknown exception occurred.\n";
294294 }
295295
296296 return 1;
1616 #include "llvm/Support/CommandLine.h"
1717 #include "llvm/Support/ManagedStatic.h"
1818 #include "llvm/Support/PrettyStackTrace.h"
19 #include "llvm/Support/raw_ostream.h"
1920 #include "llvm/System/Signals.h"
2021 #include
2122 #include
8687 printSymbolTable(TheArchive);
8788
8889 } catch (const char* msg) {
89 std::cerr << argv[0] << ": " << msg << "\n\n";
90 errs() << argv[0] << ": " << msg << "\n\n";
9091 exitCode = 1;
9192 } catch (const std::string& msg) {
92 std::cerr << argv[0] << ": " << msg << "\n";
93 errs() << argv[0] << ": " << msg << "\n";
9394 exitCode = 2;
9495 } catch (...) {
95 std::cerr << argv[0] << ": An unexpected unknown exception occurred.\n";
96 errs() << argv[0] << ": An unexpected unknown exception occurred.\n";
9697 exitCode = 3;
9798 }
9899 return exitCode;
2020 #include "llvm/Pass.h"
2121 #include "llvm/Support/CallSite.h"
2222 #include "llvm/Analysis/CallGraph.h"
23 #include "llvm/Support/raw_ostream.h"
2324 #include
2425 using namespace llvm;
2526
4445 E = CS.arg_end(); AI != E; ++AI)
4546 if (isa(*AI)) {
4647 if (!PrintedFn) {
47 std::cerr << "Function '" << I->getName() << "':\n";
48 errs() << "Function '" << I->getName() << "':\n";
4849 PrintedFn = true;
4950 }
50 std::cerr << *User;
51 errs() << *User;
5152 break;
5253 }
5354 }