Commit Graph

609 Commits

Author SHA1 Message Date
Slava Pestov
0b320a6d5b Sema: Implement DefaultWitnessChecker
Now that WitnessChecker is separate from ConformanceChecker, implement
a DefaultWitnessChecker subclass which performs default witness
resolution.

This populates the recently-added ProtocolDecl::DefaultWitnesses map.

Unlike ConformanceChecker, the DefaultWitnessChecker looks up the witness
in any protocol extensions of the protocol, matching the context archetypes
of the requirement against the witness.

For now, we infer default witnesses for all protocols, but don't do
anything with that information. An upcoming SILGen patch will start to
emit thunks and add tests.
2016-03-03 06:59:55 -08:00
AnnaZaks
767d9ca914 Merge pull request #1434 from apple/asan
[asan] Add basic support for Address Sanitizer function instrumentation
2016-02-29 18:58:40 -08:00
Michael Gottesman
aebc5baf84 Add a new frontend option for debugging called '-disable-incremental-llvm-codegen'.
Currently IRGen stores hashes of the bitcode generated by swift in object files.
This is then used to reduce compile time by not re-codegening if a subsequent
compilation yields a bit code with the same hash.

This is good for users and general compilation, but can result in confusion when
attempting to measure the "real" compile time of the compiler.

By default it is off.
2016-02-28 18:50:19 -08:00
zaks
2110235fd3 [asan] Cleanup based on Jordan's review comments 2016-02-26 16:02:40 -08:00
zaks
d727c68fde [asan] Add "unsupported option .. for target" error message
ASan support for Linux does not exist at this point.
2016-02-25 15:20:51 -08:00
Roman Levenstein
8dff92ad4d Move pre-specializations of popular types away from the standard library.
Pre-specializations were only used by Onone builds, but were kept inside the standard library dylyb anyways. This commit moves all the pre-specializations into a dedicated Swift module and a dynamic library, which are only used by Onone builds.

This reduces the code size of libswiftCore.dylib by 4%-5%.
2016-02-25 11:23:15 -08:00
zaks
ef925f8fb3 [asan] Add basic support for Address Sanitizer function instrumentation
ASan allows to catch and diagnose memory corruption errors, which are possible
when using unsafe pointers.

This patch introduces a new driver/frontend option -sanitize=address to enable
ASan. When option is passed in, the ASan llvm passes will be turned on and
all functions will gain SanitizeAddress llvm attribute.
2016-02-24 09:45:38 -08:00
Todd Fiala
ceb58eac1e Merge branch 'master' of ssh://github.com/apple/swift 2016-02-22 22:00:10 -08:00
Todd Fiala
8ff40a3a22 Revert "Move pre-specializations of popular types away from the standard library."
This reverts commit 4d4c2cdba9.
2016-02-22 21:18:32 -08:00
Xi Ge
dd74e1c0ef [Serialization] Add a new front-end argument to specify the path of the group info file. NFC 2016-02-22 20:28:39 -08:00
Dmitri Gribenko
7235595264 Merge pull request #1108 from tinysun212/porting-to-cygwin
Porting to cygwin
2016-02-22 18:53:30 -08:00
Roman Levenstein
4d4c2cdba9 Move pre-specializations of popular types away from the standard library.
Pre-specializations were only used by Onone builds, but were kept inside the standard library dylyb anyways. This commit moves all the pre-specializations into a dedicated Swift module and a dynamic library, which are only used by Onone builds.

This reduces the code size of libswiftCore.dylib by 5%.
2016-02-22 07:54:44 -08:00
Han Sangjin
e06c7136cb Porting to Cygwin. rebased and squashed 2016-02-22 13:20:21 +09:00
Joe Groff
d4fdc1e7a8 Conditionally enable behaviors by a frontend flag.
Since the feature is incomplete and yet to be accepted or implemented as proposed, hide it behind an -enable-experimental-property-behaviors frontend flag.
2016-02-20 15:01:06 -08:00
William Dillon
d0d9b1de5a Discard swift.ld and support gold linker 2016-02-17 17:47:35 -08:00
Mark Lacey
bd30572f80 Minor clean-up of -assert-config option handling.
* Replace 'Fast' with 'Unchecked' everywhere.
* Update the help text to specify DisableReplacement rather than
  Replacement and to document Unchecked.
* Simplify tests slightly and add a tests for Unchecked.
2016-02-12 15:10:45 -08:00
Jordan Rose
6272941c5c Rename "build configurations" to "conditional compilation blocks".
...because "build configuration" is already the name of an Xcode feature.

- '#if' et al are "conditional compilation directives".
- The condition is a "conditional compilation expression", or just
  "condition" if it's obvious.
- The predicates are "platform conditions" (including 'swift(>=...)')
- The options set with -D are "custom conditional compilation flags".
  (Thanks, Kevin!)

I left "IfConfigDecl" as is, as well as SourceKit's various "BuildConfig"
settings because some of them are part of the SourceKit request format.
We can change these in follow-up commits, or not.

rdar://problem/19812930
2016-02-12 11:09:26 -08:00
Erik Eckstein
9e28192ea3 Option -print-llvm-inline-tree for printing the inline-tree of the LLVM module.
This is useful to get information about what inlined functions contribute to the code size.
2016-02-10 12:14:23 -08:00
Doug Gregor
293d130272 [Omit needless words] Add a flag -enable-strip-ns-prefix to control NS stripping
Stripping "NS" is a massively invasive change; separate it out into
another flag.
2016-02-08 22:41:16 -08:00
David Farler
a6a5ece206 IRGen: Emit type references for remote reflection
- Implement emission of type references for nominal type field
  reflection, using a small custom encoder resulting in packed
  structs, not strings. This will let us embed 7-bit encoded
  32-bit relative offsets directly in the structure (not yet
  hooked in).
- Use the AST Mangler for encoding type references
  Archetypes and internal references were complicating this before, so we
  can take the opportunity to reuse this machinery and avoid unique code
  and new ABI.

Next up: Tests for reading the reflection sections and converting the
demangle tree into a tree of type references.

Todo: For concrete types, serialize the types for associated types of
their conformances to bootstrap the typeref substitution process.

rdar://problem/15617914
2016-02-03 13:52:26 -08:00
saisi
08abcd92c3 fixed niggling typos 2016-01-29 22:22:12 -05:00
David Farler
bb2391adbd Add -strip-field-names and -strip-field-metadata IRGen options
This controls emission of field metadata for reflection, providing
the default decision. We might want to explore finer-grained
control per type, likely as a source code annotation.

  -strip-field-names
    Strip field names from nominal type metadata.

  -strip-field-metadata
    Strip all field metadata for nominal types. This also implies
    -strip-field-names.

NFC yet.
2016-01-26 09:33:54 -08:00
practicalswift
0d40662332 [gardening] Consistent use of header pattern 2016-01-23 12:19:51 +01:00
practicalswift
8efa5f587e [gardening] Remove "-*- C++ -*-" tag from .cpp files
Emacs assumes .h files are C files by default which is why the
tag "-*- C++ -*-" is needed.

.cpp files do not have this problem.
2016-01-23 12:09:32 +01:00
Doug Gregor
5e11e3f728 Also map -enable-omit-needless-words to a language option.
Although omit-needless-words is almost entirely a Clang importer task,
there are a handful of other places in the compiler that will need to
query this flag as well. NFC for now; those changes will come soon.
2016-01-17 23:40:14 -08:00
Slava Pestov
81267ce1db AST: Serialize -enable-resilience flag on the ModuleDecl
Since resilience is a property of the module being compiled,
not decls being accessed, we need to record which types are
resilient as part of the module.

Previously we would only ever look at the @_fixed_layout
attribute on a type. If the flag was not specified, Sema
would slap this attribute on every type that gets validated.

This is wasteful for non-resilient builds, because there
all types get the attribute. It was also apparently wrong,
and I don't fully understand when Sema decides to validate
which decls.

It is much cleaner conceptually to just serialize this flag
with the module, and check for its presence if the
attribute was not found on a type.
2016-01-16 02:23:27 -08:00
Michael Ilseman
34260e3a56 Merge remote-tracking branch 'origin/master' into warning_control 2016-01-15 14:22:47 -08:00
Michael Ilseman
dc689e607c [Diagnostics] -suppress-warnings and -warnings-as-errors flags
Exposes the global warning suppression and treatment as errors
functionality to the Swift driver. Introduces the flags
"-suppress-warnings" and "-warnings-as-errors". Test case include.
2016-01-15 14:20:44 -08:00
David Farler
bd8d85da0a Turn on dynamic super method dispatch by default
This removes the -use-native-super-method flag and turns on dynamic
dispatch for native method invocations on super by default.

rdar://problem/22749732
2016-01-15 13:37:53 -08:00
Doug Gregor
657319903e Add a "-swift3-migration" frontend option and corresponding language option.
This is intended to enable various Fix-Its to perform the one-way
migration from Swift 2.x to Swift 3, with a focus on the issues
involving naming.
2016-01-14 00:21:47 -08:00
Doug Gregor
12d6f02c45 Remove the "-disable-self-type-mangling" flag and corresponding language option
NFC
2016-01-14 00:21:47 -08:00
John McCall
f1682cd9a8 Use real types instead of "Self" for the IR value names of local type data.
Since that's somewhat expensive, allow the generation of meaningful
IR value names to be efficiently controlled in IRGen.  By default,
enable meaningful value names only when generating .ll output.

I considered giving protocol witness tables the name T:Protocol
instead of T.Protocol, but decided that I didn't want to update that
many test cases.
2016-01-13 19:26:18 -08:00
Jordan Rose
bcff26193e Teach the frontend about -output-filelist.
Finishes up https://bugs.swift.org/browse/SR-280. At this point, nothing
should be passing O(N) arguments on the command line, where N is the
number of input source files, unless N is small.

(There are other inputs which are passed through to subtools, and these
are not put into filelists. That's fine.)
2016-01-13 18:41:05 -08:00
Jordan Rose
ad945426a0 Teach the frontend about -filelist for input files.
With this, we're out of the business of passing large numbers of input
files on the command line to the frontend, which means we no longer
overflow argv with a mere 1100 input files under whole-module optimization.

In order to make sure this doesn't happen again, I'd like to also get
this working for
- swiftmodule inputs to the merge-module build phase
- /output/ files for multithreading single-frontend builds (WMO)
- object file inputs to the linker on OS X (response files for binutils
  ld have different quoting rules)

Part 3 of https://bugs.swift.org/browse/SR-280.
2016-01-12 19:20:50 -08:00
practicalswift
1339b5403b Consistent use of header comment format.
Correct format:
//===--- Name of file - Description ----------------------------*- Lang -*-===//
2016-01-04 13:26:31 +01:00
practicalswift
50baf2e53b Use consistent formatting in top of file headers. 2016-01-04 02:17:48 +01:00
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00:00
Joe Groff
611defcdcb Introduce -enable-guaranteed-closure-contexts staging option. 2015-12-30 20:30:38 -08:00
practicalswift
db13bcb22e Fix typos. 2015-12-26 14:11:42 +01:00
practicalswift
22e10737e2 Fix typos 2015-12-26 01:19:40 +01:00
gregomni
db44bf7d69 Add support in the diagnostic verifier for verifying no fix-its
Checked what it would look like to verify fix-its in every case, and
currently the tests are missing expected fix-its in 435 diagnoses in 60
test files.

So as an alternative, added support for a no fix-its marker “{{none}}”, and
added that marker to the c-style for deprecation tests where it applies.
2015-12-22 13:33:39 -08:00
Jordan Rose
c40e8d9031 Add frontend option -debug-time-compilation.
This times each phase of compilation, so you can see where time is being
spent. This doesn't cover all of compilation, but does get all the major
work being done.

Note that these times are non-overlapping, and should stay that way.
If we add more timers, they should go in a different timer group, so we
don't end up double-counting.

Based on a patch by @cwillmor---thanks, Chris!

Example output, from an -Onone build using a debug compiler:

===-------------------------------------------------------------------------===
                               Swift compilation
===-------------------------------------------------------------------------===
  Total Execution Time: 8.7215 seconds (8.7779 wall clock)

   ---User Time---   --System Time--   --User+System--   ---Wall Time---  --- Name ---
   2.6670 ( 30.8%)   0.0180 ( 25.3%)   2.6850 ( 30.8%)   2.7064 ( 30.8%)  Type checking / Semantic analysis
   1.9381 ( 22.4%)   0.0034 (  4.8%)   1.9415 ( 22.3%)   1.9422 ( 22.1%)  AST verification
   1.0746 ( 12.4%)   0.0089 ( 12.5%)   1.0834 ( 12.4%)   1.0837 ( 12.3%)  SILGen
   0.8468 (  9.8%)   0.0171 ( 24.0%)   0.8638 (  9.9%)   0.8885 ( 10.1%)  IRGen
   0.6595 (  7.6%)   0.0142 ( 20.0%)   0.6737 (  7.7%)   0.6739 (  7.7%)  LLVM output
   0.6449 (  7.5%)   0.0019 (  2.6%)   0.6468 (  7.4%)   0.6469 (  7.4%)  SIL verification (pre-optimization)
   0.3505 (  4.1%)   0.0023 (  3.2%)   0.3528 (  4.0%)   0.3530 (  4.0%)  SIL optimization
   0.2632 (  3.0%)   0.0005 (  0.7%)   0.2637 (  3.0%)   0.2639 (  3.0%)  SIL verification (post-optimization)
   0.0718 (  0.8%)   0.0021 (  3.0%)   0.0739 (  0.8%)   0.0804 (  0.9%)  Parsing
   0.0618 (  0.7%)   0.0010 (  1.4%)   0.0628 (  0.7%)   0.0628 (  0.7%)  LLVM optimization
   0.0484 (  0.6%)   0.0011 (  1.5%)   0.0495 (  0.6%)   0.0495 (  0.6%)  Serialization (swiftmodule)
   0.0240 (  0.3%)   0.0006 (  0.9%)   0.0246 (  0.3%)   0.0267 (  0.3%)  Serialization (swiftdoc)
   0.0000 (  0.0%)   0.0000 (  0.0%)   0.0000 (  0.0%)   0.0000 (  0.0%)  Name binding
   8.6505 (100.0%)   0.0710 (100.0%)   8.7215 (100.0%)   8.7779 (100.0%)  Total
2015-12-17 15:19:09 -08:00
David Farler
101cf49880 Use -enable-resilience for IRGen super_method tests
We've already got -enable-resilience and @_fixed_layout to compare
IRGen differences when lowering super_method instructions, so nuke
the -force-resilient-super-dispatch testing flag. While
we're at it, consolidate the super tests a bit.
2015-12-16 14:01:49 -08:00
Doug Gregor
99c1af3fd1 Merge branch 'master' of github.com:/apple/swift 2015-12-14 22:06:20 -08:00
David Farler
86f815bd32 IRGen: Statically load superclass metadata for non-resilient classes
We only need to indirectly load the superclass's metadata when the
superclass is resilient. For example, we may be calling a super method
inside an extension of a class we don't own. Otherwise, we can
immediately load the statically known superclass.

Adds a testing flag to force resilient super dispatch, since the
IRGen module resilience checks aren't fully implemented yet.

SIL -> IR tests added.

rdar://problem/22749732

Also fixes rdar://problem/23884670
2015-12-14 17:37:34 -08:00
Doug Gregor
cf7ed8d600 Add -enable-swift-name-lookup-tables option to enable Swift lookup tables.
Aside from causing the tables to get built, this doesn't actually do
anything yet.
2015-12-14 15:43:30 -08:00
Doug Gregor
563bdb9156 Clang importer: remove support for implicit properties.
We decided not to support "implicit" properties, where we import
getter/setter pairs as properties. Rather, we only import a property
when there is an explicit "@property" in Objective-C. Remove the flag
and supporting code for implicit properties.
2015-12-14 14:33:07 -08:00
Dmitri Gribenko
23366f2001 Merge pull request #506 from practicalswift/fix-typos-10
Fix typos (10 of 30)
2015-12-13 20:17:38 -08:00
practicalswift
bb6be23027 Fix typo: diagostics → diagnostics 2015-12-14 00:11:37 +01:00
practicalswift
2d9c3c3503 Fix typo: abbrevation → abbreviation 2015-12-13 23:56:38 +01:00