aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Object/IRObjectFile.cpp
AgeCommit message (Collapse)AuthorFilesLines
2016-09-16[IRObjectFile] Turn llvm_unreachable("foo") into something more explicative.Davide Italiano1-1/+1
llvm-svn: 281742
2016-09-15[IRObjectFile] Handle undefined weak symbols in RecordStreamer.Davide Italiano1-1/+4
Differential Revision: https://reviews.llvm.org/D24594 llvm-svn: 281629
2016-08-11Restore "Resolution-based LTO API."Teresa Johnson1-1/+1
This restores commit r278330, with fixes for a few bot failures: - Fix a late change I had made to the save temps output file that I missed due to existing files sitting on my disk - Fix a bunch of Windows bot failures with "ambiguous call to overloaded function" due to confusion between llvm::make_unique vs std::make_unique (preface the new make_unique calls with "llvm::") - Attempt to fix a modules bot failure by adding a missing include to LTO/Config.h. Original change: Resolution-based LTO API. Summary: This introduces a resolution-based LTO API. The main advantage of this API over existing APIs is that it allows the linker to supply a resolution for each symbol in each object, rather than the combined object as a whole. This will become increasingly important for use cases such as ThinLTO which require us to process symbol resolutions in a more complicated way than just adjusting linkage. Patch by Peter Collingbourne. Reviewers: rafael, tejohnson, mehdi_amini Subscribers: lhames, tejohnson, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D20268 llvm-svn: 278338
2016-08-11Revert "Resolution-based LTO API."Teresa Johnson1-1/+1
This reverts commit r278330. I made a change to the save temps output that is causing issues with the bots. Didn't realize this because I had older output files sitting on disk in my test output directory. llvm-svn: 278331
2016-08-11Resolution-based LTO API.Teresa Johnson1-1/+1
Summary: This introduces a resolution-based LTO API. The main advantage of this API over existing APIs is that it allows the linker to supply a resolution for each symbol in each object, rather than the combined object as a whole. This will become increasingly important for use cases such as ThinLTO which require us to process symbol resolutions in a more complicated way than just adjusting linkage. Patch by Peter Collingbourne. Reviewers: rafael, tejohnson, mehdi_amini Subscribers: lhames, tejohnson, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D20268 Address review comments llvm-svn: 278330
2016-07-01function_refify. NFC.Benjamin Kramer1-8/+5
While there use emplace_back to create an expensive pair. llvm-svn: 274344
2016-06-23[IRObjectFile] Try to be defensive, add a break.Davide Italiano1-0/+1
Suggested by Sean Silva. llvm-svn: 273519
2016-06-22[IRObjectFile] Propagate .weak attribute correctly for ASM symbols.Davide Italiano1-0/+3
PR: 28256 Differential Revision: http://reviews.llvm.org/D21616 llvm-svn: 273474
2016-05-18Don't pass a Reloc::Model to MC.Rafael Espindola1-1/+1
MC only needs to know if the output is PIC or not. It never has to decide about creating GOTs and PLTs for example. The only thing that MC itself uses this information for is expanding "macros" in sparc and mips. The rest I am pretty sure could be moved to CodeGen. This is a cleanup and isolates the code from future changes to Reloc::Model. llvm-svn: 269909
2016-05-11Return a StringRef from getSection.Rafael Espindola1-1/+1
This is similar to how getName is handled. llvm-svn: 269218
2016-04-22Clean the API for CollectAsmUndefinedRefs, taking a Triple and a String ↵Mehdi Amini1-5/+3
InlineAsm instead of a Module (NFC) From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 267106
2016-04-22IRObjectFile, clang-format fixup for r267104Mehdi Amini1-4/+5
From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 267105
2016-04-22Use std::move on the enum to insert it into the pair to please MSVCMehdi Amini1-1/+1
(I have no idea why is it needed) Fixup for r267103 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 267104
2016-04-22Refactor IRObjectFile, extract a static CollectAsmUndefinedRefs() method to ↵Mehdi Amini1-4/+15
parse inline assembly (NFC) I plan to call this from ThinLTOCodeGenerator. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 267103
2016-04-06Thread Expected<...> up from createMachOObjectFile() to allow llvm-objdump ↵Kevin Enderby1-2/+2
to produce a real error message Produce the first specific error message for a malformed Mach-O file describing the problem instead of the generic message for object_error::parse_failed of "Invalid data was encountered while parsing the file”.  Many more good error messages will follow after this first one. This is built on Lang Hames’ great work of adding the ’Error' class for structured error handling and threading Error through MachOObjectFile construction. And making createMachOObjectFile return Expected<...> . So to to get the error to the llvm-obdump tool, I changed the stack of these methods to also return Expected<...> : object::ObjectFile::createObjectFile() object::SymbolicFile::createSymbolicFile() object::createBinary() Then finally in ParseInputMachO() in MachODump.cpp the error can be reported and the specific error message can be printed in llvm-objdump and can be seen in the existing test case for the existing malformed binary but with the updated error message. Converting these interfaces to Expected<> from ErrorOr<> does involve touching a number of places. To contain the changes for now use of errorToErrorCode() and errorOrToExpected() are used where the callers are yet to be converted. Also there some were bugs in the existing code that did not deal with the old ErrorOr<> return values. So now with Expected<> since they must be checked and the error handled, I added a TODO and a comment: “// TODO: Actually report errors helpfully” and a call something like consumeError(ObjOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there is one fix also needed to lld/COFF/InputFiles.cpp that goes along with this that I will commit right after this. So expect lld not to built after this commit and before the next one. llvm-svn: 265606
2016-02-29Rename embedded bitcode section in MachOSteven Wu1-4/+1
Summary: Rename the section embeds bitcode from ".llvmbc,.llvmbc" to "__LLVM,__bitcode". The new name matches MachO section naming convention. Reviewers: rafael, pcc Subscribers: davide, llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D17388 llvm-svn: 262245
2016-02-29IRObject: Mark extern_weak as weak.Rafael Espindola1-1/+2
llvm-svn: 262222
2016-02-11Use copy initialization.Rafael Espindola1-2/+2
We can do it since getMemBuffer returns a unique_ptr. llvm-svn: 260576
2016-01-27Move MCTargetAsmParser.h to llvm/MC/MCParser where it belongs.Benjamin Kramer1-1/+1
llvm-svn: 258917
2015-12-14Use diagnostic handler in the LLVMContextRafael Espindola1-1/+1
This patch converts code that has access to a LLVMContext to not take a diagnostic handler. This has a few advantages * It is easier to use a consistent diagnostic handler in a single program. * Less clutter since we are not passing a handler around. It does make it a bit awkward to implement some C APIs that return a diagnostic string. I will propose new versions of these APIs and deprecate the current ones. llvm-svn: 255571
2015-11-10Fix llvm-nm(1) printing of llvm-bitcode files for -format darwin to match ↵Kevin Enderby1-0/+6
darwin’s nm(1). Also a small fix to match printing of Mach-O objects with -format posix. llvm-svn: 252567
2015-06-23Simplify the Mangler interface now that DataLayout is mandatory.Rafael Espindola1-3/+1
We only need to pass in a DataLayout when mangling a raw string, not when constructing the mangler. llvm-svn: 240405
2015-06-16Return a unique_ptr from getLazyBitcodeModule and parseBitcodeFile. NFC.Rafael Espindola1-2/+2
llvm-svn: 239858
2015-06-16Recommit r239721: Replace string GNU Triples with llvm::Triple in ↵Daniel Sanders1-6/+6
InitMCObjectFileInfo. NFC. Summary: This affects other tools so the previous C++ API has been retained as a deprecated function for the moment. Clang has been updated with a trivial patch (not covered by the pre-commit review) to avoid breaking -Werror builds. Other in-tree tools will be fixed with similar patches. This continues the patch series to eliminate StringRef forms of GNU triples from the internals of LLVM that began in r239036. The first time this was committed it accidentally fixed an inconsistency in triples in llvm-mc and this caused a failure. This inconsistency was fixed in r239808. Reviewers: rengolin Reviewed By: rengolin Subscribers: llvm-commits, rengolin Differential Revision: http://reviews.llvm.org/D10366 llvm-svn: 239812
2015-06-15Revert r239721 - Replace string GNU Triples with llvm::Triple in ↵Daniel Sanders1-6/+6
InitMCObjectFileInfo. NFC. It appears to cause sparc-little-endian.s to assert on Windows and Darwin. llvm-svn: 239724
2015-06-15Replace string GNU Triples with llvm::Triple in InitMCObjectFileInfo. NFC.Daniel Sanders1-6/+6
Summary: This affects other tools so the previous C++ API has been retained as a deprecated function for the moment. Clang has been updated with a trivial patch (not covered by the pre-commit review) to avoid breaking -Werror builds. Other in-tree tools will be fixed with similar trivial patches. This continues the patch series to eliminate StringRef forms of GNU triples from the internals of LLVM that began in r239036. Reviewers: rengolin Reviewed By: rengolin Subscribers: llvm-commits, rengolin Differential Revision: http://reviews.llvm.org/D10366 llvm-svn: 239721
2015-06-11Object: Prepend __imp_ when mangling a dllimport symbol in IRObjectFile.Peter Collingbourne1-0/+3
We cannot prepend __imp_ in the IR mangler because a function reference may be emitted unmangled in a constant initializer. The linker is expected to resolve such references to thunks. This is covered by the new test case. Strictly speaking we ought to emit two undefined symbols, one with __imp_ and one without, as we cannot know which symbol the final object file will refer to. However, this would require rather intrusive changes to IRObjectFile, and lld works fine without it for now. This reimplements r239437, which was reverted in r239502. Differential Revision: http://reviews.llvm.org/D10400 llvm-svn: 239560
2015-06-09Remove object_error::success and use std::error_code() insteadRui Ueyama1-2/+2
make_error_code(object_error) is slow because object::object_category() uses a ManagedStatic variable. But the real problem is that the function is called too frequently. This patch uses std::error_code() instead of object_error::success. In most cases, we return "success", so this patch reduces number of function calls to that function. http://reviews.llvm.org/D10333 llvm-svn: 239409
2015-05-15Remove MCAssembler.h include from MCStreamer.h and fix users of MCStreamer.hPete Cooper1-0/+1
llvm-svn: 237483
2015-03-13Be lazy about loading metadata in IRObjectFile.Rafael Espindola1-1/+3
This speeds up llvm-ar building lib64/libclangSema.a with debug IR files from 8.658015807 seconds to just 0.351036519 seconds :-) llvm-svn: 232221
2015-03-04Make DataLayout Non-Optional in the ModuleMehdi Amini1-6/+3
Summary: DataLayout keeps the string used for its creation. As a side effect it is no longer needed in the Module. This is "almost" NFC, the string is no longer canonicalized, you can't rely on two "equals" DataLayout having the same string returned by getStringRepresentation(). Get rid of DataLayoutPass: the DataLayout is in the Module The DataLayout is "per-module", let's enforce this by not duplicating it more than necessary. One more step toward non-optionality of the DataLayout in the module. Make DataLayout Non-Optional in the Module Module->getDataLayout() will never returns nullptr anymore. Reviewers: echristo Subscribers: resistor, llvm-commits, jholewinski Differential Revision: http://reviews.llvm.org/D7992 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 231270
2015-03-01Add missing includes. make_unique proliferated everywhere.Benjamin Kramer1-0/+1
llvm-svn: 230909
2015-02-19Introduce Target::createNullTargetStreamer and use it from IRObjectFile.Peter Collingbourne1-0/+1
A null MCTargetStreamer allows IRObjectFile to ignore target-specific directives. Previously we were crashing. Differential Revision: http://reviews.llvm.org/D7711 llvm-svn: 229797
2015-01-14[cleanup] Re-sort all the #include lines in LLVM usingChandler Carruth1-3/+3
utils/sort_includes.py. I clearly haven't done this in a while, so more changed than usual. This even uncovered a missing include from the InstrProf library that I've added. No functionality changed here, just mechanical cleanup of the include order. llvm-svn: 225974
2014-12-15Silence more static analyzer warnings.Michael Ilseman1-0/+2
Add in definedness checks for shift operators, null checks when pointers are assumed by the code to be non-null, and explicit unreachables. llvm-svn: 224255
2014-12-09Rename createIRObjectFile to just create.Rafael Espindola1-2/+2
It is a static method of IRObjectFile, so having to use IRObjectFile::createIRObjectFile was redundant. llvm-svn: 223822
2014-12-09Move method out of line to make buildbot happy.Rafael Espindola1-0/+2
llvm-svn: 223781
2014-12-09Don't lookup an object symbol name in the module.Rafael Espindola1-5/+2
Instead, walk the obj symbol list in parallel to find the GV. This shouldn't change anything on ELF where global symbols are not mangled, but it is a step toward supporting other object formats. Gold itself is ELF only, but bfd ld supports COFF and the logic in the gold plugin could be reused on lld. llvm-svn: 223780
2014-10-24Don't ever call materializeAllPermanently during LTO.Rafael Espindola1-11/+1
To do this, change the representation of lazy loaded functions. The previous representation cannot differentiate between a function whose body has been removed and one whose body hasn't been read from the .bc file. That means that in order to drop a function, the entire body had to be read. llvm-svn: 220580
2014-09-18LTO: introduce object file-based on-disk module format.Peter Collingbourne1-1/+41
This format is simply a regular object file with the bitcode stored in a section named ".llvmbc", plus any number of other (non-allocated) sections. One immediate use case for this is to accommodate compilation processes which expect the object file to contain metadata in non-allocated sections, such as the ".go_export" section used by some Go compilers [1], although I imagine that in the future we could consider compiling parts of the module (such as large non-inlinable functions) directly into the object file to improve LTO efficiency. [1] http://golang.org/doc/install/gccgo#Imports Differential Revision: http://reviews.llvm.org/D4371 llvm-svn: 218078
2014-09-03unique_ptrify IRObjectFile::createIRObjectFileDavid Blaikie1-2/+2
I took a guess at the changes to the gold plugin, because that doesn't seem to build by default for me. Not sure what dependencies I might be missing for that. llvm-svn: 217056
2014-09-03Pass a && to getLazyBitcodeModule.Rafael Espindola1-1/+1
This forces callers to use std::move when calling it. It is somewhat odd to have code with std::move that doesn't always move, but it is also odd to have code without std::move that sometimes moves. llvm-svn: 217049
2014-08-26Pass a std::unique_ptr<MemoryBuffer>& to getLazyBitcodeModule.Rafael Espindola1-2/+1
By taking a reference we can do the ownership transfer in one place instead of expecting every caller to do it. llvm-svn: 216492
2014-08-26Pass a MemoryBufferRef when we can avoid taking ownership.Rafael Espindola1-4/+1
The attached patch simplifies a few interfaces that don't need to take ownership of a buffer. For example, both parseAssembly and parseBitcodeFile will parse the entire buffer before returning. There is no need to take ownership. Using a MemoryBufferRef makes it obvious in the type signature that there is no ownership transfer. llvm-svn: 216488
2014-08-21Explicitly pass ownership of the MemoryBuffer to AddNewSourceBuffer using ↵David Blaikie1-1/+1
std::unique_ptr llvm-svn: 216223
2014-08-19Don't own the buffer in object::Binary.Rafael Espindola1-10/+14
Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries (like Archive) and we had to create dummy buffers just to handle that. It is also a bad fit for IRObjectFile where the Module wants to own the buffer too. Keeping this ownership would make supporting IR inside native objects particularly painful. This patch focuses in lib/Object. If something elsewhere used to own an Binary, now it also owns a MemoryBuffer. This patch introduces a few new types. * MemoryBufferRef. This is just a pair of StringRefs for the data and name. This is to MemoryBuffer as StringRef is to std::string. * OwningBinary. A combination of Binary and a MemoryBuffer. This is needed for convenience functions that take a filename and return both the buffer and the Binary using that buffer. The C api now uses OwningBinary to avoid any change in semantics. I will start a new thread to see if we want to change it and how. llvm-svn: 216002
2014-07-04Make RecordStreamer.h private.Rafael Espindola1-2/+2
llvm-svn: 212361
2014-07-04Ignore llvm.* globals.Rafael Espindola1-6/+3
It is not clear if llvm.global_ctors should or should not be in llvm.metadata, but in practice it is not and we need to ignore it for LTO. llvm-svn: 212351
2014-07-04Implement LTOModule on top of IRObjectFile.Rafael Espindola1-14/+12
IRObjectFile provides all the logic for producing mangled names and getting symbols from inline assembly. LTOModule then adds logic for linking specific tasks, like constructing llvm.compiler_user or extracting linker options from the bitcode. The rule of the thumb is that IRObjectFile has the functionality that is needed by both LTO and llvm-ar. llvm-svn: 212349
2014-07-04Mark intrinsic functions as llvm-specific.Rafael Espindola1-0/+5
llvm-svn: 212347