aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/opt/NewPMDriver.cpp
AgeCommit message (Collapse)AuthorFilesLines
7 days[PGO] Drive profile validator from opt (#147418)Mircea Trofin1-2/+6
Add option to `opt` to run the `ProfileInjectorPass` before the passes opt would run, and then `ProfileVerifierPass` after. This will then be a mode in which we run tests on a specialized buildbot, with the goal of finding passes that drop (and, later, corrupt) profile information.
2025-04-14ThinLTO: Add flag to print uselistorder in bitcode writer pass (#133230)Matt Arsenault1-1/+2
This is needed in llvm-reduce to avoid perturbing the uselistorder in intermediate steps. Really llvm-reduce wants pure serialization with no dependency on the pass manager. There are other optimizations mixed in to the serialization here depending on metadata in the module, which is also bad. Part of #63621
2025-03-27[opt][timers] Fix time-passes.ll test failing on reversed iterators (#131941)Alan Zhao1-0/+5
After https://github.com/llvm/llvm-project/pull/131217 was submitted, time-passes.ll fails because `opt` prints `-time-report` when `ManagedTimerGlobals` is destroyed. `ManagedTimerGlobals` stores `TimerGroup`s in an unordered map, so the ordering of the output `TimerGroup`s depends on the underlying iterator. To fix this, we do what Clang does and use `llvm::TimerGroup::printAll(...)`, which *is* deterministic. This is also what Clang does. This does put move analysis section before the pass section for `-time-report`, but again, this is also what Clang currently does.
2025-03-24[NFC] Fix macro redefinition warning in NewPMDriver.cpp (#132854)Rahul Joshi1-0/+2
2025-01-29[PassBuilder] VectorizerEnd Extension Points (#123494)Axel Sorenson1-0/+11
Added an extension point after vectorizer passes in the PassBuilder. Additionally, added extension points before and after vectorizer passes in `buildLTODefaultPipeline`. Credit goes to @mshockwave for guiding me through my first LLVM contribution (and my first open source contribution in general!) :) - Implemented `registerVectorizerEndEPCallback` - Implemented `invokeVectorizerEndEPCallbacks` - Added `VectorizerEndEPCallbacks` SmallVector - Added a command line option `passes-ep-vectorizer-end` to `NewPMDriver.cpp` - `buildModuleOptimizationPipeline` now calls `invokeVectorizerEndEPCallbacks` - `buildO0DefaultPipeline` now calls `invokeVectorizerEndEPCallbacks` - `buildLTODefaultPipeline` now calls BOTH `invokeVectorizerStartEPCallbacks` and `invokeVectorizerEndEPCallbacks` - Added LIT tests to `new-pm-defaults.ll`, `new-pm-lto-defaults.ll`, `new-pm-O0-ep-callbacks.ll`, and `pass-pipeline-parsing.ll` - Renamed `CHECK-EP-Peephole` to `CHECK-EP-PEEPHOLE` in `new-pm-lto-defaults.ll` for consistency. This code is intended for developers that wish to implement and run custom passes after the vectorizer passes in the PassBuilder pipeline. For example, in #91796, a pass was created that changed the induction variables of vectorized code. This is right after the vectorization passes.
2024-11-03[PassBuilder] Add `ThinOrFullLTOPhase` to optimizer pipeline (#114577)Shilei Tian1-2/+2
2024-11-03[PassBuilder] Add `ThinOrFullLTOPhase` to early simplication EP call backs ↵Shilei Tian1-1/+1
(#114547) The early simplication pipeline is used in non-LTO and (Thin/Full)LTO pre-link stage. There are some passes that we want them in non-LTO mode, but not at LTO pre-link stage. The control is missing currently. This PR adds the support. To demonstrate the use, we only enable the internalization pass in non-LTO mode for AMDGPU because having it run in pre-link stage causes some issues.
2024-09-03[NFC][opt] Rename VerifierKind enums (#106789)Arthur Eubanks1-4/+2
Make into enum class. Output really should be InputOutput since it also verifies the input IR.
2024-07-29[lld][LTO] Teach LTO to print pipeline passes (#101018)macurtis-amd1-4/+0
I found this useful while debugging code generation differences between old and new offloading drivers. No functional change (intended).
2024-02-12[PGO] Add ability to mark cold functions as optsize/minsize/optnone (#69030)Arthur Eubanks1-5/+20
The performance of cold functions shouldn't matter too much, so if we care about binary sizes, add an option to mark cold functions as optsize/minsize for binary size, or optnone for compile times [1]. Clang patch will be in a future patch. This is intended to replace `shouldOptimizeForSize(Function&, ...)`. We've seen multiple cases where calls to this expensive function, if not careful, can blow up compile times. I will clean up users of that function in a followup patch. Initial version: https://reviews.llvm.org/D149800 [1] https://discourse.llvm.org/t/rfc-new-feature-proposal-de-optimizing-cold-functions-using-pgo-info/56388
2024-01-24Reland "[CMake/Bazel] Support usage of opt driver as a library (#79205)"Nico Weber1-2/+7
This reverts commit be08be5d5de97cd593fb99affa1fa994d104eb70. The build error was due to a different change, apologies!
2024-01-24Revert "[CMake/Bazel] Support usage of opt driver as a library (#79205)"Nico Weber1-7/+2
This reverts commit 32f7922646d5903f63d16c9fbfe3d508b0f8cda7. Doesn't build, see https://github.com/llvm/llvm-project/pull/79205#issuecomment-1908730527
2024-01-24[CMake/Bazel] Support usage of opt driver as a library (#79205)William Moses1-2/+7
In Bazel, Clang current separates the clang executable into a clang-driver library, and the actual clang executable. This allows downstream users to make their own variations of clang, without having to redo/maintain separate build pipelines. This adds the same for opt for both CMake and Bazel.
2023-07-11Restore "[MemProf] Use new option/pass for profile feedback and matching"Teresa Johnson1-7/+13
This restores commit b4a82b62258c5f650a1cccf5b179933e6bae4867, reverted in 3ab7ef28eebf9019eb3d3c4efd7ebfd160106bb1 because it was thought to cause a bot failure, which ended up being unrelated to this patch set. Differential Revision: https://reviews.llvm.org/D154856
2023-07-11Revert "[MemProf] Use new option/pass for profile feedback and matching"JP Lehr1-13/+7
This reverts commit b4a82b62258c5f650a1cccf5b179933e6bae4867. Broke AMDGPU OpenMP Offload buildbot
2023-07-10[MemProf] Use new option/pass for profile feedback and matchingTeresa Johnson1-7/+13
Previously the MemProf profile was expected to be in the same profile file as a normal PGO profile, passed via the usual -fprofile-use= option, and was matched in the same pass. To simplify profile preparation, since the raw MemProf profile requires the binary for symbolization and may be simpler to index separately from the raw PGO profile, and also to enable providing a MemProf profile for a SamplePGO build, separate out the MemProf feedback option and matching pass. This patch adds the -fmemory-profile-use=${file} option, and the provided file is passed down to LLVM and ultimately used in a new MemProfUsePass which performs the matching of just the memory profile contents of that file. Note that a single profile file containing both normal PGO and MemProf profile data is still supported, and the relevant profile data is matched by the appropriate matching pass(es) based on which option(s) the profile is provided with (the same profile file can be supplied to both feedback options). Differential Revision: https://reviews.llvm.org/D154856
2023-07-05[llvm] A Unified LTO Bitcode FrontendMatthew Voss1-11/+10
Here's a high level summary of the changes in this patch. For more information on rational, see the RFC. (https://discourse.llvm.org/t/rfc-a-unified-lto-bitcode-frontend/61774). - Add config parameter to LTO backend, specifying which LTO mode is desired when using unified LTO. - Add unified LTO flag to the summary index for efficiency. Unified LTO modules can be detected without parsing the module. - Make sure that the ModuleID is generated by incorporating more types of symbols. Differential Revision: https://reviews.llvm.org/D123803
2023-03-16[Debugify] Use ModuleAnalysisManager in instrumentationArthur Eubanks1-2/+2
In preparation for doing module checks of PreservedAnalyses.
2023-03-15Reland [StandardInstrumentations] Check function analysis invalidation in ↵Arthur Eubanks1-1/+1
module passes as well See comments for why we now need to pass in the MAM instead of the FAM. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D146160
2023-03-15Revert "[StandardInstrumentations] Check function analysis invalidation in ↵Arthur Eubanks1-1/+1
module passes as well" This reverts commit d6c0724eb158efcdcd4e31289dcb954a441c4939. Breaks clang/flang builds.
2023-03-15[StandardInstrumentations] Check function analysis invalidation in module ↵Arthur Eubanks1-1/+1
passes as well See comments for why we now need to pass in the MAM instead of the FAM. Reviewed By: nikic Differential Revision: https://reviews.llvm.org/D146160
2023-03-15[Debugify] Invalidate function analysesArthur Eubanks1-2/+2
Since debugify inserts instructions.
2023-02-01[NFC][Profile] Access profile through VirtualFileSystemSteven Wu1-6/+10
Make the access to profile data going through virtual file system so the inputs can be remapped. In the context of the caching, it can make sure we capture the inputs and provided an immutable input as profile data. Reviewed By: akyrtzi, benlangmuir Differential Revision: https://reviews.llvm.org/D139052
2023-01-19[opt] Fix static code analysis concernsArvind Sudarsanam1-3/+9
This is an issue reported inside the NewPMDriver module. Static analyzer reported that Null pointer 'P' may be dereferenced at line 371 and two more sites. Proposed change guards this use. Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D142047
2022-12-13[opt] Do not add verify pass at beginning of pipelineArthur Eubanks1-2/+0
We've already verified the input module manually in opt so this is redundant. Reviewed By: bjope Differential Revision: https://reviews.llvm.org/D139899
2022-12-12[opt] Clean up code related to parsing legacy passes for new PM driver. NFCBjorn Pettersson1-13/+1
Just some minor cleanups given that `opt -passname` syntax is dead for the new pass manager driver.
2022-12-04[Passes] llvm::Optional => std::optionalFangrui Song1-1/+1
2022-12-02[tools] Use std::nullopt instead of None (NFC)Kazu Hirata1-1/+1
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-11-28[opt] Remove "new-pm" from some cl::opt namesArthur Eubanks1-2/+3
2022-11-28[NFC][opt] Move some cl::opts into the only file they're used inArthur Eubanks1-11/+39
2022-11-25Use PassGate from LLVMContext if any otherwise global oneEvgeniy Brevnov1-2/+2
Differential Revision: https://reviews.llvm.org/D137149
2022-11-19Remove unused llvm/IRPrinter/IRPrintingPasses.h or reorder #include after ↵Fangrui Song1-1/+1
D137768
2022-11-18Revert "Revert "[opt][clang] Enable using -module-summary/-flto=thin with ↵Alexander Shaposhnikov1-4/+4
-S/-emit-llvm"" This reverts commit 7f608a2497c7578b9f3ca98014176ab95cffe3c0 and removes the dependency of Object on IRPrinter.
2022-11-18Revert "[opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm"Mikhail Goncharov1-4/+4
This reverts commit 34ab474348e2623cc67abddb7bb662385297ac65. as it has introduced circular dependency lib - analysis
2022-11-18[opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvmAlexander Shaposhnikov1-4/+4
Enable using -module-summary with -S (similarly to what currently can be achieved with opt <input> -o - | llvm-dis). This is a recommit of ef9e62469. Test plan: ninja check-all Differential revision: https://reviews.llvm.org/D137768
2022-11-18[IR] Split out IR printing passes into IRPrinterAlexander Shaposhnikov1-1/+1
This diff splits out (from LLVMCore) IR printing passes into IRPrinter. This structure is similar to what we already have for IRReader and enables us to avoid circular dependencies between LLVMCore and Analysis (this is a preparation for https://reviews.llvm.org/D137768). The legacy interface is left unchanged, once the legacy pass manager is removed (in the future) we will be able to clean it up further. The bazel build configuration has been updated as well. Test plan: 1/ Tested the following cmake configurations: static/dynamic linking * lld/gold * clang/gcc 2/ bazel build --config=generic_clang @llvm-project//... Differential revision: https://reviews.llvm.org/D138081
2022-11-14Revert "[opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm"Fangrui Song1-4/+4
This reverts commit bf8381a8bce28fc69857645cc7e84a72317e693e. There is a layering violation: LLVMAnalysis depends on LLVMCore, so LLVMCore should not include LLVMAnalysis header llvm/Analysis/ModuleSummaryAnalysis.h
2022-11-14[opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvmAlexander Shaposhnikov1-4/+4
Enable using -module-summary with -S (similarly to what currently can be achieved with opt <input> -o - | llvm-dis). This is a recommit of ef9e62469. Test plan: ninja check-all Differential revision: https://reviews.llvm.org/D137768
2022-11-14Revert "[opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvm"Alexander Shaposhnikov1-4/+4
This reverts commit ef9e624694c0f125c53f7d0d3472fd486bada57d for further investigation offline. It appears to break the buildbot llvm-clang-x86_64-sie-ubuntu-fast.
2022-11-14[opt][clang] Enable using -module-summary/-flto=thin with -S/-emit-llvmAlexander Shaposhnikov1-4/+4
Enable using -module-summary with -S (similarly to what currently can be achieved with opt <input> -o - | llvm-dis). Test plan: ninja check-all Differential revision: https://reviews.llvm.org/D137768
2022-10-12[PrintPipeline] Handle CoroConditionalWrapper and add more verificationArthur Eubanks1-1/+24
Add a check (can be disabled via a flag) that the pipeline we generate is actually parsable. Can be disabled because we don't expect to handle every pass in -print-pipeline-passes. Fixes #58280. Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D135703
2022-10-07[opt] Don't translate legacy -analysis flag to require<analysis>Arthur Eubanks1-4/+1
Tests relying on this should explicitly use -passes='require<analysis>,foo'.
2022-10-07[opt] Remove -passes=asan-pipelineArthur Eubanks1-11/+0
It was obsoleted when the asan pass was changed to just be one module pass.
2022-10-07[opt] Stop treating alias analysis specially when translating legacy opt syntaxArthur Eubanks1-28/+3
I've attempted to keep AA tests as close to their original intent as possible.
2022-10-07[opt] Remove temporary legacy pass name translationsArthur Eubanks1-12/+0
And update corresponding tests.
2022-09-06[NFC][asan] Rename ModuleAddressSanitizerPassVitaly Buka1-1/+1
2022-07-06[Debugify] Port verify-debuginfo-preserve to NewPMNikola Tesic1-4/+35
Debugify in OriginalDebugInfo mode, introduced with D82545, runs only with legacy PassManager. This patch enables this utility for the NewPM. Differential Revision: https://reviews.llvm.org/D115351
2022-06-27Delete 'llvm.asan.globals' for global metadata.Mitch Phillips1-2/+0
Now that we have the sanitizer metadata that is actually on the global variable, and now that we use debuginfo in order to do symbolization of globals, we can delete the 'llvm.asan.globals' IR synthesis. This patch deletes the 'location' part of the __asan_global that's embedded in the binary as well, because it's unnecessary. This saves about ~1.7% of the optimised non-debug with-asserts clang binary. Reviewed By: vitalybuka Differential Revision: https://reviews.llvm.org/D127911
2022-03-31[NewPM] Add OptimizerEarly module extension pointWenju He1-0/+11
VectorizerStart extension is module callback in old PM, but is function callback in new PM. We lack a module extension point between end of buildModuleSimplificationPipeline and the function optimization (including vectorizer) pipeline. So this patch adds a new module extension point before the function optimization pipeline. Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D122296
2022-03-24[opt] Remove -analyze optionArthur Eubanks1-1/+0
This is legacy PM-specific, which is deprecated. Uses of this should be replaced with a corresponding `-passes='print<foo>'`. Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D122420