summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
AgeCommit message (Collapse)AuthorLines
2015-04-21rollup merge of #24635: tamird/llvm-3.5Alex Crichton-16/+6
r? @alexcrichton
2015-04-21rustc: Handle duplicate names merging archivesAlex Crichton-24/+55
When linking an archive statically to an rlib, the compiler will extract all contents of the archive and add them all to the rlib being generated. The current method of extraction is to run `ar x`, dumping all files into a temporary directory. Object archives, however, are allowed to have multiple entries with the same file name, so there is no method for them to extract their contents into a directory in a lossless fashion. This commit adds iterator support to the `ArchiveRO` structure which hooks into LLVM's support for reading object archives. This iterator is then used to inspect each object in turn and extract it to a unique location for later assembly.
2015-04-21LLVM < 3.5 is unsupported since bb18a3cTamir Duberstein-16/+6
2015-04-03Implement LLVMGetOrInsertGlobal wrapperSimonas Kazlauskas-0/+6
2015-04-03Wrap LLVM’s Module::getNamedValueSimonas Kazlauskas-0/+5
2015-03-14Drop support for LLVM < 3.5 and fix compile errors with 3.5Björn Steinbrink-108/+12
LLVM older that 3.6 has a bug that cause assertions when compiling certain constructs. For 3.5 there's still a chance that the bug might get fixed in 3.5.2, so let's keep allowing to compile with it for it for now.
2015-02-01Update LLVM to rust-llvm-2015-01-30Björn Steinbrink-101/+168
2015-01-22Better inline assembly errorsJohn Kåre Alsaker-0/+16
2014-12-30debuginfo: Add a rust-gdb shell script that will start GDB with Rust pretty ↵Michael Woerister-3/+9
printers enabled.
2014-10-04Update LLVM.Luqman Aden-5/+40
2014-09-27Translate inline assembly errors back to source locationsKeegan McAllister-0/+15
Fixes #17552.
2014-09-12Add -C remark for LLVM optimization remarksKeegan McAllister-0/+48
Fixes #17116.
2014-09-12Add a Rust string ostream for LLVMKeegan McAllister-8/+4
2014-08-15Fix builds with LLVM < 3.6Björn Steinbrink-0/+8
2014-08-04Update LLVMVadim Chugunov-2/+2
2014-07-25rustllvm: Stub out some functions for llvm < 3.5Luqman Aden-0/+9
2014-07-25librustc: Use builder for llvm attributes.Luqman Aden-0/+17
2014-07-24rustllvm: Don't require null terminators in filesAlex Crichton-9/+25
Apparently the default getFile implementation for a memory buffer in LLVM ends up requiring a null terminator at the end of the file. This isn't true a good bit of the time apparently on OSX. There have been a number of failed nightly/snapshot builds recently with this strange assertion. This modifies the calls to MemoryBuffer::getFile to explicitly not ask for a null terminator.
2014-07-24Updated LLVM for iOSValerii Hiora-5/+6
There should be no more problems during SjLj pass
2014-06-21Update LLVMBjörn Steinbrink-2/+10
To fix #8106, we need an LLVM version that contains r211082 aka 0dee6756 which fixes a bug that blocks that issue. There have been some tiny API changes in LLVM, and cmpxchg changed its return type. The i1 part of the new return type is only interesting when using the new weak cmpxchg, which we don't do.
2014-06-12debuginfo: Fix issue with unique type IDs not being passed to LLVM for LLVM 3.4Michael Woerister-2/+7
2014-05-23librustc: Consolidate the attribute handling for tagging function arguments ↵Luqman Aden-40/+31
and returns.
2014-05-22Update to LLVM head and mark various ptrs as nonnull.Luqman Aden-0/+12
2014-05-13rustllvm: Add LLVMRustArrayTypeklutzy-0/+6
LLVM internally uses `uint64_t` for array size, but the corresponding C API (`LLVMArrayType`) uses `unsigned int` so ths value is truncated. Therefore rustc generates wrong type for fixed-sized large vector e.g. `[0 x i8]` for `[0u8, ..(1 << 32)]`. This patch adds `LLVMRustArrayType` function for `uint64_t` support.
2014-04-23rustc: Fix passing errors from LLVM to rustcAlex Crichton-13/+23
Many of the instances of setting a global error variable ended up leaving a dangling pointer into free'd memory. This changes the method of error transmission to strdup any error and "relinquish ownership" to rustc when it gets an error. The corresponding Rust code will then free the error as necessary. Closes #12865
2014-04-19rustc: Ensure closures are "split-stack"Alex Crichton-0/+12
In upgrading LLVM, only rust functions had the "split-stack" attribute added. This commit changes the addition of LLVM's "split-stack" attribute to *always* occur and then we remove it sometimes if the "no_split_stack" rust attribute is present. Closes #13625
2014-04-17Upgrade LLVMAlex Crichton-10/+38
This comes with a number of fixes to be compatible with upstream LLVM: * Previously all monomorphizations of "mem::size_of()" would receive the same symbol. In the past LLVM would silently rename duplicated symbols, but it appears to now be dropping the duplicate symbols and functions now. The symbol names of monomorphized functions are now no longer solely based on the type of the function, but rather the type and the unique hash for the monomorphization. * Split stacks are no longer a global feature controlled by a flag in LLVM. Instead, they are opt-in on a per-function basis through a function attribute. The rust #[no_split_stack] attribute will disable this, otherwise all functions have #[split_stack] attached to them. * The compare and swap instruction now takes two atomic orderings, one for the successful case and one for the failure case. LLVM internally has an implementation of calculating the appropriate failure ordering given a particular success ordering (previously only a success ordering was specified), and I copied that into the intrinsic translation so the failure ordering isn't supplied on a source level for now. * Minor tweaks to LLVM's API in terms of debuginfo, naming, c++11 conventions, etc.
2014-04-03rustc: Stop using LLVMGetSectionNameAlex Crichton-0/+25
The recent pull request to remove libc from libstd has hit a wall in compiling on windows, and I've been trying to investigate on the try bots as to why (it compiles locally just fine). To the best of my knowledge, the LLVM section iterator is behaving badly when iterating over the sections of the libc DLL. Upon investigating the LLVMGetSectionName function in LLVM, I discovered that this function doesn't always return a null-terminated string. It returns the data pointer of a StringRef instance (LLVM's equivalent of &str essentially), but it has no method of returning the length of the name of the section. This commit modifies the section iteration when loading libraries to invoke a custom LLVMRustGetSectionName which will correctly return both the length and the data pointer. I have not yet verified that this will fix landing liblibc, as it will require a snapshot before doing a full test. Regardless, this is a worrisome situation regarding the LLVM API, and should likely be fixed anyway.
2014-03-27Initial support for emitting DWARF for static vars.gentlefolk-0/+22
Only supports crate level statics. No debug info is generated for function level statics. Closes #9227.
2014-03-05rustc: Fix support for LLVM 3.3Alex Crichton-0/+5
The llvm.copysign and llvm.round intrinsics weren't added until LLVM 3.4, so if we're on LLVM 3.3 we lower these to calls in libm instead of LLVM intrinsics. This should fix our travis failures.
2014-02-26rustc: Get rustc compiling with LLVM 3.{3,4} againAlex Crichton-7/+56
The travis builds have been breaking recently because LLVM 3.5 upstream is changing. This looks like it's likely to continue, so it would be more useful for us if we could lock ourselves to a system LLVM version that is not changing. This commit has the support to bring our C++ glue to LLVM back in line with what was possible back in LLVM 3.{3,4}. I don't think we're going to be able to reasonably protect against regressions in the future, but this kind of code is a good sign that we can continue to use the system LLVM for simple-ish things. Codegen for ARM won't work and it won't have some of the perf improvements we have, but using the system LLVM should work well enough for development.
2014-01-29auto merge of #11853 : alexcrichton/rust/up-llvm, r=brsonbors-7/+13
This upgrade brings commit by @eddyb to help optimizations of virtual calls in a few places (https://github.com/llvm-mirror/llvm/commit/6d2bd95) as well as a commit by @c-a to *greatly* improve the runtime of the optimization passes (https://github.com/rust-lang/llvm/pull/3). Nice work to these guys!
2014-01-29Upgrade LLVMAlex Crichton-7/+13
This upgrade brings commit by @eddyb to help optimizations of virtual calls in a few places (https://github.com/llvm-mirror/llvm/commit/6d2bd95) as well as a commit by @c-a to *greatly* improve the runtime of the optimization passes (https://github.com/rust-lang/llvm/pull/3). Nice work to these guys!
2014-01-28Add appropriate LLVM module flags for debug info.comex-0/+8
Set "Dwarf Version" to 2 on OS X to avoid toolchain incompatibility, and set "Debug Info Version" to prevent debug info from being stripped from bitcode. Fixes #11352.
2014-01-15Issue #3511 - Rationalize temporary lifetimes.Niko Matsakis-0/+11
Major changes: - Define temporary scopes in a syntax-based way that basically defaults to the innermost statement or conditional block, except for in a `let` initializer, where we default to the innermost block. Rules are documented in the code, but not in the manual (yet). See new test run-pass/cleanup-value-scopes.rs for examples. - Refactors Datum to better define cleanup roles. - Refactor cleanup scopes to not be tied to basic blocks, permitting us to have a very large number of scopes (one per AST node). - Introduce nascent documentation in trans/doc.rs covering datums and cleanup in a more comprehensive way.
2014-01-02auto merge of #11274 : michaelwoerister/rust/issue11083, r=pcwaltonbors-2/+4
This pull request fixes #11083. The problem was that recursive type definitions were not properly handled for enum types, leading to problems with LLVM's metadata "uniquing". This bug has already been fixed for struct types some time ago (#9658) but I seem to have forgotten about enums back then. I added the offending code from issue #11083 as a test case.
2014-01-02debuginfo: Fix issue #11083 and some minor clean up.Michael Woerister-2/+4
2013-12-31Convert relevant static mutexes to OnceAlex Crichton-22/+0
2013-12-19rustc: Optimize reading metadata by 4xAlex Crichton-0/+40
We were previously reading metadata via `ar p`, but as learned from rustdoc awhile back, spawning a process to do something is pretty slow. Turns out LLVM has an Archive class to read archives, but it cannot write archives. This commits adds bindings to the read-only version of the LLVM archive class (with a new type that only has a read() method), and then it uses this class when reading the metadata out of rlibs. When you put this in tandem of not compressing the metadata, reading the metadata is 4x faster than it used to be The timings I got for reading metadata from the respective libraries was: libstd-04ff901e-0.9-pre.dylib => 100ms libstd-04ff901e-0.9-pre.rlib => 23ms librustuv-7945354c-0.9-pre.dylib => 4ms librustuv-7945354c-0.9-pre.rlib => 1ms librustc-5b94a16f-0.9-pre.dylib => 87ms librustc-5b94a16f-0.9-pre.rlib => 35ms libextra-a6ebb16f-0.9-pre.dylib => 63ms libextra-a6ebb16f-0.9-pre.rlib => 15ms libsyntax-2e4c0458-0.9-pre.dylib => 86ms libsyntax-2e4c0458-0.9-pre.rlib => 22ms In order to always take advantage of these faster metadata read-times, I sort the files in filesearch based on whether they have an rlib extension or not (prefer all rlib files first). Overall, this halved the compile time for a `fn main() {}` crate from 0.185s to 0.095s on my system (when preferring dynamic linking). Reading metadata is still the slowest pass of the compiler at 0.035s, but it's getting pretty close to linking at 0.021s! The next best optimization is to just not copy the metadata from LLVM because that's the most expensive part of reading metadata right now.
2013-12-09Implement LTOAlex Crichton-0/+19
This commit implements LTO for rust leveraging LLVM's passes. What this means is: * When compiling an rlib, in addition to insdering foo.o into the archive, also insert foo.bc (the LLVM bytecode) of the optimized module. * When the compiler detects the -Z lto option, it will attempt to perform LTO on a staticlib or binary output. The compiler will emit an error if a dylib or rlib output is being generated. * The actual act of performing LTO is as follows: 1. Force all upstream libraries to have an rlib version available. 2. Load the bytecode of each upstream library from the rlib. 3. Link all this bytecode into the current LLVM module (just using llvm apis) 4. Run an internalization pass which internalizes all symbols except those found reachable for the local crate of compilation. 5. Run the LLVM LTO pass manager over this entire module 6a. If assembling an archive, then add all upstream rlibs into the output archive. This ignores all of the object/bitcode/metadata files rust generated and placed inside the rlibs. 6b. If linking a binary, create copies of all upstream rlibs, remove the rust-generated object-file, and then link everything as usual. As I have explained in #10741, this process is excruciatingly slow, so this is *not* turned on by default, and it is also why I have decided to hide it behind a -Z flag for now. The good news is that the binary sizes are about as small as they can be as a result of LTO, so it's definitely working. Closes #10741 Closes #10740
2013-12-05Update LLVM and jettison jit supportAlex Crichton-277/+1
LLVM's JIT has been updated numerous times, and we haven't been tracking it at all. The existing LLVM glue code no longer compiles, and the JIT isn't used for anything currently. This also rebases out the FixedStackSegment support which we have added to LLVM. None of this is still in use by the compiler, and there's no need to keep this functionality around inside of LLVM. This is needed to unblock #10708 (where we're tripping an LLVM assertion).
2013-10-28add support for the `cold` function attributeDaniel Micay-0/+5
This allows a function to marked as infrequently called, resulting in any branch calling it to be considered colder.
2013-10-11have LLVM print type strings for usDaniel Micay-0/+7
Example: void ({ i64, %tydesc*, i8*, i8*, i8 }*, i64*, %"struct.std::fmt::Formatter[#1]"*)* Before, we would print 20 levels deep due to recursion in the type definition.
2013-10-08debuginfo: Unified namespace generation approach for crate-local and ↵Michael Woerister-6/+13
external items. Fixed bug related to LLVM metadata uniquing.
2013-09-15debuginfo: Added description of algorithm for handling recursive types.Michael Woerister-23/+0
Also fixed nasty bug caused by calling LLVMDIBuilderCreateStructType() with a null pointer where an empty array was expected (which would trigger an unintelligable assertion somewhere down the line).
2013-09-15debuginfo: Support for recursive types.Michael Woerister-0/+30
2013-09-10debuginfo: Wrapped namespace facilities of llvm::DIBuilderMichael Woerister-3/+17
2013-09-09add `noalias` attribute to ~ return valuesDaniel Micay-0/+15
2013-09-04debuginfo: Support for variables captured in closures and closure type ↵Michael Woerister-0/+36
descriptions.
2013-08-28Revert "auto merge of #8695 : thestinger/rust/build, r=pcwalton"Brian Anderson-0/+1
This reverts commit 2c0f9bd35493def5e23f0f43ddeba54da9d788b4, reversing changes made to f8c4f0ea9c96218dbc81081799e77875fbb071de. Conflicts: src/rustllvm/RustWrapper.cpp