Commit Graph

655 Commits

Author SHA1 Message Date
John McCall
fd92ef7c15 Use the *Swift* ABI version in the objc_imageinfo.
Not sure what I was thinking before, especially with
the obviously-wrong comment.

Swift SVN r21221
2014-08-14 23:45:37 +00:00
Pete Cooper
5579167754 Add the swift AA pass to the LLVM pass managers called in IRGen.
These are -O results which differ by >= 1.0%

benchmark``````,`````````````baserun0``,````````optrun0```,`````````````delta,``speedup
Ackermann``````,`````````````1680.00```,````````1654.00```,`````````````26.00```,````````1.6%
ArrayLiteral```,`````````````887.00````,````````866.00````,`````````````21.00```,````````2.4%
Ary````````````,`````````````1143.00```,````````1120.00```,`````````````23.00```,````````2.1%
Ary3```````````,`````````````1221.00```,````````1191.00```,`````````````30.00```,````````2.5%
DeltaBlue``````,`````````````2279.00```,````````2219.00```,`````````````60.00```,````````2.7%
Dictionary`````,`````````````518.00````,````````489.00````,`````````````29.00```,````````5.9%
Dictionary2````,`````````````403.00````,````````380.00````,`````````````23.00```,````````6.1%
Dictionary3````,`````````````398.00````,````````373.00````,`````````````25.00```,````````6.7%
EditDistance```,`````````````1388.00```,````````1346.00```,`````````````42.00```,````````3.1%
Fibonacci``````,`````````````1407.00```,````````1391.00```,`````````````16.00```,````````1.2%
ForLoops```````,`````````````1426.00```,````````1406.00```,`````````````20.00```,````````1.4%
Forest`````````,`````````````793.00````,````````770.00````,`````````````23.00```,````````3.0%
Hash```````````,`````````````683.00````,````````676.00````,`````````````7.00````,````````1.0%
Histogram``````,`````````````369.00````,````````352.00````,`````````````17.00```,````````4.8%
Life```````````,`````````````70.00`````,````````71.00`````,`````````````1.00````,````````-1.4%
MatMul`````````,`````````````250.00````,````````240.00````,`````````````10.00```,````````4.2%
Memset`````````,`````````````44.00`````,````````42.00`````,`````````````2.00````,````````4.8%
MonteCarloE````,`````````````976.00````,````````966.00````,`````````````10.00```,````````1.0%
Phonebook``````,`````````````1530.00```,````````1508.00```,`````````````22.00```,````````1.5%
Prims``````````,`````````````1034.00```,````````1016.00```,`````````````18.00```,````````1.8%
R17315246``````,`````````````809.00````,````````801.00````,`````````````8.00````,````````1.0%
RIPEMD`````````,`````````````767.00````,````````749.00````,`````````````18.00```,````````2.4%
StrCat`````````,`````````````1119.00```,````````1095.00```,`````````````24.00```,````````2.2%
StringBuilder``,`````````````713.00````,````````692.00````,`````````````21.00```,````````3.0%
StringWalk`````,`````````````1229.00```,````````1208.00```,`````````````21.00```,````````1.7%
Totals`````````,`````````````42437.00``,````````41910.00``,`````````````527.00``,````````1.3%
TwoSum`````````,`````````````638.00````,````````631.00````,`````````````7.00````,````````1.1%

Swift SVN r21174
2014-08-13 16:30:59 +00:00
John McCall
64a6a7393b Include information about the Swift ABI version in
the objc_imageinfo record.

rdar://17528908

Swift SVN r21104
2014-08-08 02:52:42 +00:00
Adrian Prantl
e63fbc5d64 [LLVM Sync] Adapt this use of TargetMachine to the new interface
introduced in LLVM r214781.

Swift SVN r21028
2014-08-04 23:37:35 +00:00
Sean Callanan
ebbf503a6a In all cases where playgrounds need to register
classes, UseJIT will also be set, so we don't
need to check.

And there's an important case where we *don't*
need to register classes: testcases, which break
if we do try to register classes, with the
following assertion:

Assertion failed: (registered == c && "objc_readClassPair failed to instantiate the class in-place"), function swift_instantiateObjCClass, file /Volumes/Excelion/swift/lldb-work/llvm/tools/swift/stdlib/runtime/SwiftObject.mm, line 594.

So only register classes if UseJIT is enabled,
and ignore the playground flag.


Swift SVN r20655
2014-07-28 23:15:27 +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
Arnold Schwaighofer
8fe003805f IRGen: Enable vectorization for OptLevel > 0
rdar://17186215

Swift SVN r18722
2014-06-06 00:34:25 +00:00
Arnold Schwaighofer
e50b489801 IRGen: Add missing calls to TargetMachine->addAnalysisPasses
rdar://17186215

Swift SVN r18721
2014-06-06 00:34:20 +00:00
Mark Lacey
cd00cfbf8f Fix some build warnings.
DEBUG_TYPE should be defined before the inclusion of LLVM's Support/Debug.h.

Swift SVN r18640
2014-05-26 20:17:54 +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
Greg Clayton
5977f42f86 Add code to initialize anything we need in the special debugger function for LLDB expressions, REPL and playground.
This current fix will initialize all objective C classes with the objective C runtime when any ObjC classes are defined in expressions

<rdar://problem/16029117>



Swift SVN r18037
2014-05-13 23:10:44 +00:00
Doug Gregor
3d3ff6811a Add a pile of missing #includes exposed by pruning includes in top-of-tree LLVM.
Swift SVN r17157
2014-05-01 14:26:34 +00:00
Jordan Rose
84f4d3b9fa Sink some triple predicates into swiftBasic.
getPlatformNameForTriple isn't currently being used anywhere elsee, but
this seems more consistent.

No functionality change.

Swift SVN r17002
2014-04-28 23:39:15 +00:00
Chris Lattner
a3916614ef respond to mainline API changes in the Debug.h header, by defining the
DEBUG_TYPE macro in all .cpp files that use the DEBUG macro.  Hopefully
this will unbreak the build.


Swift SVN r16638
2014-04-22 02:54:55 +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
Dmitri Hrybenko
f232267f23 Replace llvm::OwningPtr with std::unique_ptr
It looks like llvm::OwningPtr is going to be removed soon.


Swift SVN r14729
2014-03-06 09:47:17 +00:00
Dmitri Hrybenko
07cb1c935a Update for header move llvm/Linker.h -> llvm/Linker/Linker.h
While there, sort headers.


Swift SVN r14728
2014-03-06 08:59:38 +00:00
Dmitri Hrybenko
3d0e7ec09d Track upstream LLVM API change. DataLayout is not a Pass anymore
Swift SVN r14390
2014-02-26 10:03:45 +00:00
Chris Lattner
8ff9aa61ff remove a dead function
Swift SVN r14331
2014-02-25 01:29:43 +00:00
Dmitri Hrybenko
73aa816935 Track upstream change in raw_fd_ostream API
The default (F_None) used to mean F_Text, now it is F_Binary, which is arguably
a better default.  It only matters on Windows anyway, so just use F_None (to
mean binary mode) everywhere to allow Swift to be compled with older LLVM as
well as current ToT.


Swift SVN r14312
2014-02-24 21:00:00 +00:00
John McCall
c21a293243 Lazily emit SILFunctions with non-external linkage.
rdar://13013457

'import Cocoa' is still generating a ton of unnecessary
global metadata, which causes some unused VWTs to be built,
but at least we no longer generate tons of useless global
functions.  At least, we don't in IR-gen --- we still do
all the SILGen work for them.

Swift SVN r14224
2014-02-21 19:58:56 +00:00
John McCall
32cf8b3bac Preserve SIL function order in the parser and IRGen.
We're mostly not that bad about this right now, but lazy
emission is going to wreak havoc.

Note that SILGen itself doesn't really make very good decisions
about the order in which to emit functions, but step one
towards fixing that is actually respecting it.

Swift SVN r14200
2014-02-21 02:22:03 +00:00
Mark Lacey
5c696fda8b Make IR generation take an explicit LLVMContext.
Prior to r13134, the modules being constructed for IRGen always used the
LLVM global context due to <rdar://problem/15283227>, but the interface
should really take this as a parameter rather than baking the behavior
into IRGen.

Swift SVN r13260
2014-02-01 01:07:14 +00:00
Jordan Rose
fb21a2da84 Move LLVM passes into a library, and use opt to test them instead of swift.
These don't really have anything to do with Swift, and there's no reason to
include this capability in the new driver.

Swift SVN r13181
2014-01-30 23:42:38 +00:00
Mark Lacey
088d7b5f20 IRGenModule users shouldn't need to know about clang::CodeGenerator.
Swift SVN r13179
2014-01-30 22:59:00 +00:00
Mark Lacey
d69b305200 Generate IR for inline functions from Clang modules.
Currently only inline functions referenced from Swift source files, or
from the REPL, will get IR generated for them. Inline functions
referenced by other inline functions will require additional effort to
generate properly.

With this change we use the clang::CodeGenerator-created llvm::Module
for all IR generation in Swift. This is perhaps undesirable, but
unavoidable given the interface the public Clang APIs expose, which do
not allow for building a ModuleBuilder that borrows an existing
llvm::Module.

Also unfortunate is the hack to generate a UsedAttr for each imported
inline function, but the public Clang APIs do not provide a way to only
emit deferred decls without emitting other things (e.g. module flags
that conflict with what the Swift IRGen emits). Note that we do not do
IRGen for every inline function in the module - only the ones that the
importer pulls in, which appears to be only those transitively
referenced from Swift code.

Swift SVN r13134
2014-01-30 02:33:37 +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
Mark Lacey
5e40837b62 Always pass an llvm::Module* to performIRGeneration().
Previously it would create a new module if one was not passed in. There
are no uses where we do not or cannot provide a module, so it seems
reasonable to make the interface consistently require a module.

Swift SVN r13016
2014-01-27 23:48:49 +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
Jordan Rose
11008f0ed1 Split diagnostics out into separate files.
Thanks to the way we've set up our diagnostics engine, there's not actually
a reason for /everything/ to get rebuilt when /one/ diagnostic changes.
I've split them up into five categories for now: Parse, Sema, SIL, IRGen,
and Frontend, plus a set of "Common" diagnostics that are used in multiple
areas of the compiler. We can massage this later.

No functionality change, but should speed up compile times!

Swift SVN r12438
2014-01-17 00:15:12 +00:00
Greg Parker
927613bcac [IRGen] Set iOS simulator bit in Objective-C metadata.
Swift SVN r12325
2014-01-15 08:13:40 +00:00
Chris Lattner
1d9a826420 more mainline API drift.
Swift SVN r12227
2014-01-13 15:15:58 +00:00
Chris Lattner
914591b332 adjust for mainline llvm changes.
Swift SVN r12219
2014-01-13 01:18:48 +00:00
Jordan Rose
f09cd93194 [autolinking] Hack: autolink any module containing external definitions.
We're still synthesizing external definitions too eagerly, and things
getting pulled in only through submodules aren't getting properly autolinked.
(That is, AppKit imports <QuartzCore/CIImage.h> but doesn't think that
QuartzCore is visible, because it isn't.)

The first right answer is to detect that a part of QuartzCore is visible even
though the whole thing isn't. The second right answer is to properly handle
Clang submodules as real modules---there are a lot of rough edges there.
<rdar://problem/13140302>. The third right answer is that we shouldn't even
emit references to these symbols until the /user/ needs them.

And what I'm doing now is just to attempt to link to every module that we've
synthesized thunks for.

<rdar://problem/15754311>

Swift SVN r12031
2014-01-08 01:52:24 +00:00
Doug Gregor
4c9bda853e llvm/Assembly/PrintModulePass.h moved to llvm/IR/PrintModulePass.h
Swift SVN r11991
2014-01-07 15:25:30 +00:00
Jordan Rose
b1b50a134e Autolinking: include all imported modules.
Although Cocoa.framework re-exports AppKit, Foundation, and CoreData, an
arbitrary library does not re-export most of its imports. Normally this
would be fine, but the Clang importer can pull in types too eagerly and
then generate thunks and wrappers for things we don't care about. At least
for now, return to the behavior of autolinking /anything/ that gets visibly
imported.

<rdar://problem/15705923>

Swift SVN r11844
2014-01-03 01:21:11 +00:00
Connor Wakamo
59f18f9fc0 Renamed irgen::Options and irgen::OutputKind to IRGenOptions and IRGenOutputKind, and move both out of the irgen namespace now that they're in swiftAST.
Swift SVN r11405
2013-12-18 01:17:09 +00:00
Connor Wakamo
3e81830385 Move "include/swift/IRGen/Options.h" to "include/swift/AST/IRGenOptions.h".
This commit only moves the header file; updating the class so that it is no longer in the irgen namespace will be handled separately.

Swift SVN r11404
2013-12-18 01:17:09 +00:00
Adrian Prantl
e01d25bcb7 [Sync with ToT LLVM] Output the new debug info metadata version.
Swift SVN r11266
2013-12-13 21:20:50 +00:00
Jordan Rose
417b5d3982 Merge TranslationUnit into Module, and eliminate the term "translation unit".
This completes the FileUnit refactoring. A module consists of multiple
FileUnits, which provide decls from various file-like sources. I say
"file-like" because the Builtin module is implemented with a single
BuiltinUnit, and imported Clang modules are just a single FileUnit source
within a module.

Most modules, therefore, contain a single file unit; only the main module
will contain multiple source files (and eventually partial AST files).

The term "translation unit" has been scrubbed from the project. To refer
to the context of declarations outside of any other declarations, use
"top-level" or "module scope". To refer to a .swift file or its DeclContext,
use "source file". To refer to a single unit of compilation, use "module",
since the model is that an entire module will be compiled with a single
driver call. (It will still be possible to compile a single source file
through the direct-to-frontend interface, but only in the context of the
whole module.)

Swift SVN r10837
2013-12-05 01:51:15 +00:00
Jordan Rose
8b8cc8ee62 Turn SerializedModule into SerializedASTFile.
Part of the FileUnit restructuring. A serialized module is now represented as
a TranslationUnit containing a single SerializedASTFile.

As part of this change, the FileUnit interface has been made virtual, rather
than switching on the Kind in every accessor. We think the operations
performed on files are sufficiently high-level that this shouldn't affect us.

A nice side effect of all this is that we now properly model the visibility
of modules imported into source files. Previously, we would always consider
the top-level imports of all files within a target, whether re-exported or
not.

We may still end up wanting to distinguish properties of a complete Swift
module file from a partial AST file, but we can do that within
SerializedModuleLoader.

Swift SVN r10832
2013-12-05 01:51:09 +00:00
Jordan Rose
eede5ec4f9 Begin refactoring for mixed file kinds within a single module.
The goal of this series of commits is to allow the main module to consist
of both source files and AST files, where the AST files represent files
that were already built and don't need to be rebuilt, or of Swift source
files and imported Clang headers that share a module (because they are in
the same target).

Currently modules are divided into different kinds, and that defines how
decls are looked up, how imports are managed, etc. In order to achieve the
goal above, that polymorphism should be pushed down to the individual units
within a module, so that instead of TranslationUnit, BuiltinModule,
SerializedModule, and ClangModule, we have SourceFile, BuiltinUnit,
SerializedFile, and ClangUnit. (Better names welcome.) At that point we can
hopefully collapse TranslationUnit into Module and make Module non-polymorphic.

This commit makes SourceFile the subclass of an abstract FileUnit, and
makes TranslationUnit hold an array of FileUnits instead of SourceFiles.
To demonstrate that this is actually working, the Builtin module has also
been converted to FileUnit: it is now a TranslationUnit containing a single
BuiltinUnit.

Swift SVN r10830
2013-12-05 01:51:03 +00:00
Joe Groff
72be5e8f59 IRGen: Always use PIC relocation model.
Fixes <rdar://problem/15358345>.

Swift SVN r10026
2013-11-07 18:42:53 +00:00
Jordan Rose
4a90ab0a4f [IRGen] Separate out SourceFile-specific processing from whole-module stuff.
We're going to want to emit multiple SourceFiles and one SILModule in one
IRGenModule.

Swift SVN r9670
2013-10-25 17:30:39 +00:00
Jordan Rose
28e01f3c3a Eliminate "MainSourceFile" from TranslationUnit in favor of an array.
Anywhere that assumes a single input file per TU now has to do so explicitly.
Parsing still puts all files in a single SourceFile instance; that's next on
the list.

There are a lot of issues still to go, but the design is now in place.

Swift SVN r9669
2013-10-25 17:30:37 +00:00
Jordan Rose
f7f253320a Re-add -l flag to Swift interim driver.
This is useful in -i and REPL modes, which do not have a separate linking
step. This version of the -l flag doesn't rely on TranslationUnit. I also
cleaned up the library-loading diagnostics.

Swift SVN r9488
2013-10-18 18:52:10 +00:00
Jordan Rose
5ed38c0b72 Clarify SourceFile vs. TranslationUnit interfaces for SILGen and IRGen.
Once we have multiple SourceFiles in a TranslationUnit, it no longer makes
sense to say "only SILGen decls starting from element N" without specifying
which source file you mean.

Also, clarify ownership by having performSILGeneration return a unique_ptr
instead of just a bare pointer.

Swift SVN r9112
2013-10-09 23:44:43 +00:00