about summary refs log tree commit diff
path: root/src/librustc_codegen_llvm/llvm
AgeCommit message (Collapse)AuthorLines
2020-02-08rustc_codegen_llvm: remove InternalDebugLocation and simplify dbg_var_addr.Eduard-Mihai Burtescu-2/+0
2020-02-01Add support for enabling the LLVM time-trace featureWesley Wiser-0/+4
I found this helpful while investigating an LLVM performance issue. Passing `-Z llvm-time-trace` causes a `llvm_timings.json` file to be created. This file can be inspected in either the Chrome Profiler tools or with any other compatible tool like SpeedScope. More information on the LLVM feature: - https://aras-p.info/blog/2019/01/16/time-trace-timeline-flame-chart-profiler-for-Clang/ - https://reviews.llvm.org/rL357340
2019-12-22Format the worldMark Rousskov-966/+1106
2019-12-12Fix weird implicit dependency between rustllvm and rustc_codegen_llvmAaron Hill-17/+2
rustllvm relies on the `LLVMRustStringWriteImpl` symbol existing, but this symbol was previously defined in a *downstream* crate (rustc_codegen_llvm, which depends on rustc_llvm. While this somehow worked under the old 'separate bootstrap step for codegen' scheme, it meant that rustc_llvm could not actually be built by itself, since it relied linking to the downstream rustc_codegen_llvm crate. Now that librustc_codegen_llvm is just a normal crate, we actually try to build a standalone rustc_llvm when we run tests. This commit moves `LLVMRustStringWriteImpl` into rustc_llvm (technically the rustllvm directory, which has its contents built by rustc_llvm). This ensures that we can build each crate in the graph by itself, without requiring that any downstream crates be linked in as well.
2019-12-11rustc: Link LLVM directly into rustc againAlex Crichton-0/+1
This commit builds on #65501 continue to simplify the build system and compiler now that we no longer have multiple LLVM backends to ship by default. Here this switches the compiler back to what it once was long long ago, which is linking LLVM directly to the compiler rather than dynamically loading it at runtime. The `codegen-backends` directory of the sysroot no longer exists and all relevant support in the build system is removed. Note that `rustc` still supports a dynamically loaded codegen backend as it did previously, it just no longer supports dynamically loaded codegen backends in its own sysroot. Additionally as part of this the `librustc_codegen_llvm` crate now once again explicitly depends on all of its crates instead of implicitly loading them through the sysroot. This involved filling out its `Cargo.toml` and deleting all the now-unnecessary `extern crate` annotations in the header of the crate. (this in turn required adding a number of imports for names of macros too). The end results of this change are: * Rustbuild's build process for the compiler as all the "oh don't forget the codegen backend" checks can be easily removed. * Building `rustc_codegen_llvm` is much simpler since it's simply another compiler crate. * Managing the dependencies of `rustc_codegen_llvm` is much simpler since it's "just another `Cargo.toml` to edit" * The build process should be a smidge faster because there's more parallelism in the main rustc build step rather than splitting `librustc_codegen_llvm` out to its own step. * The compiler is expected to be slightly faster by default because the codegen backend does not need to be dynamically loaded. * Disabling LLVM as part of rustbuild is still supported, supporting multiple codegen backends is still supported, and dynamic loading of a codegen backend is still supported.
2019-12-07Rollup merge of #67033 - cuviper:ValueName2, r=rkruppeYuki Okushi-5/+24
Migrate to LLVM{Get,Set}ValueName2 The deprecated `LLVM{Get,Set}ValueName` only work with NUL-terminated strings, but the `2` variants use explicit lengths, which fits better with Rust strings and slices. We now use these in new helper functions `llvm::{get,set}_value_name` that convert to/from `&[u8]`. Closes #64223. r? @rkruppe
2019-12-05Auto merge of #66952 - 0dvictor:print, r=rkruppebors-2/+1
Use Module::print() instead of a PrintModulePass llvm::Module has a print() method. It is unnecessary to create a pass just for the purpose of printing LLVM IR.
2019-12-04Migrate to LLVM{Get,Set}ValueName2Josh Stone-5/+24
The deprecated `LLVM{Get,Set}ValueName` only work with NUL-terminated strings, but the `2` variants use explicit lengths, which fits better with Rust strings and slices. We now use these in new helper functions `llvm::{get,set}_value_name` that convert to/from `&[u8]`.
2019-12-03Change linker for x86_64-fortanix-unknown-sgx to rust-lldParth Sane-1/+2
For SGX, the relocation using the relocation table is done by the code in rust/src/libstd/sys/sgx/abi/reloc.rs and this code should not require relocation. Setting RelaxELFRelocations flag if allows this to happen, hence adding a Target Option for it.
2019-12-02Use Module::print() instead of a PrintModulePassVictor Ding-2/+1
llvm::Module has a print() method. It is unnecessary to create a pass just for the purpose of printing LLVM IR.
2019-11-29Use LLVMAddAnalysisPasses instead of Rust's wrapperVictor Ding-1/+2
LLVM exposes a C API `LLVMAddAnalysisPasses` and hence Rust's own wrapper `LLVMRustAddAnalysisPasses` is not needed anymore.
2019-11-22Move sanitizer passes creation from ssa to llvmTomasz Miąsko-0/+5
2019-11-13Revert "Auto merge of #65134 - ↵Robin Kruppe-1/+0
davidtwco:issue-19834-improper-ctypes-in-extern-C-fn, r=rkruppe" This reverts commit 3f0e16473de5ec010f44290a8c3ea1d90e0ad7a2, reversing changes made to 61a551b4939ec1d5596e585351038b8fbd0124ba.
2019-11-06Auto merge of #65134 - davidtwco:issue-19834-improper-ctypes-in-extern-C-fn, ↵bors-0/+1
r=rkruppe improper_ctypes: `extern "C"` fns cc #19834. Fixes #65867. This pull request implements the change [described in this comment](https://github.com/rust-lang/rust/issues/19834#issuecomment-466671572). cc @rkruppe @varkor @shepmaster
2019-11-06Rollup merge of #66062 - smaeul:patch/pic-level, r=estebankMazdak Farrokhzad-0/+1
Configure LLVM module PIC level As of LLVM 9, this is required for 32-bit PowerPC to properly generate PLT references. Previously, only BigPIC was supported; now LLVM supports both BigPIC and SmallPIC, and there is no default value provided.
2019-11-05Rollup merge of #65953 - keystone-enclave:llvm_abiname, r=alexcrichtonPietro Albini-0/+1
Allow specifying LLVM's MCTargetOptions::ABIName in target specification files This addresses #65024, as it allows RISC-V target specification files to set `"llvm-abiname": "lp64d"`. Other languages (read: C) usually expose this codegen parameter under a compiler argument like `-mabi=<XYZ>`.
2019-11-05improper_ctypes: `extern "C"` fnsDavid Wood-0/+1
2019-11-05Rollup merge of #65720 - icefoxen:LLVMgetInstructionCount, r=rkruppePietro Albini-0/+1
Add FFI bindings for LLVM's Module::getInstructionCount() Just to make it usable for profiling and such inside rustc itself. It was vaguely useful in https://wiki.alopex.li/WhereRustcSpendsItsTime and I figured I might as well upstream it; I may or may not ever get around to doing more with it (hopefully I will), but it may be useful for others.
2019-11-03Configure LLVM module PIC levelSamuel Holland-0/+1
As of LLVM 9, this is required for 32-bit PowerPC to properly generate PLT references. Previously, only BigPIC was supported; now LLVM supports both BigPIC and SmallPIC, and there is no default value provided.
2019-11-02Add FFI bindings for Module::getInstructionCount()Simon Heath-0/+1
Just to make it useable for profiling and such inside rustc itself. It was vaguely useful in https://wiki.alopex.li/WhereRustcSpendsItsTime and I figured I might as well upstream it; I may or may not ever get around to doing more with it (hopefully I will), but it may be useful for others.
2019-10-29Allow specifying key "llvm-abiname" in target specificationGui Andrade-0/+1
This addresses #65024, as it allows RISC-V target specification files to set "llvm-abiname": "lp64d". In general, it is useful for the programmer to be able to set this codegen parameter, which other languages usually expose under a compiler argument like "-mabi=<XYZ>".
2019-10-21Remove many unnecessary trait derivations.Nicholas Nethercote-2/+1
2019-10-13Improve type safetybjorn3-3/+4
2019-09-06rustc_codegen_llvm: give names to non-alloca variable values.Eduard-Mihai Burtescu-0/+2
2019-08-01Use Rust integer types instead of libc's fixed-width typesgnzlbg-2/+2
2019-07-28Remove lint annotations in specific crates that are already enforced by ↵Vadim Petrochenkov-3/+3
rustbuild Remove some random unnecessary lint `allow`s
2019-07-20Remove vector fadd/fmul reduction workaroundsNikita Popov-2/+0
The bugs that this was working around have been fixed in LLVM 9.
2019-07-15Don't add extra passes into the function pass managerNikita Popov-0/+3
Exception for specific cases like linting, additional passes should be going into the module pass manager (even if they are function passes). The separate function pass manager is only used for very early optimization passes. Rather than apparending passes to the MPM, use the OptimizerLast and EnabledOnOptLevel0 pass manager builder extension hooks, which allow adding passes directly before finalization (alias canonicalization and name-anon-globals). The main effect and purpose of this change is to add sanitizer passes at the end of the pipeline, which is where they belong. In LLVM 9 the address sanitizer can't be used as a pass in the early function pass manager, because it has a dependence on a module-level analysis pass.
2019-07-10Rollup merge of #62474 - nikic:update-llvm, r=alexcrichtonMazdak Farrokhzad-0/+3
Prepare for LLVM 9 update Main changes: * In preparation for opaque pointer types, the `byval` attribute now takes a type. As such, the argument type needs to be threaded through to the function/callsite attribute application logic. * On ARM the `+fp-only-sp` and `+d16` features have become `-fp64` and `-d32`. I've switched the target definitions to use the new names, but also added bidirectional emulation so either can be used on any LLVM version for backwards compatibility. * The datalayout can now specify function pointer alignment. In particular on ARM `Fi8` is specified, which means that function pointer alignment is independent of function alignment. I've added this to our datalayouts to match LLVM (which is something we check) and strip the fnptr alignment for older LLVM versions. * The fmul/fadd reductions now always respect the accumulator (including for unordered reductions), so we should pass the identity instead of undef. Open issues: * https://reviews.llvm.org/D62106 causes linker errors with ld.bdf due to https://sourceware.org/bugzilla/show_bug.cgi?id=24784. To avoid this I've enabled `RelaxELFRelocations`, which results in a GOTPCRELX relocation for `__tls_get_addr` and avoids the issue. However, this is likely not acceptable because relax relocations are not supported by older linker versions. We may need an LLVM option to keep using PLT for `__tls_get_addr` despite `RtLibUseGOT`. The corresponding llvm-project PR is https://github.com/rust-lang/llvm-project/pull/19. r? @ghost
2019-07-09Fix float add/mul reduction codegenNikita Popov-0/+1
The accumulator is now respected for unordered reductions.
2019-07-09Pass type to byval attributesNikita Popov-0/+2
2019-07-07Handle null from LLVMRustGetSectionNameValentin Tolmer-1/+3
2019-06-16librustc_codegen_llvm: Use repr(transparent) for bitflags over repr(C) (#61306)John Paul Adrian Glaubitz-2/+2
In order to make sure that Rust's bitflags types are passed the same way in the Rust ABI as they are in the C ABI, we need to use the attribute repr(transparent) over the repr(C) attribute for the single-field bitflags structs in in order to prevent ABI mismatches. Thanks to Michael Karcher for finding this bug.
2019-06-03add support for unchecked mathlcnr/Bastian Kauschke-0/+30
2019-04-18Remove the unused LLVMRustIsRustLLVMJosh Stone-1/+0
2019-04-06Auto merge of #59710 - alexcrichton:llvm-9-compat, r=sanxiynbors-1/+1
rustc: Start implementing compat with LLVM 9 This commit doesn't actually migrate to LLVM 9, but it brings our own C++ bindings in line with LLVM 9 and able to compile against tip of tree. The changes made were: * The `MainSubprogram` flag for debuginfo moved between flag types. * Iteration of archive members was tweaked slightly and we have to construct the two iterators before constructing the returned `RustArchiveIterator` value. * The `getOrInsertFunction` binding now returns a wrapper which we use `getCallee()` on to get the value we're interested in.
2019-04-05Show better errors for LLVM IR outputJosh Stone-1/+2
I was trying to output LLVM IR directly to the console: $ rustc hello.rs --emit=llvm-ir -o /dev/stdout LLVM ERROR: IO failure on output stream: Bad file descriptor Now `LLVMRustPrintModule` returns an error, and we print: error: failed to write LLVM IR to /dev/stdout.hello.7rcbfp3g-cgu.0.rcgu.ll: Permission denied ... which is more informative.
2019-04-05rustc: Start implementing compat with LLVM 9Alex Crichton-1/+1
This commit doesn't actually migrate to LLVM 9, but it brings our own C++ bindings in line with LLVM 9 and able to compile against tip of tree. The changes made were: * The `MainSubprogram` flag for debuginfo moved between flag types. * Iteration of archive members was tweaked slightly and we have to construct the two iterators before constructing the returned `RustArchiveIterator` value. * The `getOrInsertFunction` binding now returns a wrapper which we use `getCallee()` on to get the value we're interested in.
2019-03-24make asm diagnostic instruction optionalAndy Russell-2/+2
`DiagnosticInfoInlineAsm::getInstruction` may return a null pointer, so the instruction shouldn't be blindly unwrapped.
2019-02-25librustc_codegen_llvm: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-16/+16
2019-02-23Implement ffi_returns_twice attributegnzlbg-0/+1
2019-02-18librustc_codegen_llvm => 2018Taiki Endo-4/+2
2019-02-14Rollup merge of #58378 - alexcrichton:incremental-lto, r=michaelwoeristerMazdak Farrokhzad-1/+1
rustc: Implement incremental "fat" LTO Currently the compiler will produce an error if both incremental compilation and full fat LTO is requested. With recent changes and the advent of incremental ThinLTO, however, all the hard work is already done for us and it's actually not too bad to remove this error! This commit updates the codegen backend to allow incremental full fat LTO. The semantics are that the input modules to LTO are all produce incrementally, but the final LTO step is always done unconditionally regardless of whether the inputs changed or not. The only real incremental win we could have here is if zero of the input modules changed, but that's so rare it's unlikely to be worthwhile to implement such a code path. cc #57968 cc rust-lang/cargo#6643
2019-02-12rustc: Implement incremental "fat" LTOAlex Crichton-1/+1
Currently the compiler will produce an error if both incremental compilation and full fat LTO is requested. With recent changes and the advent of incremental ThinLTO, however, all the hard work is already done for us and it's actually not too bad to remove this error! This commit updates the codegen backend to allow incremental full fat LTO. The semantics are that the input modules to LTO are all produce incrementally, but the final LTO step is always done unconditionally regardless of whether the inputs changed or not. The only real incremental win we could have here is if zero of the input modules changed, but that's so rare it's unlikely to be worthwhile to implement such a code path. cc #57968 cc rust-lang/cargo#6643
2019-02-10rustc: doc commentsAlexander Regueiro-1/+1
2019-01-26Auto merge of #55641 - nagisa:optimize-attr, r=pnkfelixbors-0/+1
Implement optimize(size) and optimize(speed) attributes This PR implements both `optimize(size)` and `optimize(speed)` attributes. While the functionality itself works fine now, this PR is not yet complete: the code might be messy in places and, most importantly, the compiletest must be improved with functionality to run tests with custom optimization levels. Otherwise the new attribute cannot be tested properly. Oh, and not all of the RFC is implemented – attribute propagation is not implemented for example. # TODO * [x] Improve compiletest so that tests can be written; * [x] Assign a proper error number (E9999 currently, no idea how to allocate a number properly); * [ ] Perhaps reduce the duplication in LLVM attribute assignment code…
2019-01-25Set the DICompileUnit emissionKindJosh Stone-2/+23
2019-01-25Rebase to the llvm-project monorepoJosh Stone-5/+17
The new git submodule src/llvm-project is a monorepo replacing src/llvm and src/tools/{clang,lld,lldb}. This also serves as a rebase for these projects to the new 8.x branch from trunk. The src/llvm-emscripten fork is unchanged for now.
2019-01-24Implement optimize(size) and optimize(speed)Simonas Kazlauskas-0/+1
2018-12-25Remove licensesMark Rousskov-40/+0