summaryrefslogtreecommitdiffstats
path: root/llvm/tools/gold/gold-plugin.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [ThinLTO] Pass CodeGenOpts like UnrollLoops/VectorizeLoop/VectorizeSLPWei Mi2020-01-091-0/+3
| | | | | | | | | | | | | down to pass builder in ltobackend. Currently CodeGenOpts like UnrollLoops/VectorizeLoop/VectorizeSLP in clang are not passed down to pass builder in ltobackend when new pass manager is used. This is inconsistent with the behavior when new pass manager is used and thinlto is not used. Such inconsistency causes slp vectorization pass not being enabled in ltobackend for O3 + thinlto right now. This patch fixes that. Differential Revision: https://reviews.llvm.org/D72386
* Move CodeGenFileType enum to Support/CodeGen.hReid Kleckner2019-11-131-1/+1
| | | | | | | Avoids the need to include TargetMachine.h from various places just for an enum. Various other enums live here, such as the optimization level, TLS model, etc. Data suggests that this change probably doesn't matter, but it seems nice to have anyway.
* [llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-151-6/+6
| | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
* Rename F_{None,Text,Append} to OF_{None,Text,Append}. NFCFangrui Song2019-08-051-4/+4
| | | | | | F_{None,Text,Append} are kept for compatibility since r334221. llvm-svn: 367800
* Fix gold-plugin Windows buildYi Kong2019-07-231-2/+2
| | | | | | | r365588 missed one instance of integer file descriptor use in gold-plugin.cpp. llvm-svn: 366786
* [Remarks] Extend -fsave-optimization-record to specify the formatFrancis Visoiu Mistrih2019-06-171-0/+4
| | | | | | | | | Use -fsave-optimization-record=<format> to specify a different format than the default, which is YAML. For now, only YAML is supported. llvm-svn: 363573
* Reland: [Remarks] Refactor optimization remarks setupFrancis Visoiu Mistrih2019-06-141-9/+9
| | | | | | | | * Add a common function to setup opt-remarks * Rename common options to the same names * Add error types to distinguish between file errors and regex errors llvm-svn: 363415
* Revert "[Remarks] Refactor optimization remarks setup"Francis Visoiu Mistrih2019-06-141-9/+9
| | | | | | | | This reverts commit 6e6e3af55bb97e1a4c97375c15a2b0099120c5a7. This breaks greendragon. llvm-svn: 363343
* [Remarks] Refactor optimization remarks setupFrancis Visoiu Mistrih2019-06-131-9/+9
| | | | | | | | * Add a common function to setup opt-remarks * Rename common options to the same names * Add error types to distinguish between file errors and regex errors llvm-svn: 363328
* Reland "[Remarks] Add -foptimization-record-passes to filter remark emission"Francis Visoiu Mistrih2019-03-121-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | Currently we have -Rpass for filtering the remarks that are displayed as diagnostics, but when using -fsave-optimization-record, there is no way to filter the remarks while generating them. This adds support for filtering remarks by passes using a regex. Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline` will only emit the remarks coming from the pass `inline`. This adds: * `-fsave-optimization-record` to the driver * `-opt-record-passes` to cc1 * `-lto-pass-remarks-filter` to the LTOCodeGenerator * `--opt-remarks-passes` to lld * `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2 * `-opt-remarks-passes` to gold-plugin Differential Revision: https://reviews.llvm.org/D59268 Original llvm-svn: 355964 llvm-svn: 355984
* Revert "[Remarks] Add -foptimization-record-passes to filter remark emission"Francis Visoiu Mistrih2019-03-121-5/+1
| | | | | | This reverts commit 20fff32b7d1f1a1bd417b22aa9f26ededd97a3e5. llvm-svn: 355976
* [Remarks] Add -foptimization-record-passes to filter remark emissionFrancis Visoiu Mistrih2019-03-121-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | Currently we have -Rpass for filtering the remarks that are displayed as diagnostics, but when using -fsave-optimization-record, there is no way to filter the remarks while generating them. This adds support for filtering remarks by passes using a regex. Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline` will only emit the remarks coming from the pass `inline`. This adds: * `-fsave-optimization-record` to the driver * `-opt-record-passes` to cc1 * `-lto-pass-remarks-filter` to the LTOCodeGenerator * `--opt-remarks-passes` to lld * `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2 * `-opt-remarks-passes` to gold-plugin Differential Revision: https://reviews.llvm.org/D59268 llvm-svn: 355964
* Recommit r354930 "[PGO] Context sensitive PGO (part 1)"Rong Xu2019-02-271-1/+13
| | | | | | Fixed UBSan failures. llvm-svn: 355005
* Revert "[PGO] Context sensitive PGO (part 1)"Vlad Tsyrklevich2019-02-271-13/+1
| | | | | | This reverts commit r354930, it was causing UBSan failures. llvm-svn: 354953
* [PGO] Context sensitive PGO (part 1)Rong Xu2019-02-261-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Current PGO profile counts are not context sensitive. The branch probabilities for the inlined functions are kept the same for all call-sites, and they might be very different from the actual branch probabilities. These suboptimal profiles can greatly affect some downstream optimizations, in particular for the machine basic block placement optimization. In this patch, we propose to have a post-inline PGO instrumentation/use pass, which we called Context Sensitive PGO (CSPGO). For the users who want the best possible performance, they can perform a second round of PGO instrument/use on the top of the regular PGO. They will have two sets of profile counts. The first pass profile will be manly for inline, indirect-call promotion, and CGSCC simplification pass optimizations. The second pass profile is for post-inline optimizations and code-gen optimizations. A typical usage: // Regular PGO instrumentation and generate pass1 profile. > clang -O2 -fprofile-generate source.c -o gen > ./gen > llvm-profdata merge default.*profraw -o pass1.profdata // CSPGO instrumentation. > clang -O2 -fprofile-use=pass1.profdata -fcs-profile-generate -o gen2 > ./gen2 // Merge two sets of profiles > llvm-profdata merge default.*profraw pass1.profdata -o profile.profdata // Use the combined profile. Pass manager will invoke two PGO use passes. > clang -O2 -fprofile-use=profile.profdata -o use This change touches many components in the compiler. The reviewed patch (D54175) will committed in phrases. Differential Revision: https://reviews.llvm.org/D54175 llvm-svn: 354930
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [gold] emit assembly listing from gold plugin on LTO stageTeresa Johnson2019-01-021-1/+11
| | | | | | | | | | | | | | | | | | Summary: Sometimes it's useful to emit assembly after LTO stage to modify it manually. Emitting precodegen bitcode file (via save-temps plugin option) and then feeding it to llc doesn't always give the same binary as original. This patch is simpler alternative to https://reviews.llvm.org/D24020. Patch by Denis Bakhvalov. Reviewers: mehdi_amini, tejohnson Reviewed By: tejohnson Subscribers: MaskRay, inglorion, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D56114 llvm-svn: 350276
* [gold-plugin] allow function/data sections to be toggleableNick Desaulniers2018-12-051-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: r336838 allowed these to be toggleable. r336858 reverted r336838. r336943 made the generation of these sections conditional on LDPO_REL. This commit brings back the toggle-ability. You can specify: -plugin-opt=-function-sections -plugin-opt=-data-sections For your linker flags to disable the changes made in r336943. Without toggling r336943 off, arm64 linux kernels linked with gold-plugin see significant boot time regressions, but with r336943 outright reverted x86_64 linux kernels linked with gold-plugin fail to boot. Reviewers: pcc, void Reviewed By: pcc Subscribers: javed.absar, kristof.beyls, llvm-commits, srhines Differential Revision: https://reviews.llvm.org/D55291 llvm-svn: 348389
* [gold-plugin] Fix a bunch of build warningsMandeep Singh Grang2018-11-011-3/+2
| | | | | Phabricator: https://reviews.llvm.org/D53997 llvm-svn: 345910
* Silence -Wimplicit-fallthrough in gold pluginReid Kleckner2018-11-011-0/+1
| | | | | | | Fatal errors are likely fatal, but in case they aren't, return instead of printing a second warning. llvm-svn: 345894
* [gold] -thinlto-object-suffix-replace: don't append new suffix if path does ↵Fangrui Song2018-08-221-7/+3
| | | | | | | | | | | | | | | | not end with old suffix Summary: This is to be consistent with lld behavior since rLLD340364. Reviewers: tejohnson Reviewed By: tejohnson Subscribers: steven_wu, eraman, mehdi_amini, inglorion, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D51060 llvm-svn: 340380
* [gold-plugin] Disable section ordering for relocatable linksBill Wendling2018-07-121-3/+5
| | | | | | | | | | | | Not all programs want section ordering when compiled with LTO. In particular, the Linux kernel is very sensitive when it comes to linking, and doesn't boot when each function is placed in its own sections. Reviewed By: pcc Differential Revision: https://reviews.llvm.org/D48756 llvm-svn: 336943
* Temporarily reverting.Bill Wendling2018-07-111-5/+3
| | | | llvm-svn: 336858
* gold: Add ability to toggle function/data sectionsBill Wendling2018-07-111-3/+5
| | | | | | | | | | | Some programs (e.g. Linux) aren't able to handle function/data sections when LTO is used. Thus they need a way to disable it. That can be done with these plugin options: -plugin-opt=-function-sections=0 -plugin-opt=-data-sections=0 llvm-svn: 336838
* Set the code model when specified.Bill Wendling2018-06-131-0/+1
| | | | llvm-svn: 334571
* Try to fix build.Zachary Turner2018-06-071-1/+1
| | | | | | | | I don't know how to build this code, but based on the failing buildbot error message it looks like this change should get the buildbot up and running again. llvm-svn: 334231
* [ThinLTO] Rename index IsAnalysis flag to HaveGVs (NFC)Teresa Johnson2018-06-061-1/+1
| | | | | | | | | With the upcoming patch to add summary parsing support, IsAnalysis would be true in contexts where we are not performing module summary analysis. Rename to the more specific and approprate HaveGVs, which is essentially what this flag is indicating. llvm-svn: 334140
* LTO: Replace split dwarf implementation that uses objcopy with one that uses ↵Peter Collingbourne2018-05-211-6/+0
| | | | | | | | | | direct emission. Part of PR37466. Differential Revision: https://reviews.llvm.org/D47091 llvm-svn: 332884
* [LTO] Add stats-file option to LTO/Config.h.Florian Hahn2018-04-201-0/+5
| | | | | | | | | | | | | This patch adds a StatsFile option to LTO/Config.h and updates both LLVMGold and llvm-lto2 to set it. Reviewers: MatzeB, tejohnson, espindola Reviewed By: tejohnson Differential Revision: https://reviews.llvm.org/D45531 llvm-svn: 330411
* [gold/ThinLTO] Invoke llvm_shutdown when exiting after ThinLTO indexingTeresa Johnson2018-04-191-2/+1
| | | | | | | | | | | | | | | | Summary: Instead of manually invoking PrintStatistics, simply invoke llvm_shutdown which will take care of destroying managed statics, and as a side effect will destroy the StatisticInfo ManagedStatic, invoking PrintStatistics when needed. Reviewers: fhahn Subscribers: inglorion, llvm-commits Differential Revision: https://reviews.llvm.org/D45820 llvm-svn: 330341
* [gold] Add support for optimization remarksTeresa Johnson2018-04-181-0/+12
| | | | | | | | | | | | | | Summary: Adds support for LTO opt remarks (optionally with hotness) to gold-plugin. Reviewers: anemet Subscribers: fhahn, mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D45752 llvm-svn: 330252
* Enable debug fission for thinLTO linked via gold-pluginYunlian Jiang2018-04-131-0/+12
| | | | | | | | | | | | | | Summary: This enables debug fission on implicit ThinLTO when linked with gold. It will put the .dwo files in a directory specified by user. Reviewers: tejohnson, pcc, dblaikie Reviewed By: pcc Subscribers: JDevlieghere, mehdi_amini, inglorion Differential Revision: https://reviews.llvm.org/D44792 llvm-svn: 329988
* Rename *CommandFlags.def to *CommandFlags.incDavid Blaikie2018-04-111-1/+1
| | | | | | | | These aren't the .def style files used in LLVM that require a macro defined before their inclusion - they're just basic non-modular includes to stamp out command line flag variables. llvm-svn: 329840
* Revert r324557, "gold-plugin: Do not set codegen opt level based on LTO opt ↵Peter Collingbourne2018-04-061-0/+15
| | | | | | | | | | | | | level." It was reported that this change measurably regressed -plugin-opt=O3 performance. There is an ongoing discussion on llvm-dev about the correct way to set the CG opt level, see thread "[llvm-dev] [RFC] Adding function attributes to represent codegen optimization level". llvm-svn: 329458
* [gold] Add debug-pass-manager option, and use it to test new-pass-managerTeresa Johnson2018-04-051-0/+6
| | | | | | | | | | | | Summary: Follow up from r314963. Reviewers: pcc Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45293 llvm-svn: 329249
* [LTO/gold] Fix workaround for old plugin-api.h in --wrap supportTeresa Johnson2018-03-141-1/+1
| | | | | | | | | | | | The workaround for older plugin-api.h in r327506 unfortunately used another union member that is also fairly new and not available in the plugin-api.h on some of the bots, leading to: http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/9121/steps/build-stage2-LLVMgold.so/logs/stdio Change to use a different member that we will definitely have (as it is used elsewhere in gold-plugin.cpp already). llvm-svn: 327509
* [LTO/gold] Support --wrapTeresa Johnson2018-03-141-0/+48
| | | | | | | | | | | | | | | | | | | | Summary: (Restores r327459 with handling for old plugin-api.h) Utilize new gold plugin api interface for obtaining --wrap option arguments, and LTO API handling (added for --wrap support in lld LTO), to mark symbols so that LTO does not optimize them inappropriately. Note the test cases will be in a new gold test subdirectory that is dependent on the next release of gold which will contain the new interfaces. Reviewers: pcc, tmsriram Subscribers: mehdi_amini, llvm-commits, inglorion Differential Revision: https://reviews.llvm.org/D44235 llvm-svn: 327506
* Revert "[LTO/gold] Support --wrap"Teresa Johnson2018-03-131-35/+0
| | | | | | | | This reverts commit r327459. The new gold plugin interface is not available with older gold installations, leading to compile failures: http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/9109/steps/build-stage2-LLVMgold.so/logs/stdio llvm-svn: 327465
* [LTO/gold] Support --wrapTeresa Johnson2018-03-131-0/+35
| | | | | | | | | | | | | | | | | | | Summary: Utilize new gold plugin api interface for obtaining --wrap option arguments, and LTO API handling (added for --wrap support in lld LTO), to mark symbols so that LTO does not optimize them inappropriately. Note the test cases will be in a new gold test subdirectory that is dependent on the next release of gold which will contain the new interfaces. Reviewers: pcc, tmsriram Subscribers: mehdi_amini, llvm-commits, inglorion Differential Revision: https://reviews.llvm.org/D44235 llvm-svn: 327459
* [ThinLTO/gold] Perform cache pruning when cache directory specifiedTeresa Johnson2018-02-221-1/+1
| | | | | | | | | | | | | | | Summary: As pointed out in the review for D37993, for consistency with other linkers, gold plugin should perform cache pruning whenever there is a cache directory specified, which will use the default cache policy. Reviewers: pcc Subscribers: llvm-commits, inglorion Differential Revision: https://reviews.llvm.org/D43389 llvm-svn: 325830
* [ThinLTO] Always create linked objects file for --thinlto-index-only=Vitaly Buka2018-02-221-7/+29
| | | | | | | | | | | | | | | Summary: ThinLTO indexing may decide to skip all objects. If we don't write something to the list build system may consider this as failure or linker can reuse a file from the previews build. Reviewers: pcc, tejohnson Subscribers: mehdi_amini, inglorion, eraman, hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D43415 llvm-svn: 325819
* [gold] Extract runLTO to avoid exit(0) from function with non-trivial ↵Vitaly Buka2018-02-221-17/+23
| | | | | | | | | | | | objects on the stack Reviewers: tejohnson, pcc Subscribers: inglorion, llvm-commits Differential Revision: https://reviews.llvm.org/D43537 llvm-svn: 325818
* [LTO] Remove unused Path parameter to AddBufferFnTeresa Johnson2018-02-201-2/+1
| | | | | | | | | | | | | | | Summary: With D43396, no clients use the Path parameter anymore. Depends on D43396. Reviewers: pcc Subscribers: mehdi_amini, inglorion, llvm-commits Differential Revision: https://reviews.llvm.org/D43400 llvm-svn: 325619
* [ThinLTO/gold] Avoid race with cache pruner by copying to temp filesTeresa Johnson2018-02-201-3/+1
| | | | | | | | | | | | | | | | | | | Summary: This will avoid the race condition described in the review for D37993. I believe that the Path parameter to AddBufferFn is no longer utilized. I would prefer to remove that as a follow up clean up patch to reduce the diffs in this patch. Reviewers: pcc Reviewed By: pcc Subscribers: inglorion, llvm-commits Differential Revision: https://reviews.llvm.org/D43396 llvm-svn: 325618
* [ThinLTO] Allow indexing to request backend to ignore the moduleVitaly Buka2018-02-161-3/+19
| | | | | | | | | | | | | | | | | | Summary: Gold plugin does not add pass to ThinLTO modules without useful symbols. In this case ThinLTO can't create corresponding index file and some features, like CFI, cannot be processes by backed correctly without index. Given that we don't need the backed output we can request it to avoid processing the module. This is implemented by this patch using new "SkipModuleByDistributedBackend" flag. Reviewers: pcc, tejohnson Subscribers: mehdi_amini, inglorion, eraman, cfe-commits Differential Revision: https://reviews.llvm.org/D42995 llvm-svn: 325411
* Pass a reference to a module to the bitcode writer.Rafael Espindola2018-02-141-1/+1
| | | | | | | This simplifies most callers as they are already using references or std::unique_ptr. llvm-svn: 325155
* gold-plugin: Do not set codegen opt level based on LTO opt level.Peter Collingbourne2018-02-081-15/+0
| | | | | | | | | | | The LTO opt level should not affect the codegen opt level, and indeed it does not affect it in lld. Ideally the codegen opt level should be controlled by an IR-level attribute based on the compile-time opt level, but that hasn't been implemented yet. Differential Revision: https://reviews.llvm.org/D43040 llvm-svn: 324557
* [ThinLTO/gold] Write empty imports even for modules with symbolsVitaly Buka2018-01-301-18/+23
| | | | | | | | | | | | Summary: ThinLTO may skip object for other reasons, e.g. if there is no summary. Reviewers: pcc, eugenis Subscribers: mehdi_amini, inglorion, eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D42514 llvm-svn: 323818
* [LLVMgold] Don't set undefined symbol as prevailingEugene Leviant2017-12-151-3/+7
| | | | | | Differential revision: https://reviews.llvm.org/D41113 llvm-svn: 320794
* Rename CommandFlags.h -> CommandFlags.defDavid Blaikie2017-11-271-1/+1
| | | | | | | | | Since this isn't a real header - it includes static functions and had external linkage variables (though this change makes them static, since that's what they should be) so can't be included more than once in a program. llvm-svn: 319082
OpenPOWER on IntegriCloud