Commit Graph

629 Commits

Author SHA1 Message Date
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
Nadav Rotem
4eb340e028 Enable the llvm function merging pass.
This pass removes almost half of the value witness functions in the dylib,
about 8% of the code in the dylib, and about 4% of the total dylib size.

Swift SVN r24920
2015-02-03 17:41:54 +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
Dmitri Hrybenko
fecf7f89fc Update for upstream LLVM API changes
Swift SVN r24889
2015-02-02 03:22:10 +00:00
Dmitri Hrybenko
92ace1b2e5 Update for upstream LLVM API change (r227685)
Swift SVN r24880
2015-01-31 12:35:28 +00:00
David Farler
5b4017c348 Build fix: Update for upstream LLVM TargetMachine API change
Swift SVN r24749
2015-01-27 03:05:03 +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
Erik Eckstein
14af3a57e8 Enable elimination of dead methods which are in classes of higher visibility.
The underlying problem is that e.g. even if a method is private but its class is public, the method can be referenced from another module - from the vtable of a derived class.
So far we handled this by setting the SILLinkage of such methods according to the visibility of the class. But this prevented dead method elimination.
Now I set the SILLinkage according to the visibility of the method. This enables dead method elimination, but it requires the following:
1) Still set the linkage in llvm so that it can be referenced from outside.
2) If the method is dead and eliminated, create a stub for it (which calls swift_reportMissingMethod).



Swift SVN r23889
2014-12-12 17:35:40 +00:00
Joe Groff
6e74b5c21b IRGen: Base our clang::CodeGenOptions on those from the Clang instance.
Use the CodeGenOptions the Clang frontend determined for the compiler instance instead of starting from scratch, so that we pick up important settings like '-mstackrealign'. Fixes the GLKit test on iOS. rdar://problem/19180367

Swift SVN r23792
2014-12-08 23:29:27 +00:00
Joe Groff
056f55fd47 IRGen: Install the AlwaysInliner pass at -O0.
We want to make sure C definitions that get emitted as alwaysinline actually get inlined.

Swift SVN r23786
2014-12-08 22:07:30 +00:00
Joe Groff
17e85e60e4 Consistently set target, CPU, and subtarget options in AOT and JIT mode.
Factor out the code that sets up llvm::TargetOptions and SubtargetFeatures via Clang, and reuse it in immediate mode to properly set up the ExecutionEngine to be consistent with the environment we emitted code for. This makes it so that we can use code that lowers to, for instance, SSE3 intrinsics, in particular stuff like GLKit code imported from Clang.

Swift SVN r23646
2014-12-03 06:40:18 +00:00
Graham Batty
06c75f5f76 Revert "Appropriately disable some more objective-c codegen on non-objc."
This reverts commit f62a356cd3689a1325c921315cedfd56eda7cb00.

Swift SVN r23578
2014-11-24 17:42:18 +00:00
Graham Batty
b0d7b07e05 Appropriately disable some more objective-c codegen on non-objc.
Swift SVN r23574
2014-11-24 17:40:42 +00:00
Joe Groff
f205082b6d IRGen: Register JITed conformances with the runtime.
dyld won't help us with JIT code, so we need to inject a runtime call to add the conformances ourselves in JIT mode.

Swift SVN r23058
2014-11-01 22:20:10 +00:00
Jordan Rose
92623006d6 Fix incorrect use of std::move.
Noticed by inspection. No functionality change because the actual argument
is a StringRef anyway.

Swift SVN r22765
2014-10-15 19:28:07 +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
Michael Gottesman
c02643e281 Update swift for llvm trunk change r217548.
Swift SVN r21861
2014-09-11 00:30:00 +00:00
Ted Kremenek
ff5f742c68 Update Swift version to '1.1'. This includes bumping the Swift
ABI version to '2'.

This patch shows that we need to consolidate where we encode
version information in our CMake build; that's for a later patch.

Implements rdar://problem/18238390.

Swift SVN r21850
2014-09-10 20:49:59 +00:00
Michael Gottesman
4c953d7f33 Rename OptimizeARC library => LLVMPasses library.
OptimizeARC does not only contain an optimize arc pass: the library also
includes aa. What this really is a repository of the extra passes and
infrastructure that we inject into LLVM. Thus LLVMPasses is a more descriptive
name. It also matches SILPasses.

I also taught lit how to use the new llvm-opt driver for running swift llvm
passes through opt without having to remember how to setup the dynamic swift
llvm pass dylib. You can use this in lit tests by using the substitution
%llvm-opt.

Swift SVN r21654
2014-09-02 20:51:40 +00:00
Andrew Trick
9ce5894db1 Fix raw_fd_ostream calls for ToT constructor changes
Swift SVN r21447
2014-08-25 23:29:36 +00:00
Jordan Rose
64d8f31d26 [IRGen] Register Objective-C classes explicitly in immediate mode as well.
Otherwise we can't use KVO with script files.

Swift SVN r21390
2014-08-21 23:50:14 +00:00
John McCall
f7ebe89949 Set up the ARM retainAutoreleasedReturnValue markers
correctly in optimized builds.

rdar://17999904

Swift SVN r21323
2014-08-20 22:48:55 +00:00
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