about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
AgeCommit message (Collapse)AuthorLines
2015-10-24rustllvm: Update to LLVM trunkSeo Sanghyeon-0/+18
2015-09-29Tweak Travis to use GCEAlex Crichton-5/+0
Travis CI has new infrastructure using the Google Compute Engine which has both faster CPUs and more memory, and we've been encouraged to switch as it should help our build times! The only downside currently, however, is that IPv6 is disabled, causing a number of standard library tests to fail. Consequently this commit tweaks our travis config in a few ways: * ccache is disabled as it's not working on GCE just yet * Docker is used to run tests inside which reportedly will get IPv6 working * A system LLVM installation is used instead of building LLVM itself. This is primarily done to reduce build times, but we want automation for this sort of behavior anyway and we can extend this in the future with building from source as well if needed. * gcc-specific logic is removed as the docker image for Ubuntu gives us a recent-enough gcc by default.
2015-07-21trans: Move rust_try into the compilerAlex Crichton-1/+2
This commit moves the IR files in the distribution, rust_try.ll, rust_try_msvc_64.ll, and rust_try_msvc_32.ll into the compiler from the main distribution. There's a few reasons for this change: * LLVM changes its IR syntax from time to time, so it's very difficult to have these files build across many LLVM versions simultaneously. We'll likely want to retain this ability for quite some time into the future. * The implementation of these files is closely tied to the compiler and runtime itself, so it makes sense to fold it into a location which can do more platform-specific checks for various implementation details (such as MSVC 32 vs 64-bit). * This removes LLVM as a build-time dependency of the standard library. This may end up becoming very useful if we move towards building the standard library with Cargo. In the immediate future, however, this commit should restore compatibility with LLVM 3.5 and 3.6.
2015-07-16rustc_trans: Update LLVMBuildLandingPad signatureAlex Crichton-0/+15
The C API of this function changed so it no longer takes a personality function. A shim was introduced to call the right LLVM function (depending on which version we're compiled against) to set the personality function on the outer function. The compiler only ever sets one personality function for all generated functions, so this should be equivalent.
2015-07-10trans: Use LLVM's writeArchive to modify archivesAlex Crichton-101/+0
We have previously always relied upon an external tool, `ar`, to modify archives that the compiler produces (staticlibs, rlibs, etc). This approach, however, has a number of downsides: * Spawning a process is relatively expensive for small compilations * Encoding arguments across process boundaries often incurs unnecessary overhead or lossiness. For example `ar` has a tough time dealing with files that have the same name in archives, and the compiler copies many files around to ensure they can be passed to `ar` in a reasonable fashion. * Most `ar` programs found do **not** have the ability to target arbitrary platforms, so this is an extra tool which needs to be found/specified when cross compiling. The LLVM project has had a tool called `llvm-ar` for quite some time now, but it wasn't available in the standard LLVM libraries (it was just a standalone program). Recently, however, in LLVM 3.7, this functionality has been moved to a library and is now accessible by consumers of LLVM via the `writeArchive` function. This commit migrates our archive bindings to no longer invoke `ar` by default but instead make a library call to LLVM to do various operations. This solves all of the downsides listed above: * Archive management is now much faster, for example creating a "hello world" staticlib is now 6x faster (50ms => 8ms). Linking dynamic libraries also recently started requiring modification of rlibs, and linking a hello world dynamic library is now 2x faster. * The compiler is now one step closer to "hassle free" cross compilation because no external tool is needed for managing archives, LLVM does the right thing! This commit does not remove support for calling a system `ar` utility currently. We will continue to maintain compatibility with LLVM 3.5 and 3.6 looking forward (so the system LLVM can be used wherever possible), and in these cases we must shell out to a system utility. All nightly builds of Rust, however, will stop needing a system `ar`.
2015-06-16rustc: Update LLVMAlex Crichton-31/+115
This commit updates the LLVM submodule in use to the current HEAD of the LLVM repository. This is primarily being done to start picking up unwinding support for MSVC, which is currently unimplemented in the revision of LLVM we are using. Along the way a few changes had to be made: * As usual, lots of C++ debuginfo bindings in LLVM changed, so there were some significant changes to our RustWrapper.cpp * As usual, some pass management changed in LLVM, so clang was re-scrutinized to ensure that we're doing the same thing as clang. * Some optimization options are now passed directly into the `PassManagerBuilder` instead of through CLI switches to LLVM. * The `NoFramePointerElim` option was removed from LLVM, favoring instead the `no-frame-pointer-elim` function attribute instead. Additionally, LLVM has picked up some new optimizations which required fixing an existing soundness hole in the IR we generate. It appears that the current LLVM we use does not expose this hole. When an enum is moved, the previous slot in memory is overwritten with a bit pattern corresponding to "dropped". When the drop glue for this slot is run, however, the switch on the discriminant can often start executing the `unreachable` block of the switch due to the discriminant now being outside the normal range. This was patched over locally for now by having the `unreachable` block just change to a `ret void`.
2015-06-07rustc_trans: don't hardcode llvm version for conditional intrinsicsLuca Bruno-0/+8
This commit introduce a third parameter for compatible_ifn!, as new intrinsics are being added in recent LLVM releases and there is no need to hardcode a specific case. Signed-off-by: Luca Bruno <lucab@debian.org>
2015-06-07Remove useless `const`Tamir Duberstein-1/+1
2015-05-19rustc_llvm: Don't export constants across dllsAlex Crichton-1/+3
For imports of constants across DLLs to work on Windows it *requires* that the import be marked with `dllimport` (unlike functions where the marker is optional, but strongly recommended). This currently isn't working for importing FFI constants across boundaries, however, so the one constant exported from `rustc_llvm.dll` is now a function to be called instead.
2015-05-12rustc_llvm: Expose setting more DLL storage classesAlex Crichton-2/+3
Currently only `dllexport` is used, but more integration will require using `dllimport` as well.
2015-04-25Add singlethreaded fence intrinsics.Peter Marheine-2/+4
These new intrinsics are comparable to `atomic_signal_fence` in C++, ensuring the compiler will not reorder memory accesses across the barrier, nor will it emit any machine instructions for it. Closes #24118, implementing RFC 888.
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.