Commit Graph

159 Commits

Author SHA1 Message Date
Francis Visoiu Mistrih dd42236c6c Reland "[Remarks] Add -foptimization-record-passes to filter remark emission"
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
2019-03-12 21:22:27 +00:00
Francis Visoiu Mistrih 1d6c47ad2b Revert "[Remarks] Add -foptimization-record-passes to filter remark emission"
This reverts commit 20fff32b7d.

llvm-svn: 355976
2019-03-12 20:54:18 +00:00
Francis Visoiu Mistrih 20fff32b7d [Remarks] Add -foptimization-record-passes to filter remark emission
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
2019-03-12 20:28:50 +00:00
Rong Xu f92e59cbba [PGO] Add options for context-sensitive PGO
Add lld options for CSPGO (context-sensitive PGO).

Differential Revision: https://reviews.llvm.org/D56675

llvm-svn: 355876
2019-03-11 22:51:38 +00:00
Bill Wendling 01706bda5b Output ELF files after ThinLTO is run.
Summary:
The gold linker allowed you to output the ELF files after LTO was run. It did
it by using the 'obj-path' option. This replicates that behavior.

Reviewers: espindola, ruiu, MaskRay, pcc

Reviewed By: MaskRay, pcc

Subscribers: grimar, emaste, inglorion, arichardson, steven_wu, dexonsmith, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D56046

llvm-svn: 354917
2019-02-26 19:29:14 +00:00
Sam Clegg dfbd19033b Fix names of functions in TargetOptionsCommandFlags.h. NFC.
Differential Revision: https://reviews.llvm.org/D57555

llvm-svn: 352825
2019-02-01 02:24:50 +00:00
Sam Clegg 5cdc91d003 [LTO] Set CGOptLevel in LTO config.
Previously we were never setting this which means it was always being
set to Default (-O2/-Os).

Differential Revision: https://reviews.llvm.org/D57422

llvm-svn: 352667
2019-01-30 20:46:18 +00:00
Chandler Carruth 2946cd7010 Update the file headers across all of the LLVM projects in the monorepo
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
2019-01-19 08:50:56 +00:00
Rui Ueyama 9f49990976 Add --plugin-opt=emit-llvm option.
`--plugin-opt=emit-llvm` is an option for LTO. It makes the linker to
combine all bitcode files and write the result to an output file without
doing codegen. Gold LTO plugin has this option.

This option is being used for some post-link code analysis tools that
have to see a whole program but don't need to see them in the native
machine code.

Differential Revision: https://reviews.llvm.org/D55717

llvm-svn: 349198
2018-12-14 21:58:49 +00:00
Fangrui Song ccfc8415c2 Set MAttrs in LTO mode
Summary: Without this patch, MAttrs are not set.

Patch by Yin Ma

Reviewers: espindola, MaskRay, ruiu, pcc

Reviewed By: MaskRay, pcc

Subscribers: pcc, emaste, sbc100, inglorion, arichardson, aheejin, steven_wu, llvm-commits

Differential Revision: https://reviews.llvm.org/D53446

llvm-svn: 345884
2018-11-01 20:02:49 +00:00
Rui Ueyama 98e4a5ca11 Simplify.
Instead of Map<StringRef, bool>, we can simply use Set<StringRef>.

llvm-svn: 341948
2018-09-11 14:37:27 +00:00
Peter Collingbourne 82a7f144a4 ELF: Enable address-significance tables during LTO.
This allows safe ICF to work when linking with LTO.

Differential Revision: https://reviews.llvm.org/D50221

llvm-svn: 339050
2018-08-06 20:12:12 +00:00
Yunlian Jiang 496fb3e7a0 Support option -plugin-opt=dwo_dir=
Summary:
This adds support to option -plugin-opt=dwo_dir=${DIR}. This option is used to specify the directory to store the .dwo files when LTO and debug fission is used
at the same time.

Reviewers: ruiu, espindola, pcc

Reviewed By: pcc

Subscribers: eraman, dexonsmith, mehdi_amini, emaste, arichardson, steven_wu, llvm-commits

Differential Revision: https://reviews.llvm.org/D47904

llvm-svn: 337195
2018-07-16 17:55:48 +00:00
George Rimar 046fa610e0 [ELF] - Remove dead code. NFC.
I think code is dead, because the only way to see
Path as empty seems would be if replaceThinLTOSuffix()
replaced some prefix with empty prefix (making the result
Path empty).

But it is impossible to pass the empty prefix,
we would file in driver:
https://github.com/llvm-mirror/lld/blob/master/ELF/Driver.cpp#L669

llvm-svn: 336338
2018-07-05 11:58:04 +00:00
Teresa Johnson 566b402a13 [ThinLTO/lld] Document constant bool ModuleSummaryIndex parameter (NFC)
Makes this consistent with other ModuleSummaryIndex constructor calls.

llvm-svn: 334141
2018-06-06 22:22:13 +00:00
Fangrui Song bdbe5d8477 Revert "[ELF] Simplify. NFC"
This reverts commit cc6f052261096dc9d4c9d3123e37b023c3e171df.

llvm-svn: 333099
2018-05-23 16:51:23 +00:00
Sam Clegg 3ad27e92bc Code cleanup in preparation for adding LTO for wasm. NFC.
- Move some common code into Common/rrorHandler.cpp and
  Common/Strings.h.
- Don't use `fatal` when incompatible bitcode files are
  encountered.
- Rename NameRef variable to just Name

See D47162

Differential Revision: https://reviews.llvm.org/D47206

llvm-svn: 333021
2018-05-22 20:20:25 +00:00
Fangrui Song bfd08534b0 [ELF] Simplify. NFC
llvm-svn: 332952
2018-05-22 06:28:00 +00:00
Rui Ueyama f06d494f46 Improve error message for -thinlto-object-suffix-replace and simplify code.
llvm-svn: 332643
2018-05-17 18:27:12 +00:00
Rumeet Dhindsa d2eb089a0e Add support for ThinLTO plugin option thinlto-object-suffix-replace
Differential Revision: https://reviews.llvm.org/D46608

llvm-svn: 332527
2018-05-16 21:04:08 +00:00
Rumeet Dhindsa b5b7d6e19c Add support for LTO plugin option obj-path
Differential Revision: https://reviews.llvm.org/D46598

llvm-svn: 331817
2018-05-08 22:37:57 +00:00
Rumeet Dhindsa 1888326b2d Update ThinLTO Indexing logic
Instead of writing empty index for file, this patch tracks the state of files in ObjectToIndexFileState. If the files are not indexed , only then we emit the empty files

Differential Revision: https://reviews.llvm.org/D46480

llvm-svn: 331803
2018-05-08 20:12:07 +00:00
Rui Ueyama d31b54b3c1 Refactor BitcodeCompiler::add(). NFC.
This change makes it explicit that the main loop iterates over a
parallel array, Syms and ObjSyms.

llvm-svn: 331780
2018-05-08 17:50:54 +00:00
Rui Ueyama 2f9fa42892 Fix a bug that a copy of a large vector was created. NFC.
llvm-svn: 331779
2018-05-08 17:50:43 +00:00
Rui Ueyama cdf8d06426 Rename a local variable whose scope is very narrow. NFC.
llvm-svn: 331703
2018-05-07 23:43:48 +00:00
Rui Ueyama d432f216d1 Rename Config::ThinLTOIndexOnlyObjectFiles -> Config::ThinLTOIndexOnlyArg.
llvm-svn: 331699
2018-05-07 23:24:16 +00:00
Rui Ueyama 397dffd81b Split BitcodeCompiler::init() into two functions. NFC.
Previously, code to initialize Backend and code to initialize Conf are
intermingled in init(), though they don't depend on each other.

Differential Revision: https://reviews.llvm.org/D46554

llvm-svn: 331698
2018-05-07 23:24:07 +00:00
Rumeet Dhindsa 4fb5119215 Add support for thinlto option ( thinlto-emit-imports-files) to emit import files for thinlink.
Differential Revision: https://reviews.llvm.org/D46400

llvm-svn: 331696
2018-05-07 23:14:12 +00:00
Rui Ueyama 554adb2e97 Do not call exit() directly from lld.
Our promise is that as long as there's no fatal error (i.e. broken
file is given to the linker), our main function returns to the caller.
So we can't use exit() in the regular code path.

Differential Revision: https://reviews.llvm.org/D46442

llvm-svn: 331690
2018-05-07 22:11:34 +00:00
Rui Ueyama d54f1c2fed Refactor ThinLTO-related code in BitcodeCompiler.cpp. NFC.
Summary: Refactor ThinLTO-related code in BitcodeCompiler.cpp. NFC.

Reviewers: rdhindsa, espindola

Subscribers: emaste, inglorion, arichardson, llvm-commits, eraman

Differential Revision: https://reviews.llvm.org/D46549

llvm-svn: 331689
2018-05-07 22:11:24 +00:00
Rui Ueyama f64f345e1b Do not pass Config members to simplify function signature. NFC.
llvm-svn: 331658
2018-05-07 17:59:52 +00:00
Rui Ueyama 4454b3d1eb Parse --thinlto-prefix-replace early so that we don't need to parse it later. NFC.
llvm-svn: 331657
2018-05-07 17:59:43 +00:00
Rui Ueyama e4ba06eda6 Use StringRef instead of `const std::string &`. NFC.
llvm-svn: 331656
2018-05-07 17:59:34 +00:00
Rui Ueyama 66a9f257b6 Refactor BitcodeCompiler::createLTO. NFC.
llvm-svn: 331655
2018-05-07 17:46:28 +00:00
Rumeet Dhindsa b082a8790c Updated ThinLTO test to not include forward or backward slash for testing
Differential Revision: https://reviews.llvm.org/D46372

llvm-svn: 331419
2018-05-03 00:28:51 +00:00
Rumeet Dhindsa d366e36bbf Added support for ThinLTO plugin options : thinlto-index-only and thinlto-prefix-replace
Differential Revision: https://reviews.llvm.org/D46034

llvm-svn: 331405
2018-05-02 21:40:07 +00:00
Rumeet Dhindsa 682a417e51 Added support for LTO options: sample_profile, new_pass_manager and debug_pass_manager
Differential Revision: https://reviews.llvm.org/D45275

llvm-svn: 329598
2018-04-09 17:56:07 +00:00
Teresa Johnson 2c2ed3cf03 [lld/LTO] Remove unused Path parameter to AddBufferFn
Summary:
With D43396, no clients use the Path parameter anymore.
This is the lld side fix with D43400.

Depends on D43396 and D43400.

Reviewers: pcc

Subscribers: emaste, inglorion, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D43401

llvm-svn: 325620
2018-02-20 20:21:59 +00:00
Dmitry Mikulin 8ddd922d73 Symbols defined in linker scripts should not have dso_local flag set in LTO resolutions.
Differential Revision: https://reviews.llvm.org/D43051

llvm-svn: 324559
2018-02-08 04:25:52 +00:00
Dmitry Mikulin c84e0ee0e2 Don't set dso_local flag in LTO resolutions for absolute symbols defined in ELF
objects, it confuses codegen into generating pc-rel relocations for those
symbols, which leads to linker errors.

Differential Revision: https://reviews.llvm.org/D42977

llvm-svn: 324435
2018-02-07 00:49:51 +00:00
Rafael Espindola 3a730d8582 Pass CPU string to LTO pipeline.
Previously an empty CPU string was passed to the LTO engine which
resulted in a generic CPU for which certain features like NOPL were
disabled. This fixes that.

Patch by Pratik Bhatu!

llvm-svn: 323801
2018-01-30 18:18:59 +00:00
George Rimar c4ccfb5d93 [ELF] - Define linkerscript symbols early.
Currently symbols assigned or created by linkerscript are not processed early
enough. As a result it is not possible to version them or assign any other flags/properties.

Patch creates Defined symbols for -defsym and linkerscript symbols early,
so that issue from above can be addressed.

It is based on Rafael Espindola's version of D38239 patch.

Fixes PR34121.

Differential revision: https://reviews.llvm.org/D41987

llvm-svn: 323729
2018-01-30 09:04:27 +00:00
Rafael Espindola 37e4e695e9 Use the combined visibility when computing dso_local.
We track both the combined visibility that will be used for the output
symbol and the original input visibility of the selected symbol.

Almost everything should use the computed visibility.

I will make the names less confusing an a followup patch.

llvm-svn: 322576
2018-01-16 17:34:26 +00:00
Rafael Espindola c6df38c985 Set dso_local in lld.
We were already doing this in gold, but not in lld.

llvm-svn: 322572
2018-01-16 16:49:05 +00:00
Rafael Espindola dfebd3601d Use Symbol::File directly.
We are already paying the cost of storing a InputFile in every
Symbol, so use it uniformly.

llvm-svn: 319378
2017-11-29 22:47:35 +00:00
Rafael Espindola bec3765bea Remove IsLocal.
Since we always have Binding in the current symbol design IsLocal is
redundant.

llvm-svn: 318497
2017-11-17 01:37:50 +00:00
Rui Ueyama f483da0038 Rename replaceBody -> replaceSymbol.
llvm-svn: 317383
2017-11-03 22:48:47 +00:00
Rui Ueyama f52496e1e0 Rename SymbolBody -> Symbol
Now that we have only SymbolBody as the symbol class. So, "SymbolBody"
is a bit strange name now. This is a mechanical change generated by

  perl -i -pe s/SymbolBody/Symbol/g $(git grep -l SymbolBody lld/ELF lld/COFF)

nd clang-format-diff.

Differential Revision: https://reviews.llvm.org/D39459

llvm-svn: 317370
2017-11-03 21:21:47 +00:00
Rui Ueyama f1f00841d9 Merge SymbolBody and Symbol into one class, SymbolBody.
SymbolBody and Symbol were separated classes due to a historical reason.
Symbol used to be a pointer to a SymbolBody, and the relationship
between Symbol and SymbolBody was n:1.

r2681780 changed that. Since that patch, SymbolBody and Symbol are
allocated next to each other to improve memory locality, and they have
1:1 relationship now. So, the separation of Symbol and SymbolBody no
longer makes sense.

This patch merges them into one class. In order to avoid updating too
many places, I chose SymbolBody as a unified name. I'll rename it Symbol
in a follow-up patch.

Differential Revision: https://reviews.llvm.org/D39406

llvm-svn: 317006
2017-10-31 16:07:41 +00:00
Bob Haarman b8a59c8aa5 [lld] unified COFF and ELF error handling on new Common/ErrorHandler
Summary:
The COFF linker and the ELF linker have long had similar but separate
Error.h and Error.cpp files to implement error handling. This change
introduces new error handling code in Common/ErrorHandler.h, changes the
COFF and ELF linkers to use it, and removes the old, separate
implementations.

Reviewers: ruiu

Reviewed By: ruiu

Subscribers: smeenai, jyknight, emaste, sdardis, nemanjai, nhaehnle, mgorny, javed.absar, kbarton, fedor.sergeev, llvm-commits

Differential Revision: https://reviews.llvm.org/D39259

llvm-svn: 316624
2017-10-25 22:28:38 +00:00