Commit Graph

254 Commits

Author SHA1 Message Date
David Farler
d80fe5364c Temporarily turn off reflection metadata: SR-994
This is crashing while emitting metadata for Foundation:
temporarily turning this off while I investigate locally.

https://bugs.swift.org/browse/SR-994
2016-03-19 15:31:22 -07:00
David Farler
7e8b8f83e8 Emit reflection metadata by default
This turns on the remote reflection metadata by default for swift
invocations and the standard library. The size delta for all of the
sections is:

Section __swift3_typeref: 20176
Section __swift3_reflstr: 2556
Section __swift3_fieldmd: 8172
Section __swift3_assocty: 18112

Recognizing that this is a nontrivial increase in binary size, we can
reduce this with a few methods:

- Trie for strings (typerefs and field names are both strings) but would
  need an implementation
- Compress the entire sections: this would need an implementation
  available on all platforms where we support the functionality.
- Don't use the AST mangler but a custom mangling, which may be slightly
  more compact because it can specialize by need and maybe not include
  some mangle nodes that typerefs don't need.
2016-03-18 17:50:32 -07: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
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
Han Sangjin
e06c7136cb Porting to Cygwin. rebased and squashed 2016-02-22 13:20:21 +09: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
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
Erik Eckstein
3464c89549 Add a hash function in IRGenOptions and use it for the incremental compilation hash in IRGen 2016-02-01 08:57:59 -08: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
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
Zach Panzarino
e3a4147ac9 Update copyright date 2015-12-31 23:28:40 +00: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
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
Erik Eckstein
68fa1c2c34 Support for stack promotion in IRGen.
This means: handling of alloc_ref [stack].
It can be configured with two new options. See Option/FrontendOptions.td.

As the [stack] attribute is not generated yet, there should be NFC.




Swift SVN r32929
2015-10-28 00:44:25 +00:00
Adrian Prantl
3356f7ac59 Pass the debug info settings through to Clang and ensure that compile units
created by Swift and Clang set the CU's compilation dir similarly.

rdar://problem/22692266

Swift SVN r32637
2015-10-12 22:20:58 +00:00
Jordan Rose
c516ef9223 [IRGen] Remove unnecessary IRGenOptions flag HasUnderlyingModule.
The test that it's guarding is cheap enough to do all the time, and we
don't have any interesting configurations where it's not set any more.

Swift SVN r29442
2015-06-17 04:48:09 +00:00
Doug Gregor
ffe4de6d6e Small fixes per Jordan's review
Swift SVN r29396
2015-06-16 00:05:12 +00:00
Doug Gregor
c8e3438f32 Add frontend option -disable-autolink-framework <framework>
This frontend option allows one to turn off autolinking to the
specified framework. This general capability is motivated by
rdar://problem/21246363, where we need to turn off some autolinking in
our overlays due to internal vs. public SDK differences.

Swift SVN r29393
2015-06-15 23:43:33 +00:00
Slava Pestov
0c88c13c0d IRGen: Brazenly nuke -enable-dynamic-value-type-layout flag
The last remaining case was apparently @objc generic classes, which
seem to work now.

Also nuke the IRGen/unimplemented_objc_generic_class.swift test,
this is now implemented and we have other tests that test this
functionality.

Swift SVN r29260
2015-06-03 00:01:29 +00:00
Ted Kremenek
dad92b0084 Revert "IRGen: Brazenly nuke -enable-dynamic-value-type-layout flag"
Speculatively reverting because the iOS bots are broken.

Swift SVN r29145
2015-05-29 14:11:25 +00:00
Slava Pestov
9da369b5ba IRGen: Brazenly nuke -enable-dynamic-value-type-layout flag
The last remaining case was apparently @objc generic classes, which
seem to work now.

Also nuke the IRGen/unimplemented_objc_generic_class.swift test,
this is now implemented and we have other tests that test this
functionality.

Swift SVN r29138
2015-05-29 06:19:06 +00:00
Erik Eckstein
460eea3b95 Let the frontend options handle multiple output files.
This will be needed for split-llvm code generation.
If multiple -o options are specified and only a single output file is needed
(currently always), the last one wins. This is NFC.



Swift SVN r25884
2015-03-09 16:24:52 +00:00
Arnold Schwaighofer
8482dbbb93 IRGen: Remove different NoAlias behavior at Ounchecked
As per discussion on the mailing list we don't want different behavior for
programmer errors at Ounchecked than at O for errors that are not diagnosable.

Neither O nor Ounchecked will now emit LLVM's NoAlias attribute for inout
parameters.

rdar://20041458

Swift SVN r25784
2015-03-05 19:17:23 +00:00
Arnold Schwaighofer
edf4461ba3 IRGen: Marking inout parameter NoAlias at the LLVM level is not memory safe
We have to guarantee memory safety in the presence of the user violating the
inout assumption.  Claiming NoAlias for parameters that might alias is not
memory safe because LLVM will optimize based on that assumption.

Unfortunately, this means that llvm can't optimize arrays as aggressively. For
example, the load of array->buffer won't get hoisted out of loops (this is the
Sim2DArray regression below).

-O numbers (before/after):

CaptureProp 0.888365
Chars 1.09143
ImageProc 0.917197
InsertionSort 0.895204
JSONHelperDeserialize 0.909717
NSDictionaryCastToSwift 0.923466
Sim2DArray 0.76296
SwiftStructuresBubbleSort 0.897483

Continue emitting noalias for inout when compiling Ounchecked.

rdar://20041458

Swift SVN r25770
2015-03-04 22:43:14 +00:00
Manman Ren
962febb3be [Driver] use enum instead of two flags for embedding bitcode options.
No functionality change.
 
rdar://19048891


Swift SVN r25581
2015-02-27 01:03:16 +00:00
Manman Ren
9d680564db [Driver] fix support for -embed-bitcode-marker.
Move helper function EmbedBitcode() from frontend_main.cpp to IRGen.cpp so we
can call it from performIRGeneration when the input file is Swift.

Add testing case to make sure that -embed-bitcode-marker option adds an
empty LLVM bitcode section.

rdar://19048891


Swift SVN r25577
2015-02-27 00:37:35 +00:00
Manman Ren
68e095b902 [Driver] add -embed-bitcode-marker for bitcode store project.
-embed-bitcode-marker option adds an empty LLVM bitcode section
as a marker for the real LLVM IR.

rdar://19048891


Swift SVN r25561
2015-02-26 20:56:40 +00:00
Manman Ren
48fa3d2e21 [Driver] actually embed bitcode and command line arguments for -embed-bitcode.
With -embed-bitcode, save a copy of the llvm IR as data in the __LLVM,__bitcode
section and save the command-line options in the __LLVM,__cmdline section.

rdar://19048891


Swift SVN r25560
2015-02-26 20:29:46 +00:00
Justin Bogner
a49008298e InstrProf: Set up the basic infrastructure for profiling swift
This adds the -profile-generate flag, which enables LLVM's
instrumentation based profiling. It implements the instrumentation
for basic control flow, such as if statements, loops, and closures.

Swift SVN r25155
2015-02-11 01:06:18 +00:00
Joe Groff
a4c777320e IRGen: Change type layout verifier to take a type by name to verify.
Swift SVN r25088
2015-02-09 02:51:41 +00:00
Joe Groff
8e1e6665a7 IRGen: Start a type verifier to fuzz static type info against runtime type info.
We've had a rash of bugs due to inconsistencies between how IRGen and the runtime think types are laid out. Add a '-verify-type-layout' mode to the frontend that causes IRGen to emit a bunch of code that compares its static assumptions against what the runtime value witness does.

Swift SVN r24918
2015-02-03 16:47:25 +00:00
Jordan Rose
a3a6c2695b Put the current target into LangOptions.
This has been long in coming. We always had it in IRGenOpts (in string form).
We had the version number in LangOpts for availability purposes. We had to
pass IRGenOpts to the ClangImporter to actually create the right target.
Some of our semantic checks tested the current OS by looking at the "os"
target configuration! And we're about to need to serialize the target for
debugging purposes.

Swift SVN r24468
2015-01-16 02:48:54 +00:00
Mark Lacey
cc5b6c7284 Add a hidden option to disable the LLVM SLP vectorizer.
Swift SVN r24341
2015-01-10 00:51:08 +00:00
Adrian Prantl
41a30f5988 Support line table only DWARF for Swift. <rdar://problem/19106981>
The new option is called -gline-tables-only to mirror clang.

Swift SVN r23615
2014-12-02 17:44:23 +00:00
Graham Batty
c835beb0b8 Remove IRGenOptions objc-interop flag.
Swift SVN r23166
2014-11-07 22:39:13 +00:00
Graham Batty
63a429f16e Changes to code generation to support non-objc targets
Swift SVN r23118
2014-11-05 18:05:55 +00:00
Jordan Rose
49a6c8eb7b Do all target info management in Clang, and drop -target-abi / -target-feature.
Previously we hardcoded a few important default CPUs, ABIs, and features into
Swift's driver, duplicating work in Clang. Now that we're using Clang's
driver to create the Clang "sub-compiler", we can delegate this work to Clang.

As part of this, I've dropped the options for -target-abi (which was a
frontend-only option anyway) and -target-feature (which was a hidden driver
option and is a frontend-only option in /Clang/). We can revisit this later
if it becomes interesting. I left in -target-cpu, which is now mapped
directly to Clang's -mcpu=.

Swift SVN r22449
2014-10-01 23:55:40 +00:00
Jordan Rose
b6818046a8 Eliminate optimization levels 0-3 in favor of -Onone/-O/-Ofast.
We were already effectively doing this everywhere /except/ when building
the standard library (which used -O2), so just use the model we want going
forward.

Swift SVN r20455
2014-07-24 01:12:59 +00:00
Dmitri Hrybenko
6f814ded6b Remove the '-disable-all-runtime-checks' option that predates current SIL-level
optimization/inlining scheme.

It was actually used while building a release version of stdlib, and
effectively disabled safety checks in debug builds.


Swift SVN r19461
2014-07-02 14:47:29 +00:00
Jordan Rose
2d004856cf Don't try to autolink the underlying module in a mixed-source framework.
Doing so causes the linker to list the framework itself as one of its
dependencies, which confuses tools that depend on the linker's dependency
output.

<rdar://problem/17006845>

Swift SVN r18578
2014-05-22 23:50:38 +00:00
Joe Groff
6c280e27e2 IRGen: Emit runtime initialization into top_level_code for playgrounds.
To help with the playground's transition to top level code, hand the -playground frontend flag down to IRGenOptions, so that IRGen knows to emit runtime initializer code for classes and categories into top_level_code rather than an attributed function.

Swift SVN r18479
2014-05-21 02:11:09 +00:00
Jordan Rose
41700b03da Add a new (hidden) option -autolink-force-load.
This option puts a special symbol into the generated object files that other
object files can reference to force the library to be loaded.

The next commit will modify the way we serialize autolinking information so
that importers of this module will always emit a reference to this symbol.
This means the library will be linked into the final binary even if no other
symbols are used (which happens for some of our overlays that just add
category methods to Objective-C classes).

Part of <rdar://problem/16829587>

Swift SVN r17750
2014-05-09 01:07:07 +00:00
Mark Lacey
35c3799d2a Handle -target-abi as a frontend option and default it to darwinpcs for arm64/Darwin.
Swift SVN r17077
2014-04-30 06:12:54 +00:00
John McCall
3cf3f42e98 When targeting arm64-apple-ios, the target CPU is cyclone,
which provides the Neon feature.  Do all the necessary
plumbing to get this from the driver to the backend.

Also, support -arch arm64, and diagnose bad -arch values
instead of silently ignoring them.  It's not clear to me
that we really want to support -arch as an alternative
to -target, but unless we rip it out or establish some
sort of real policy about it, it really ought to do
something approximating the right thing.

It would be nice if we could abstract enough of clang's
driver that we could re-use some of its basic logic about
tool chains and targets instaed of iteratively
rediscovering everything it does that's actually
critically important.

Swift SVN r16447
2014-04-17 06:36:03 +00:00
Jordan Rose
2c13b2e6fe Remove SwiftASTStreamerPass and the LegacyDebugInfo option.
Finishes the removal of the old "wrapped" module section that was made
unnecessary in r12922/3. Now that we no longer use the old compiler, we
don't need this at all. That also removes the need for SwiftTargetMachine.

No functionality change; this was all dead code.

Swift SVN r14758
2014-03-06 22:05:03 +00:00
Mark Lacey
9fde7f17cc Add DisableFPElim to IRGenOptions.
Use this to initialize the llvm::TargetOptions for code generation.

Swift SVN r13130
2014-01-30 00:26:57 +00:00
Connor Wakamo
38e1fd44af [frontend] Added support for -disable-llvm-arc-opts.
Adjusted how this option is handled: it is now set in IRGenOptions. If set,
this prevents the relevant passes from being added at all, instead of making
them no-ops.

Swift SVN r13005
2014-01-27 21:22:46 +00:00
Jordan Rose
be0a303c7d [DebugInfo] Only write an AST into the object file with the current compiler.
i.e. not the new driver/frontend. That one will insert it as part of linking.

Swift SVN r12923
2014-01-24 18:42:07 +00:00