about summary refs log tree commit diff
path: root/src/rustllvm/PassWrapper.cpp
AgeCommit message (Collapse)AuthorLines
2020-09-09Move `rustllvm` into `rustc_llvm`Vadim Petrochenkov-1655/+0
2020-08-12Remove CodeGenOptLevel::OtherMark Rousskov-1/+0
Also introduced in #35174, and immediately unused.
2020-08-12Remove FileType::OtherMark Rousskov-1/+0
Added in #35174, this was already unused (and new uses have not been introduced since then).
2020-06-25Prepare for LLVM 11Josh Stone-26/+93
2020-06-19Rollup merge of #73347 - tmiasko:incompatible-sanitizers, r=nikicManish Goregaokar-6/+7
Diagnose use of incompatible sanitizers Emit an error when incompatible sanitizer are configured through command line options. Previously the last one configured prevailed and others were silently ignored. Additionally use a set to represent configured sanitizers, making it possible to enable multiple sanitizers at once. At least in principle, since currently all of them are considered to be incompatible with others.
2020-06-17add blank line bw sections asrar-1/+1
Separate target features from rust ones with a blank line Co-authored-by: Josh Stone <cuviper@gmail.com>
2020-06-16trim whitespaceroot-3/+3
2020-06-16break long line for formattingroot-1/+5
2020-06-16add header for rust specific featureroot-2/+1
2020-06-14Add rust features to print target featuresasrar-0/+3
`crt-static` is a rust specific target feature that's absent from llvm feature table, adding it there.
2020-06-14Diagnose use of incompatible sanitizersTomasz Miąsko-6/+7
Emit an error when incompatible sanitizer are configured through command line options. Previously the last one configured prevailed and others were silently ignored. Additionally use a set to represent configured sanitizers, making it possible to enable multiple sanitizers at once. At least in principle, since currently all of them are considered to be incompatible with others.
2020-06-09[AVR] Add AVR platform supportJake Goulding-0/+7
2020-05-21rustllvm: Fix warnings about unused function parametersVadim Petrochenkov-1/+1
2020-05-17Auto merge of #72248 - petrochenkov:codemodel, r=Amanieubors-5/+7
Cleanup and document `-C code-model` r? @Amanieu
2020-05-16rustc_target: Stop using "string typing" for code modelsVadim Petrochenkov-5/+7
Introduce `enum CodeModel` instead.
2020-05-14Consistently use LLVM lifetime markers during codegenTomasz Miąsko-2/+2
Ensure that inliner inserts lifetime markers if they have been emitted during codegen. Otherwise if allocas from inlined functions are merged together, lifetime markers from one function might invalidate load & stores performed by the other one.
2020-05-09Rollup merge of #71234 - maurer:init-array, r=cuviperRalf Jung-1/+3
rustllvm: Use .init_array rather than .ctors LLVM TargetMachines default to using the (now-legacy) .ctors representation of init functions. Mixing .ctors and .init_array representations can cause issues when linking with lld. This happens in practice for: * Our profiling runtime which is currently implicitly built with .init_array since it is built by clang, which sets this field. * External C/C++ code that may be linked into the same process. Fixes: #71233
2020-04-29Auto merge of #71528 - alexcrichton:no-more-bitcode, r=nnethercotebors-0/+28
Store LLVM bitcode in object files, not compressed This commit is an attempted resurrection of #70458 where LLVM bitcode emitted by rustc into rlibs is stored into object file sections rather than in a separate file. The main rationale for doing this is that when rustc emits bitcode it will no longer use a custom compression scheme which makes it both easier to interoperate with existing tools and also cuts down on compile time since this compression isn't happening. The blocker for this in #70458 turned out to be that native linkers didn't handle the new sections well, causing the sections to either trigger bugs in the linker or actually end up in the final linked artifact. This commit attempts to address these issues by ensuring that native linkers ignore the new sections by inserting custom flags with module-level inline assembly. Note that this does not currently change the API of the compiler at all. The pre-existing `-C bitcode-in-rlib` flag is co-opted to indicate whether the bitcode should be present in the object file or not. Finally, note that an important consequence of this commit, which is also one of its primary purposes, is to enable rustc's `-Clto` bitcode loading to load rlibs produced with `-Clinker-plugin-lto`. The goal here is that when you're building with LTO Cargo will tell rustc to skip codegen of all intermediate crates and only generate LLVM IR. Today rustc will generate both object code and LLVM IR, but the object code is later simply thrown away, wastefully.
2020-04-29Use .init_array rather than .ctorsMatthew Maurer-1/+3
LLVM TargetMachines default to using the (now-legacy) .ctors representation of init functions. Mixing .ctors and .init_array representations can cause issues when linking with lld. This happens in practice for: * Our profiling runtime which is currently implicitly built with .init_array since it is built by clang, which sets this field. * External C/C++ code that may be linked into the same process. To support legacy systems which may use .ctors, targets may now specify that they use .ctors via the use_ctors attribute which defaults to false. For debugging and manual control, -Z use-ctors-section=yes/no will allow manual override. Fixes: #71233
2020-04-29Store LLVM bitcode in object files, not compressedAlex Crichton-0/+28
This commit is an attempted resurrection of #70458 where LLVM bitcode emitted by rustc into rlibs is stored into object file sections rather than in a separate file. The main rationale for doing this is that when rustc emits bitcode it will no longer use a custom compression scheme which makes it both easier to interoperate with existing tools and also cuts down on compile time since this compression isn't happening. The blocker for this in #70458 turned out to be that native linkers didn't handle the new sections well, causing the sections to either trigger bugs in the linker or actually end up in the final linked artifact. This commit attempts to address these issues by ensuring that native linkers ignore the new sections by inserting custom flags with module-level inline assembly. Note that this does not currently change the API of the compiler at all. The pre-existing `-C bitcode-in-rlib` flag is co-opted to indicate whether the bitcode should be present in the object file or not. Finally, note that an important consequence of this commit, which is also one of its primary purposes, is to enable rustc's `-Clto` bitcode loading to load rlibs produced with `-Clinker-plugin-lto`. The goal here is that when you're building with LTO Cargo will tell rustc to skip codegen of all intermediate crates and only generate LLVM IR. Today rustc will generate both object code and LLVM IR, but the object code is later simply thrown away, wastefully.
2020-04-26codegen_llvm: `RelocMode` -> `RelocModel`Vadim Petrochenkov-9/+9
2020-04-26rustc_target: Stop using "string typing" for relocation modelsVadim Petrochenkov-4/+1
Introduce `enum RelocModel` instead.
2020-04-14Update the minimum external LLVM to 8Josh Stone-20/+2
LLVM 8 was released on March 20, 2019, over a year ago.
2020-03-19Fix timeTraceProfilerInitialize for LLVM 10Nikita Popov-1/+5
2020-03-03Invoke OptimizerLastEPCallbacks in PreLinkThinLTOTomasz Miąsko-2/+10
The default ThinLTO pre-link pipeline does not include optimizer last extension points. Thus, when using the new LLVM pass manager & ThinLTO & sanitizers on any opt-level different from zero, the sanitizer function passes would be omitted from the pipeline. Add optimizer last extensions points manually to the pipeline, but guard registration with stage check in the case this behaviour changes in the future.
2020-02-13Auto merge of #69144 - Dylan-DPC:rollup-apt6zjj, r=Dylan-DPCbors-2/+2
Rollup of 9 pull requests Successful merges: - #68728 (parse: merge `fn` syntax + cleanup item parsing) - #68938 (fix lifetime shadowing check in GATs) - #69057 (expand: misc cleanups and simplifications) - #69108 (Use HirId in TraitCandidate.) - #69125 (Add comment to SGX entry code) - #69126 (miri: fix exact_div) - #69127 (Enable use after scope detection in the new LLVM pass manager) - #69135 (Spelling error "represening" to "representing") - #69141 (Don't error on network failures) Failed merges: r? @ghost
2020-02-13add selfprofiling for new llvm passmanagerAndreas Jonson-1/+64
2020-02-13Enable use after scope detection in the new LLVM pass managerTomasz Miąsko-2/+2
Implementation of 08a1c566a792dcf9657d293155f7ada87746bb65 for the new LLVM pass manager, support for which landed in the meantime.
2020-02-12Add support for new pass managerNikita Popov-1/+243
The new pass manager can be enabled using -Z new-llvm-pass-manager=on.
2020-02-01Add support for enabling the LLVM time-trace featureWesley Wiser-0/+18
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
2020-01-27Detect use-after-scope bugs with AddressSanitizerTomasz Miąsko-1/+2
Enable use-after-scope checks by default when using AddressSanitizer. They allow to detect incorrect use of stack objects after their scope have already ended. The detection is based on LLVM lifetime intrinsics. To facilitate the use of this functionality, the lifetime intrinsics are now emitted regardless of optimization level if enabled sanitizer makes use of them.
2020-01-07Update thinLTOInternalizeAndPromoteInIndex() usageNikita Popov-0/+10
2020-01-07Handle removal of llvm::make_unique()Nikita Popov-0/+8
2020-01-07CodeGenFileType moved outside TargetMachineNikita Popov-0/+13
2020-01-07Explicitly include InitializePasses.hNikita Popov-0/+1
2019-12-05Auto merge of #66952 - 0dvictor:print, r=rkruppebors-40/+3
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-03Rollup merge of #66973 - cuviper:min-llvm7, r=alexcrichtonMazdak Farrokhzad-13/+3
Update the minimum external LLVM to 7 LLVM 7 is over a year old, which should be plenty for compatibility. The last LLVM 6 holdout was llvm-emscripten, which went away in #65501. I've also included a fix for LLVM 8 lacking `MemorySanitizerOptions`, which was broken by #66522.
2019-12-03Change linker for x86_64-fortanix-unknown-sgx to rust-lldParth Sane-1/+3
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-02Update the minimum external LLVM to 7Josh Stone-13/+3
LLVM 7 is over a year old, which should be plenty for compatibility. The last LLVM 6 holdout was llvm-emscripten, which went away in #65501. I've also included a fix for LLVM 8 lacking `MemorySanitizerOptions`, which was broken by #66522.
2019-12-02Use Module::print() instead of a PrintModulePassVictor Ding-40/+3
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-11/+0
LLVM exposes a C API `LLVMAddAnalysisPasses` and hence Rust's own wrapper `LLVMRustAddAnalysisPasses` is not needed anymore.
2019-11-27Rollup merge of #66761 - yuyoyuppe:rust_llvm_minor_fix, r=alexcrichtonTyler Mandry-1/+1
Use LLVMDisposePassManager instead of raw delete in rustllvm LLVM has a dedicated API call which wraps the destructor invocation for the PassManager. Rust invokes it [otherwhere](https://github.com/rust-lang/rust/blob/d63b24ffcc48f44ef09e0369e6516d6f2dec3520/src/librustc_codegen_llvm/back/write.rs#L446-L447), but not in the `LLVMRustWriteOutputFile`. Since `LLVMDisposePassManager` might be extended to perform additional cleanup actions in the future, this change replaces raw destructor invocation with that API call.
2019-11-25Use LLVMDisposePassManager instead of raw delete in rustllvmyuyoyuppe-1/+1
2019-11-22Retain compatibility with LLVM 6, 7, 8 and 9Tomasz Miąsko-4/+21
2019-11-22Move sanitizer passes creation from ssa to llvmTomasz Miąsko-0/+26
2019-11-06Rollup merge of #66062 - smaeul:patch/pic-level, r=estebankMazdak Farrokhzad-0/+4
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-03Configure LLVM module PIC levelSamuel Holland-0/+4
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-10-29Allow specifying key "llvm-abiname" in target specificationGui Andrade-1/+2
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-07-20Don't link mcjit/interpreter LLVM componentsNikita Popov-2/+0
2019-07-15Don't add extra passes into the function pass managerNikita Popov-0/+17
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.