about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
AgeCommit message (Collapse)AuthorLines
2023-02-14Add `kernel-address` sanitizer support for freestanding targetsWesley Norris-3/+7
2023-02-10Update the minimum external LLVM to 14Josh Stone-41/+3
2023-02-02llvm-wrapper: adapt for LLVM API changesKrasimir Georgiev-8/+30
Adapts the wrapper for https://github.com/llvm/llvm-project/commit/516e301752560311d2cd8c2b549493eb0f98d01b, where the constructor of PGOOptions gained a new FileSystem argument. Adapted to use the real file system, similarly to the changes inside of LLVM: https://github.com/llvm/llvm-project/commit/516e301752560311d2cd8c2b549493eb0f98d01b#diff-f409934ba27ad86494f3012324e9a3995b56e0743609ded7a387ba62bbf5edb0R236
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-2/+2
2022-12-11llvm-wrapper: adapt for LLVM API changesKrasimir Georgiev-0/+4
This is a follow-up of https://github.com/rust-lang/rust/commit/75aec4703dea7ef8e13924ccfa3a3d2e8c5c7cff. There, I updated the wrapper to only include llvm/ADT/Optional.h for LLVM version below 16. But I missed updating some of the None references. Found by our experimental rust + llvm at HEAD bot: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/15587#0185006b-e0af-49e5-8b06-280ed125ff0d/200-539
2022-12-06llvm-wrapper: adapt for and LLVM API changeKrasimir Georgiev-1/+10
2022-11-25[llvm-wrapper] adapt for LLVM API changeKrasimir Georgiev-0/+4
Adapt for the LLVM API changes from https://github.com/llvm/llvm-project/commit/721f975d3518403502f770ce11f3f02509b30c5b#diff-5a347903b8412ed1b1b1948c3fce47f9a6ff05dc70bfaeedb6d06b622e399d91.
2022-11-17Throw error on failure in loading llvm-pluginDivam Narula-1/+1
2022-10-25llvm-16: Don't initialize removed legacy passesMatthew Maurer-0/+2
LLVM removed initialization for legacy passes: https://reviews.llvm.org/D136615
2022-09-26Avoid LLVM-deprecated `Optional::hasValue`Josh Stone-1/+1
LLVM 15 added `Optional::has_value`, and LLVM `main` (16) has deprecated `hasValue`. However, its `explicit operator bool` does the same thing, and was added long ago, so we can use that across our full LLVM range of compatibility.
2022-09-18Use the helper for internalizing with new PMJosh Stone-5/+2
2022-09-18Never use legacy PM for writing bitcodeJosh Stone-12/+2
2022-09-18Remove support for LLVM's legacy pass managerJosh Stone-234/+1
2022-09-09Rollup merge of #99207 - 5225225:msan-eager-checks, r=jackh726Matthias Krüger-1/+14
Enable eager checks for memory sanitizer Fixes #99179
2022-09-07llvm-wrapper: adapt for LLVM API changesKrasimir Georgiev-1/+7
No functional changes intended. Adapts PassWrapper for two recent LLVM API changes: * https://github.com/llvm/llvm-project/commit/e7bac3b9fa739f8d167a390a547068aad1d424a7 * https://github.com/llvm/llvm-project/commit/93600eb50ceeec83c488ded24fa0fd25f997fec6 * https://github.com/llvm/llvm-project/commit/5e38b2a456df6e263a509af60a731cec57310498
2022-08-17llvm-wrapper: use new pass manager for thin lto with LLVM version 15Krasimir Georgiev-2/+23
No functional changes intended. LLVM commit https://github.com/llvm/llvm-project/commit/633f5663c37a670e28040cadd938200abd854483 removed `createWriteThinLTOBitcodePass`. This adapts PassWrapper similarly to the example mentioned upstream: https://github.com/llvm/llvm-project/commit/633f5663c37a670e28040cadd938200abd854483.
2022-08-16Rollup merge of #100460 - cuviper:drop-llvm-12, r=nagisaMatthias Krüger-17/+1
Update the minimum external LLVM to 13 With this change, we'll have stable support for LLVM 13 through 15 (pending release). For reference, the previous increase to LLVM 12 was #90175. r? `@nagisa`
2022-08-14Update the minimum external LLVM to 13Josh Stone-17/+1
2022-08-14Enable eager checks for memory sanitizer5225225-1/+14
2022-08-11Add support for generating unique *.profraw files by default when using the ↵ridwanabdillahi-2/+6
`-C instrument-coverage` flag. Respond to PR comments.
2022-07-26Remove dead code from cg_llvmbjorn3-45/+0
2022-07-21Auto merge of #98162 - nextsilicon:support_lto_embed_bitcode, r=davidtwcobors-2/+7
Allow to disable thinLTO buffer to support lto-embed-bitcode lld feature Hello This change is to fix issue (https://github.com/rust-lang/rust/issues/84395) in which passing "-lto-embed-bitcode=optimized" to lld when linking rust code via linker-plugin-lto doesn't produce the expected result. Instead of emitting a single unified module into a llvmbc section of the linked elf, it emits multiple submodules. This is caused because rustc emits the BC modules after running llvm `createWriteThinLTOBitcodePass` pass. Which in turn triggers a thinLTO linkage and causes the said issue. This patch allows via compiler flag (-Cemit-thin-lto=<bool>) to select between running `createWriteThinLTOBitcodePass` and `createBitcodeWriterPass`. Note this pattern of selecting between those 2 passes is common inside of LLVM code. The default is to match the old behavior.
2022-07-16Auto merge of #95685 - oxidecomputer:restore-static-dwarf, r=pnkfelixbors-2/+2
Revert "Work around invalid DWARF bugs for fat LTO" Since September, the toolchain has not been generating reliable DWARF information for static variables when LTO is on. This has affected projects in the embedded space where the use of LTO is typical. In our case, it has kept us from bumping past the 2021-09-22 nightly toolchain lest our debugger break. This has been a pretty dramatic regression for people using debuggers and static variables. See #90357 for more info and a repro case. This commit is a mechanical revert of d5de680e20def848751cb3c11e1182408112b1d3 from PR #89041, which caused the issue. (Note on that PR that the commit's author has requested it be reverted.) I have locally verified that this fixes #90357 by restoring the functionality of both the repro case I posted on that bug, and debugger behavior on real programs. There do not appear to be test cases for this in the toolchain; if I've missed them, point me at 'em and I'll update them.
2022-07-14rustc: add ability to output regular LTO bitcode modulesZiv Dunkelman-2/+7
Adding the option to control from rustc CLI if the resulted ".o" bitcode module files are with thinLTO info or regular LTO info. Allows using "-lto-embed-bitcode=optimized" during linkage correctly. Signed-off-by: Ziv Dunkelman <ziv.dunkelman@nextsilicon.com>
2022-06-28llvm-wrapper: adapt for an LLVM API changeKrasimir Georgiev-0/+2
This adapts llvm-wrapper for https://github.com/llvm/llvm-project/commit/dacfa24f75c328ae30b710ecadaa18e4ba10cdc6, which removed ASanGlobalsMetadataAnalysis.
2022-04-20Stub out more PassManagerBuilder functionsNikita Popov-1/+52
2022-04-20Stub out various legacy PM functions with LLVM 15Nikita Popov-0/+44
2022-04-10Respect -Z verify-llvm-ir and other flags that add extra passes when ↵Luqman Aden-0/+7
combined with -C no-prepopulate-passes in the new LLVM Pass Manager.
2022-04-05Revert "Work around invalid DWARF bugs for fat LTO"Cliff L. Biffle-2/+2
Since September, the toolchain has not been generating reliable DWARF information for static variables when LTO is on. This has affected projects in the embedded space where the use of LTO is typical. In our case, it has kept us from bumping past the 2021-09-22 nightly toolchain lest our debugger break. This has been a pretty dramatic regression for people using debuggers and static variables. See #90357 for more info and a repro case. This commit is a mechanical revert of d5de680e20def848751cb3c11e1182408112b1d3 from PR #89041, which caused the issue. (Note on that PR that the commit's author has requested it be reverted.) I have locally verified that this fixes #90357 by restoring the functionality of both the repro case I posted on that bug, and debugger behavior on real programs. There do not appear to be test cases for this in the toolchain; if I've missed them, point me at 'em and I'll update them.
2022-01-14Remove LLVMRustMarkAllFunctionsNounwindAmanieu d'Antras-19/+0
This was originally introduced in #10916 as a way to remove all landing pads when performing LTO. However this is no longer necessary today since rustc properly marks all functions and call-sites as nounwind where appropriate. In fact this is incorrect in the presence of `extern "C-unwind"` which must create a landing pad when compiled with `-C panic=abort` so that foreign exceptions are caught and properly turned into aborts.
2021-12-13Use the existing llvm-plugins option for both legacy and new pm registrationAxel Cohen-4/+4
2021-12-13Add a codegen option to allow loading LLVM pass pluginsAxel Cohen-1/+17
2021-11-11PassWrapper: additional sanitizer update to match clangKrasimir Georgiev-1/+0
This happened later in the stream than the other changes, but the fix is overlapping. Fix taken from a55c4ec1cee7683d9095327d9d33e7137ec25292 in LLVM.
2021-11-09Didn't mean to invert this boolean.Augie Fackler-1/+1
2021-11-09rustc_llvm: update PassWrapper for recent LLVMAugie Fackler-6/+9
Now AddressSanitizerOptions is a struct, but at least the change was tiny. r? nikic
2021-11-05Initialize LLVM time trace profiler on each code generation threadTomasz Miąsko-0/+4
In https://reviews.llvm.org/D71059 LLVM 11, the time trace profiler was extended to support multiple threads. `timeTraceProfilerInitialize` creates a thread local profiler instance. When a thread finishes `timeTraceProfilerFinishThread` moves a thread local instance into a global collection of instances. Finally when all codegen work is complete `timeTraceProfilerWrite` writes data from the current thread local instance and the instances in global collection of instances. Previously, the profiler was intialized on a single thread only. Since this thread performs no code generation on its own, the resulting profile was empty. Update LLVM codegen to initialize & finish time trace profiler on each code generation thread.
2021-10-25Rollup merge of #89581 - jblazquez:master, r=Mark-SimulacrumMatthias Krüger-0/+2
Add -Z no-unique-section-names to reduce ELF header bloat. This change adds a new compiler flag that can help reduce the size of ELF binaries that contain many functions. By default, when enabling function sections (which is the default for most targets), the LLVM backend will generate different section names for each function. For example, a function `func` would generate a section called `.text.func`. Normally this is fine because the linker will merge all those sections into a single one in the binary. However, starting with [LLVM 12](https://github.com/llvm/llvm-project/commit/ee5d1a04), the backend will also generate unique section names for exception handling, resulting in thousands of `.gcc_except_table.*` sections ending up in the final binary because some linkers like LLD don't currently merge or strip these EH sections (see discussion [here](https://reviews.llvm.org/D83655)). This can bloat the ELF headers and string table significantly in binaries that contain many functions. The new option is analogous to Clang's `-fno-unique-section-names`, and instructs LLVM to generate the same `.text` and `.gcc_except_table` section for each function, resulting in a smaller final binary. The motivation to add this new option was because we have a binary that ended up with so many ELF sections (over 65,000) that it broke some existing ELF tools, which couldn't handle so many sections. Here's our old binary: ``` $ readelf --sections old.elf | head -1 There are 71746 section headers, starting at offset 0x2a246508: $ readelf --sections old.elf | grep shstrtab [71742] .shstrtab STRTAB 0000000000000000 2977204c ad44bb 00 0 0 1 ``` That's an 11MB+ string table. Here's the new binary using this option: ``` $ readelf --sections new.elf | head -1 There are 43 section headers, starting at offset 0x29143ca8: $ readelf --sections new.elf | grep shstrtab [40] .shstrtab STRTAB 0000000000000000 29143acc 0001db 00 0 0 1 ``` The whole binary size went down by over 20MB, which is quite significant.
2021-10-22Update the minimum external LLVM to 12Josh Stone-74/+2
2021-10-22Update the minimum external LLVM to 11Josh Stone-93/+0
2021-10-18RustWrapper: adapt for an LLVM API changeKrasimir Georgiev-0/+5
No functional changes intended. The LLVM commit https://github.com/llvm/llvm-project/commit/89b57061f7b769e9ea9bf6ed686e284f3e55affe moved TargetRegistry.(h|cpp) from Support to MC. This adapts RustWrapper accordingly.
2021-10-11Add -Z no-unique-section-names to reduce ELF header bloat.Javier Blazquez-0/+2
This change adds a new compiler flag that can help reduce the size of ELF binaries that contain many functions. By default, when enabling function sections (which is the default for most targets), the LLVM backend will generate different section names for each function. For example, a function "func" would generate a section called ".text.func". Normally this is fine because the linker will merge all those sections into a single one in the binary. However, starting with LLVM 12 (llvm/llvm-project@ee5d1a0), the backend will also generate unique section names for exception handling, resulting in thousands of ".gcc_except_table.*" sections ending up in the final binary because some linkers don't currently merge or strip these EH sections. This can bloat the ELF headers and string table significantly in binaries that contain many functions. The new option is analogous to Clang's -fno-unique-section-names, and instructs LLVM to generate the same ".text" and ".gcc_except_table" section for each function, resulting in smaller object files and potentially a smaller final binary.
2021-10-06Enable AutoFDO.Michael Benfield-9/+21
This largely involves implementing the options debug-info-for-profiling and profile-sample-use and forwarding them on to LLVM. AutoFDO can be used on x86-64 Linux like this: rustc -O -Cdebug-info-for-profiling main.rs -o main perf record -b ./main create_llvm_prof --binary=main --out=code.prof rustc -O -Cprofile-sample-use=code.prof main.rs -o main2 Now `main2` will have feedback directed optimization applied to it. The create_llvm_prof tool can be obtained from this github repository: https://github.com/google/autofdo Fixes #64892.
2021-09-27PassWrapper: handle function rename from upstream D36850Augie Fackler-0/+4
thinLTOResolvePrevailingInModule became thinLTOFinalizeInModule and gained the ability to propagate noRecurse and noUnwind function attributes. I ran codegen tests with it both on and off, as the upstream patch uses it in both modes, and the tests pass both ways. Given that, it seemed reasonable to go ahead and let the propagation be enabled in rustc, and see what happens. See https://reviews.llvm.org/D36850 for more examples of how the new version of the function gets used.
2021-09-25Use correct pipeline for LTO at O0Nikita Popov-1/+4
Unlike the pre-link piplines, the LTO pipelines do support O0, and using them is required to avoid leaving behind undefined references for the linker.
2021-09-22Rollup merge of #89041 - sticnarf:sticnarf/fat-lto-dwarf, r=nagisathe8472-2/+2
Work around invalid DWARF bugs for fat LTO This PR applies the same workaround in #46772 to fat LTO. It seems to fix the bug reported in https://github.com/rust-lang/rust/issues/66118#issuecomment-917434036.
2021-09-17Work around invalid DWARF bugs for fat LTOYilin Chen-2/+2
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
2021-09-17compiler/rustc_llvm: Enable M68k LLVM targetJohn Paul Adrian Glaubitz-0/+7
2021-09-16PassWrapper: these two lines shouldn't have been ifdef'dAugie Fackler-2/+2
2021-09-16PassWrapper: handle separate Module*SanitizerPassAugie Fackler-0/+8
Change ab41eef9aca3 in LLVM split MemorySanitizerPass into MemorySanitizerPass for functions and ModuleMemorySanitizerPass for modules. There's a related change for ThreadSanitizerPass, and in here since we're using a ModulePassManager I only add the module flavor of the pass on LLVM 14. r? @nikic cc @nagisa
2021-08-19PassWrapper: adapt for LLVM 14 changesAugie Fackler-0/+15
These API changes appear to have all taken place in https://reviews.llvm.org/D105007, which moved HWAddressSanitizerPass and AddressSanitizerPass to only accept their options type as a ctor argument instead of the sequence of bools etc. This required a couple of parameter additions, which I made match the default prior to the mentioned upstream LLVM change. This patch restores rustc to building (though not quite passing all tests, I've mailed other patches for those issues) against LLVM HEAD.