Commit Graph

493 Commits

Author SHA1 Message Date
Jordan Rose
30589d608b [Driver] Use simpler idiom for forwarding -target-cpu
No functionality change, but now at least we're testing this more
explicitly than just in test/Misc/tbi.sil.
2017-11-16 13:58:47 -08:00
Jordan Rose
23897e136c -embed-bitcode: Pass -O options to backend jobs too! (#12971)
Otherwise, we leave optimization opportunities on the table, and in
some cases even fail to remove marker intrinsics inserted by earlier
optimization.

Background: under -embed-bitcode, compilation happens in two stages: a
"frontend" job that compiles Swift code, generates LLVM IR, optimizes
it, and then emits a .bc file; and a "backend" job that takes that
.bc, converts it to assembly, and emits an object file with the
original bitcode embedded. However, there are actually optimization
passes that run before and during that "convert to assembly" step that
were getting completely skipped.

rdar://problem/34864094
2017-11-16 13:45:31 -08:00
Adam Nemet
66085a8aef Save optimization remarks in an external YAML file
This brings the capability from clang to save remarks in an external YAML files.
YAML files can be viewed with tools like the opt-viewer.

Saving the remarks is activated with the new option -save-optimization-record.

Similarly to -emit-tbd, I've only added support for single-compile mode for now.
In this case the default filename is determined by
getOutputFilenameFromPathArgOrAsTopLevel, i.e. unless explicitly specified
with -save-optimization-record-path, the file is placed in the directory of the
main output file as <modulename>.opt.yaml.
2017-10-27 10:14:27 -07:00
swift-ci
b006d07342 Merge pull request #12294 from anemet/opt-remarks 2017-10-20 20:45:50 -07:00
Adam Nemet
9b9805420d Add optimization remarks
This allows reporting successful and unsuccessful optimizations similar to
clang/llvm.

This first patch adds support for the
options -Rpass=<pass-name-regex> -Rpass-missed=<pass-name-regex>.  These allow
reporting successful/unsuccessful optimization on the compiler output for passes
specified by the regex.  I've also added one missed and one passed remark type
to the inliner to test the infrastructure.

Clang also has the option of collecting these records in an external YAML data
file.  This will be added in a later patch.

A few notes:
* The goal is to use this facility for both user-lever "performance" warnings
and expert-level performance analysis.  There will probably be a flag in the
future differentiating the verbosity.

* The intent is match clang/llvm as much as it makes sense.  On the other hand I
did make some changes.  Unlike in llvm, the emitter is not a pass which
simplifies things.  Also the remark class hierarchy is greatly simplified since
we don't derive from DiagnosticInfo.  We also don't derive from Diagnostic to
support the streaming API for arbitrary named-value pairs.

* Currently function names are printed mangled which should be fixed.
2017-10-20 12:41:37 -07:00
Brian Gesiak
b81ad22cab [SR-2660][Driver] Handle .swiftmodule inputs
Allow users to pass `.swiftmodule` files into the Swift driver when
compiling without `-g`. The `.swiftmodule` files are then passed to the
linker via `-add_ast_path` so that LLDB can access their AST
information.

This addresses one of two driver changes suggested in the comments of
https://bugs.swift.org/browse/SR-2660.
2017-10-19 15:03:03 -07:00
Brian Gesiak
6652e8f699 [Driver] Remove obsolete "APPLE-ONLY" comments
A post-commit reviewer on https://github.com/apple/swift/pull/10716
asked that the comments be removed. Remove them, as they're no longer
demarcating code that is internal to Apple.
2017-10-04 00:34:56 -04:00
Vedant Kumar
1621facc6c [SwiftPGO] Add driver support for -profile-use=<path>
This option tells the compiler where to find a profdata file. The
information in this file enables PGO. For more information about the PGO
infrastructure, look for the -profile-generate option and for the
llvm-profdata tool [1].

[1] http://llvm.org/docs/CommandGuide/llvm-profdata.html
2017-09-26 10:52:08 -07:00
Graydon Hoare
85dda86130 Merge pull request #12071 from graydon/trace-stats-deltas
Trace stats deltas
2017-09-22 22:25:58 -07:00
Calvin Hill
aee81d272f Add Initial platform support for Haiku. (#11583) 2017-09-22 21:06:56 -04:00
Graydon Hoare
994ad7ad92 [stats] Add -trace-stats-events 2017-09-22 19:16:50 -04:00
Slava Pestov
c28ade7077 Driver: Pass the new -sil-merge-partial-modules flag
Also pass flags to disable SIL optimization passes when merging
modules, since that's completely unnecessary.

An evolution test that used to fail with WMO disabled now passes
with this change.

FIxes <rdar://problem/18913977>.
2017-09-18 21:18:07 -07:00
Slava Pestov
94be90bea3 Revert "Driver: Pass the new -sil-merge-partial-modules flag"
This reverts commit 86d241b38e.
2017-09-15 18:37:54 -07:00
Slava Pestov
86d241b38e Driver: Pass the new -sil-merge-partial-modules flag
Also pass flags to disable SIL optimization passes when merging
modules, since that's completely unnecessary.

An evolution test that used to fail with WMO disabled now passes
with this change.

FIxes <rdar://problem/18913977>.
2017-09-15 00:24:52 -07:00
Slava Pestov
7ea93d9ed0 Revert "Preserve SIL when merging modules" 2017-09-14 19:04:18 -07:00
Slava Pestov
ef583499a9 Driver: Pass the new -sil-merge-partial-modules flag
Also pass flags to disable SIL optimization passes when merging
modules, since that's completely unnecessary.

An evolution test that used to fail with WMO disabled now passes
with this change.

FIxes <rdar://problem/18913977>.
2017-09-14 15:54:06 -07:00
Jordan Rose
43ad758b76 Merge pull request #11669 from gmilos/test-pie-flag
Build -shared libs without -pie (on Linux), add tests
2017-09-01 08:56:17 -07:00
Jordan Rose
f8b7db4e76 Excise the terms "blacklist" and "whitelist" from Swift source. (#11687)
The etymology of these terms isn't about race, but "black" = "blocked"
and "white" = "allowed" isn't really a good look these days. In most
cases we weren't using these terms particularly precisely anyway, so
the rephrasing is actually an improvement.
2017-08-30 09:28:00 -07:00
Grzegorz Miłoś
e13efd4007 Inverse the check != DynamicLibrary => == Executable. 2017-08-30 14:00:34 +01:00
John Holdsworth
40c82b6dd0 Allows shared libraries on Linux 2017-08-29 15:33:38 +01:00
John Holdsworth
c4c6a820e5 Avoid adding -pie on Android apps which are -shared 2017-08-29 15:33:38 +01:00
George Karpenkov
020801beb4 Update -sanitize=fuzzer option to take into account new libFuzzer location. (#11595) 2017-08-28 17:16:55 -07:00
swift-ci
326756d7fa Merge pull request #11379 from cheshire/whitespace_cleanup 2017-08-07 19:01:45 -07:00
George Karpenkov
efe143c2f4 Adding support for -sanitize=fuzzer flag (#11381)
Similarly to Clang, the flag enables coverage instrumentation, and links
`libLLVMFuzzer.a` to the produced binary.
Additionally, this change affects the driver logic, and enables the
concurrent usage of multiple sanitizers.
2017-08-07 18:16:51 -07:00
George Karpenkov
ddb7fcf81d [NFC] Clean up whitespace (no tabs!) and indentation. 2017-08-07 17:11:32 -07:00
Jordan Rose
d495e1c075 Merge pull request #11272 from gmilos/sr-5405-position-independent-executables-on-linux
Build position independent Linux binaries.
2017-08-02 08:49:57 -07:00
Huon Wilson
374826c960 Merge pull request #11219 from huonw/tbd-is-not-a-main-product
[Frontend] Emit tbd as an extra output, not a frontend action.
2017-07-31 18:46:02 -07:00
Grzegorz Miłoś
78938d8f86 Add -pie flag to clang++ linker invocation. 2017-07-31 19:21:32 +01:00
Huon Wilson
dfa8501e59 [Frontend] Emit tbd as an extra output, not a frontend action.
This means it can be emitted during an -emit-module frontend job, which is the
most common place it will be used, so reusing work like this is important for
performance.

For now, this has to happen as part of a single frontend invocation, i.e. -wmo
or -force-single-frontend-invocation.
2017-07-31 11:05:29 -07:00
John McCall
efaf5e66ba Now that the Clang importer honors and expects -O, make sure we
pass it to the PCH-generation job.

This depends on the merge-modules patch because we don't want merging
modules when optimization is enabled to re-run the optimizer.
(Thanks, Jordan!)

rdar://33541306
2017-07-27 10:21:02 -04:00
John McCall
dda3a3827c [SR-3063] Suppress SIL transforms when merging modules. 2017-07-27 10:21:02 -04:00
Pavel Yaskevich
4f8872598b [ConstraintSolver] NFC: Add option to control early termination of shrinking phase
Currently we have a number of unsolved disjunctions hard-coded to 5,
which breaks some existing code by terminating shrinking too early.
This patch makes it a command-line option so users have control over
what that threshold can be.

Resolves: rdar://problem/33433595
2017-07-20 12:44:48 -07:00
Jordan Rose
e994f61e58 Merge pull request #9958 from spevans/pr_static_libs
SR-648: Allow swiftpm to statically link binaries on Linux
2017-07-19 12:52:54 -07:00
Doug Gregor
f03685b6d0 Introduce a command-line option to limit the # of typo corrections.
Typo correction can be particularly expensive, so introduce a
command-line flag to limit the number of typo corrections we will
perform per type-checker instance. Default this limit to 10.

Addresses rdar://problem/28469270 to some extent.
2017-07-10 11:40:35 -07:00
Carl Brown
dacbb8750f Linux Address and Thread Sanitizer Support (#6446) 2017-07-02 12:42:01 -07:00
David Farler
645aaad551 [index/build] Upstream indexing while building changes
This patch upstreams previously AppleInternal changes for
indexing while building.
2017-06-29 16:20:06 -07:00
Simon Evans
3ac5e12c67 [Linux] Reorder the -Xlinker and -l arguments
- Move the -Xlinker and -l options to just before swift_end.o

- Add testcase to check linker option ordering.
2017-06-29 13:10:04 +01:00
Simon Evans
03b067b949 [Linux] Reorder arguments for autolink files from swift-autolink-extract
- Reordering the auto link files when linking in static libraries
  and object files is required because the ordering of arguments
  is important, and the dependant libraries need to come after the
  objects/libs that require them. This is not a problem for
  libswiftCore.a but can be an issue with libs that sit on top of
  it, e.g. libFoundation.a

- Dont add an -rpath to the Swift dynamic libraries if using
  -static-stdlib
2017-06-29 13:08:15 +01:00
Jordan Rose
ad3c773446 Merge pull request #10381 from keith/ks/no-linking-rpath
Don't add rpath to swift with statically linking.
2017-06-20 09:01:18 -07:00
Keith Smiley
607312663b Don't add rpath to swift with statically linking
This updates the rpath linking logic to only add the rpath that points
to the swift dylibs in the case that the libraries are not statically
linked into the binary.
2017-06-19 13:36:47 -07:00
George Karpenkov
9637bd2c36 Change driver logic for sanitizers support.
With this patch different sanitizers (tsan/asan) will be enabled or
disabled on the driver level on a particular OS depending on whether
the required library is present.

The current patch only supports Darwin architectures, but Linux support
should not be hard to add.
2017-06-16 13:26:46 -07:00
Doug Gregor
dc2159c170 [Driver] Pass -warn-swift3-objc-inference-(minimal|complete) to the frontend.
Fixes rdar://problem/32428233.
2017-05-26 10:29:25 -07:00
Michael Ilseman
4640246263 Revert "[stdlib] Static stdlib requires explicit -licucore"
This reverts commit 0de2425112.
2017-05-18 19:41:55 -07:00
Michael Ilseman
116b5330bb Revert "[stdlib] Static linking test case"
This reverts commit f1a7c3df5b.
2017-05-18 19:41:45 -07:00
Michael Ilseman
f1a7c3df5b [stdlib] Static linking test case
Adds a test case that the compiler driver will properly insert
-licucore for static standard library builds. This test runs even on
builds that don't build a static standard library, so PR testing can
regressions here.
2017-05-18 14:33:09 -07:00
Michael Ilseman
0de2425112 [stdlib] Static stdlib requires explicit -licucore 2017-05-18 12:08:17 -07:00
Argyrios Kyrtzidis
a6a3ebee6c [Driver] For the persistent PCH job there is no output path, the frontend determines the filename to use.
Previously the parseable output would have an empty string as the output of the PCH job, this fixes the issue.
2017-05-13 14:59:18 -07:00
Argyrios Kyrtzidis
4391ecc802 [Driver] For the 'emit persistent PCH' job, don't set an output filename. 2017-05-11 16:24:51 -07:00
Argyrios Kyrtzidis
c4b5b60d00 [Driver/ClangImporter] Changes for the driver to recognize -pch-output-dir and propagate to the frontend invocations
For the multiple-files mode -emit-pch is still invoked in separate frontend invocation but with using a persistent PCH.
Subsequent frontend invocations use the persistent PCH but they don't need to validate it.

For all-files mode (e.g. WMO) the frontend invocation uses a persistent PCH that it also validates.
2017-05-11 11:44:12 -07:00
David Farler
bf52ff032a [Migrator] Conservative and Minimal @objc inference workflows
Based on recommendations in SE-0160, there are two migration workflows:

- Conservative: Maintain @objc visibility that was inferred in Swift 3
  by adding @objc to all declarations that were implicitily visible to
  the Objective-C runtime. This is invoked in the migrator by adding the
  -migrate-keep-objc-visibility flag.
- Minimal: Only declarations that must be visible to Objective-C based
  on their uses (or in cases like dynamic vars) are migrated.

rdar://problem/31876357
2017-04-28 18:28:34 -07:00