aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-as/llvm-as.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-11-11Split Bitcode/ReaderWriter.h into separate reader and writer headersTeresa Johnson1-1/+1
Summary: Split ReaderWriter.h which contains the APIs into both the BitReader and BitWriter libraries into BitcodeReader.h and BitcodeWriter.h. This is to address Chandler's concern about sharing the same API header between multiple libraries (BitReader and BitWriter). That concern is why we create a single bitcode library in our downstream build of clang, which led to r286297 being reverted as it added a dependency that created a cycle only when there is a single bitcode library (not two as in upstream). Reviewers: mehdi_amini Subscribers: dlj, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D26502 llvm-svn: 286566
2016-06-09Search for llvm-symbolizer binary in the same directory as argv[0], beforeRichard Smith1-1/+1
looking for it along $PATH. This allows installs of LLVM tools outside of $PATH to find the symbolizer and produce pretty backtraces if they crash. llvm-svn: 272232
2016-04-14Remove every uses of getGlobalContext() in LLVM (but the C API)Mehdi Amini1-1/+1
At the same time, fixes InstructionsTest::CastInst unittest: yes you can leave the IR in an invalid state and exit when you don't destroy the context (like the global one), no longer now. This is the first part of http://reviews.llvm.org/D19094 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266379
2016-04-12Move summary creation out of llvm-as into optMehdi Amini1-12/+2
Summary: Let keep llvm-as "dumb": it converts textual IR to bitcode. This commit removes the dependency from llvm-as to libLLVMAnalysis. We'll add back summary in llvm-as if we get to a textual representation for it at some point. In the meantime, opt seems like a better place for that. Reviewers: tejohnson Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D19032 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266131
2016-04-11[ThinLTO] Move summary computation from BitcodeWriter to new passTeresa Johnson1-3/+9
Summary: This is the first step in also serializing the index out to LLVM assembly. The per-module summary written to bitcode is moved out of the bitcode writer and to a new analysis pass (ModuleSummaryIndexWrapperPass). The pass itself uses a new builder class to compute index, and the builder class is used directly in places where we don't have a pass manager (e.g. llvm-as). Because we are computing summaries outside of the bitcode writer, we no longer can use value ids created by the bitcode writer's ValueEnumerator. This required changing the reference graph edge type to use a new ValueInfo class holding a union between a GUID (combined index) and Value* (permodule index). The Value* are converted to the appropriate value ID during bitcode writing. Also, this enables removal of the BitWriter library's dependence on the Analysis library that was previously required for the summary computation. Reviewers: joker.eph Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D18763 llvm-svn: 265941
2016-04-04clang-format llvm-as.cpp (NFC)Teresa Johnson1-16/+17
This reduces unrelated changes in other patches (such as D18763) when changes to this file are clang formatted. llvm-svn: 265346
2016-04-01Add a module Hash in the bitcode and the combined index, implementing a kind ↵Mehdi Amini1-1/+4
of "build-id" This is intended to be used for ThinLTO incremental build. Differential Revision: http://reviews.llvm.org/D18213 This is a recommit of r265095 after fixing the Windows issues. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265111
2016-04-01Revert "Add support for computing SHA1 in LLVM"Mehdi Amini1-4/+1
This reverts commit r265096, r265095, and r265094. Windows build is broken, and the validation does not pass. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265102
2016-04-01Add a module Hash in the bitcode and the combined index, implementing a kind ↵Mehdi Amini1-1/+4
of "build-id" This is intended to be used for ThinLTO incremental build. Differential Revision: http://reviews.llvm.org/D18213 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 265095
2016-03-15[ThinLTO] Renaming of function index to module summary index (NFC)Teresa Johnson1-4/+4
(Resubmitting after fixing missing file issue) With the changes in r263275, there are now more than just functions in the summary. Completed the renaming of data structures (started in r263275) to reflect the wider scope. In particular, changed the FunctionIndex* data structures to ModuleIndex*, and renamed related variables and comments. Also renamed the files to reflect the changes. A companion clang patch will immediately succeed this patch to reflect this renaming. llvm-svn: 263513
2016-03-14Revert "[ThinLTO] Renaming of function index to module summary index (NFC)"Teresa Johnson1-4/+4
This reverts commit r263490. Missed a file. llvm-svn: 263493
2016-03-14[ThinLTO] Renaming of function index to module summary index (NFC)Teresa Johnson1-4/+4
With the changes in r263275, there are now more than just functions in the summary. Completed the renaming of data structures (started in r263275) to reflect the wider scope. In particular, changed the FunctionIndex* data structures to ModuleIndex*, and renamed related variables and comments. Also renamed the files to reflect the changes. A companion clang patch will immediately succeed this patch to reflect this renaming. llvm-svn: 263490
2015-10-04Support for function summary index bitcode sections and files.Teresa Johnson1-1/+6
Summary: The bitcode format is described in this document: https://drive.google.com/file/d/0B036uwnWM6RWdnBLakxmeDdOeXc/view For more info on ThinLTO see: https://sites.google.com/site/llvmthinlto The first customer is ThinLTO, however the data structures are designed and named more generally based on prior feedback. There are a few comments regarding how certain interfaces are used by ThinLTO, and the options added here to gold currently have ThinLTO-specific names as the behavior they provoke is currently ThinLTO-specific. This patch includes support for generating per-module function indexes, the combined index file via the gold plugin, and several tests (more are included with the associated clang patch D11908). Reviewers: dexonsmith, davidxl, joker.eph Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13107 llvm-svn: 249270
2015-05-11Fix input validation issues in llvm-as/llvm-disAlexey Samsonov1-8/+2
Summary: 1. llvm-as/llvm-dis tools do not check for input filename length. 2. llvm-dis does not verify the `Streamer` variable against `nullptr` properly, so the `M` variable could be uninitialized (e.g. if the input file does not exist) leading to null dref. Patch by Lenar Safin! Reviewers: samsonov Reviewed By: samsonov Subscribers: samsonov, llvm-commits Differential Revision: http://reviews.llvm.org/D9584 llvm-svn: 237051
2015-04-15uselistorder: Remove the global bitsDuncan P. N. Exon Smith1-7/+6
Remove all the global bits to do with preserving use-list order by moving the `cl::opt`s to the individual tools that want them. There's a minor functionality change to `libLTO`, in that you can't send in `-preserve-bc-uselistorder=false`, but making that bit settable (if it's worth doing) should be through explicit LTO API. As a drive-by fix, I removed some includes of `UseListOrder.h` that were made unnecessary by recent commits. llvm-svn: 234973
2015-04-15uselistorder: Pull the bit through WriteToBitcodFile()Duncan P. N. Exon Smith1-1/+1
Change the callers of `WriteToBitcodeFile()` to pass `true` or `shouldPreserveBitcodeUseListOrder()` explicitly. I left the callers that want to send `false` alone. I'll keep pushing the bit higher until hopefully I can delete the global `cl::opt` entirely. llvm-svn: 234957
2015-04-14IR: Set -preserve-bc-uselistorder=false by defaultDuncan P. N. Exon Smith1-0/+6
But keep it on by default in `llvm-as`, `opt`, `bugpoint`, `llvm-link`, `llvm-extract`, and `LTOCodeGenerator`. Part of PR5680. llvm-svn: 234921
2014-08-25Modernize raw_fd_ostream's constructor a bit.Rafael Espindola1-4/+4
Take a StringRef instead of a "const char *". Take a "std::error_code &" instead of a "std::string &" for error. A create static method would be even better, but this patch is already a bit too big. llvm-svn: 216393
2014-08-19Modernize the .ll parsing interface.Rafael Espindola1-1/+1
* Use StringRef instead of std::string& * Return a std::unique_ptr<Module> instead of taking an optional module to write to (was not really used). * Use current comment style. * Use current naming convention. llvm-svn: 215989
2014-04-29raw_ostream: Forward declare OpenFlags and include FileSystem.h only where ↵Benjamin Kramer1-0/+1
necessary. llvm-svn: 207593
2014-04-25[C++] Use 'nullptr'. Tools edition.Craig Topper1-1/+1
llvm-svn: 207176
2014-03-06Replace OwningPtr<T> with std::unique_ptr<T>.Ahmed Charles1-3/+3
This compiles with no changes to clang/lld/lldb with MSVC and includes overloads to various functions which are used by those projects and llvm which have OwningPtr's as parameters. This should allow out of tree projects some time to move. There are also no changes to libs/Target, which should help out of tree targets have time to move, if necessary. llvm-svn: 203083
2014-02-24Replace the F_Binary flag with a F_Text one.Rafael Espindola1-1/+1
After this I will set the default back to F_None. The advantage is that before this patch forgetting to set F_Binary would corrupt a file on windows. Forgetting to set F_Text produces one that cannot be read in notepad, which is a better failure mode :-) llvm-svn: 202052
2014-01-19[PM] Make the verifier work independently of any pass manager.Chandler Carruth1-3/+4
This makes the 'verifyFunction' and 'verifyModule' functions totally independent operations on the LLVM IR. It also cleans up their API a bit by lifting the abort behavior into their clients and just using an optional raw_ostream parameter to control printing. The implementation of the verifier is now just an InstVisitor with no multiple inheritance. It also is significantly more const-correct, and hides the const violations internally. The two layers that force us to break const correctness are building a DomTree and dispatching through the InstVisitor. A new VerifierPass is used to implement the legacy pass manager interface in terms of the other pieces. The error messages produced may be slightly different now, and we may have slightly different short circuiting behavior with different usage models of the verifier, but generally everything works equivalently and this unblocks wiring the verifier up to the new pass manager. llvm-svn: 199569
2014-01-13[cleanup] Move the Dominators.h and Verifier.h headers into the IRChandler Carruth1-1/+1
directory. These passes are already defined in the IR library, and it doesn't make any sense to have the headers in Analysis. Long term, I think there is going to be a much better way to divide these matters. The dominators code should be fully separated into the abstract graph algorithm and have that put in Support where it becomes obvious that evn Clang's CFGBlock's can use it. Then the verifier can manually construct dominance information from the Support-driven interface while the Analysis library can provide a pass which both caches, reconstructs, and supports a nice update API. But those are very long term, and so I don't want to leave the really confusing structure until that day arrives. llvm-svn: 199082
2014-01-07Move the LLVM IR asm writer header files into the IR directory, as theyChandler Carruth1-1/+1
are part of the core IR library in order to support dumping and other basic functionality. Rename the 'Assembly' include directory to 'AsmParser' to match the library name and the only functionality left their -- printing has been in the core IR library for quite some time. Update all of the #includes to match. All of this started because I wanted to have the layering in good shape before I started adding support for printing LLVM IR using the new pass infrastructure, and commandline support for the new pass infrastructure. llvm-svn: 198688
2013-09-19Revert "Encapsulate PassManager debug flags to avoid static init and cxa_exit."Andrew Trick1-5/+0
Working on a better solution to this. This reverts commit 7d4e9934e7ca83094c5cf41346966c8350179ff2. llvm-svn: 190990
2013-09-18Encapsulate PassManager debug flags to avoid static init and cxa_exit.Andrew Trick1-0/+5
This puts all the global PassManager debugging flags, like -print-after-all and -time-passes, behind a managed static. This eliminates their static initializers and, more importantly, exit-time destructors. The only behavioral change I anticipate is that tools need to initialize the PassManager before parsing the command line in order to export these options, which makes sense. Tools that already initialize the standard passes (opt/llc) don't need to do anything new. llvm-svn: 190974
2013-07-16Add a wrapper for open.Rafael Espindola1-3/+2
This centralizes the handling of O_BINARY and opens the way for hiding more differences (like how open behaves with directories). llvm-svn: 186447
2013-04-12Replace uses of the deprecated std::auto_ptr with OwningPtr.Andy Gibbs1-1/+1
llvm-svn: 179373
2013-01-02Move all of the header files which are involved in modelling the LLVM IRChandler Carruth1-2/+2
into their new header subdirectory: include/llvm/IR. This matches the directory structure of lib, and begins to correct a long standing point of file layout clutter in LLVM. There are still more header files to move here, but I wanted to handle them in separate commits to make tracking what files make sense at each layer easier. The only really questionable files here are the target intrinsic tablegen files. But that's a battle I'd rather not fight today. I've updated both CMake and Makefile build systems (I think, and my tests think, but I may have missed something). I've also re-sorted the includes throughout the project. I'll be committing updates to Clang, DragonEgg, and Polly momentarily. llvm-svn: 171366
2012-12-04Sort the #include lines for tools/...Chandler Carruth1-3/+3
Again, tools are trickier to pick the main module header for than library source files. I've started to follow the pattern of using LLVMContext.h when it is included as a stub for program source files. llvm-svn: 169252
2011-10-16Enhance llvm::SourceMgr to support diagnostic ranges, the same way clang ↵Chris Lattner1-1/+1
does. Enhance the X86 asmparser to produce ranges in the one case that was annoying me, for example: test.s:10:15: error: invalid operand for instruction movl 0(%rax), 0(%edx) ^~~~~~~ It should be straight-forward to enhance filecheck, tblgen, and/or the .ll parser to use ranges where appropriate if someone is interested. llvm-svn: 142106
2010-11-29Merge System into Support.Michael J. Spencer1-1/+1
llvm-svn: 120298
2010-10-07Move tool_output_file into its own file.Dan Gohman1-1/+1
llvm-svn: 115973
2010-09-01Make tool_output_file's raw_ostream instance a member variable insteadDan Gohman1-2/+2
of a base class. This makes it possible to unregister the file from FilesToRemove when the file is done. Also, this eliminates the need for formatted_tool_output_file. llvm-svn: 112706
2010-08-20Use the new tool_output_file in several tools. This fixes a varietyDan Gohman1-8/+6
of problems with output files being left behind or output streams being left unclosed. Fix llvm-mc to respect the -o option in all modes, rather than hardcoding outs() in some cases. llvm-svn: 111603
2009-10-17llvm-as: Simplify, and don't create empty output files with -disable-output.Daniel Dunbar1-31/+35
llvm-svn: 84304
2009-09-11Fix llvm-extract's "writing bitcode to a terminal" warning, which wasn'tDan Gohman1-7/+6
working. To support this, add an is_displayed() function to raw_ostream, and generalize Process::StandardOutIsDisplayed and friends in order to support it. Also, call RemoveFileOnSignal before creating a file instead of after, so that the file isn't left behind if the program is interrupted between when the file is created and RemoveFileOnSignal is called. While here, add a -S to llvm-extract and port it to IRReader so that it supports assembly input. llvm-svn: 81568
2009-08-25Make LLVM command-line tools overwrite their output files without -f.Dan Gohman1-4/+1
This is conventional command-line tool behavior. -f now just means "enable binary output on terminals". Add a -f option to llvm-extract and llvm-link, for consistency. Remove F_Force from raw_fd_ostream and enable overwriting and truncating by default. Introduce an F_Excl flag to permit users to enable a failure when the file already exists. This flag is currently unused. Update Makefiles and documentation accordingly. llvm-svn: 79990
2009-08-23eliminate the ostream version of CheckBitcodeOutputToConsole,Chris Lattner1-1/+1
change the raw_ostream one to take the raw_ostream byref instead of byptr. Prune #includes, eliminate a use of Streams.h llvm-svn: 79863
2009-08-23Change raw_fd_ostream to take flags as an optional bitmask Chris Lattner1-75/+51
instead of as two bools. Use this to add a F_Append flag which has the obvious behavior. Other unrelated changes conflated into this patch: 1. REmove EH stuff from llvm-dis and llvm-as, the try blocks are dead. 2. Simplify the filename inference code in llvm-as/llvm-dis, because raw_fd_ostream does the right thing with '-'. 3. Switch machine verifier to use raw_ostream instead of ostream (Which is the thing that needed append in the first place). llvm-svn: 79807
2009-07-16Convert more tools code from cerr and cout to errs() and outs().Dan Gohman1-7/+6
llvm-svn: 76070
2009-07-15To simplify the upcoming context-on-type change, switch all command line ↵Owen Anderson1-1/+1
tools to using the default global context for now. This will let us to hardwire stuff to the global context in the short term while the API is sorted out. llvm-svn: 75846
2009-07-15Add a Force option to raw_fd_ostream to specify whether openingDan Gohman1-27/+21
an existing file is considered an error. Convert several tools to use raw_fd_ostream instead of std::ostream, and to use this new option instead of doing a manual check. llvm-svn: 75801
2009-07-02switch the .ll parser into SMDiagnostic.Chris Lattner1-2/+3
llvm-svn: 74734
2009-07-01Hold the LLVMContext by reference rather than by pointer.Owen Anderson1-1/+1
llvm-svn: 74640
2009-07-01Add a pointer to the owning LLVMContext to Module. This requires threading ↵Owen Anderson1-1/+3
LLVMContext through a lot of the bitcode reader and ASM parser APIs, as well as supporting it in all of the tools. Patches for Clang and LLVM-GCC to follow. llvm-svn: 74614
2009-03-06Change various llvm utilities to use PrettyStackTraceProgram inChris Lattner1-2/+5
their main routines. This makes the tools print their argc/argv commands if they crash. llvm-svn: 66248
2009-01-02Reimplement the old and horrible bison parser for .ll files with a niceChris Lattner1-2/+3
and clean recursive descent parser. This change has a couple of ramifications: 1. The parser code is about 400 lines shorter (in what we maintain, not including what is autogenerated). 2. The code should be significantly faster than the old code because we don't have to work around bison's poor handling of datatypes with ctors/dtors. This also makes the code much more resistant to memory leaks. 3. We now get caret diagnostics from the .ll parser, woo. 4. The actual diagnostics emited from the parser are completely different so a bunch of testcases had to be updated. 5. I now disallow "%ty = type opaque %ty = type i32". There was no good reason to support this, it was just an accident of the old implementation. I have no reason to think that anyone is actually using this. 6. The syntax for sticking a global variable has changed to make it unambiguous. I don't think anyone is depending on this since only clang supports this and it is not solid yet, so I'm not worried about anything breaking. 7. This gets rid of the last use of bison, and along with it the .cvs files. I'll prune this from the makefiles as a subsequent commit. There are a few minor cleanups that can be done after this commit (suggestions welcome!) but this passes dejagnu testing and is ready for its time in the limelight. llvm-svn: 61558