Commit Graph

238 Commits

Author SHA1 Message Date
Andrew Trick
ab129dfb39 Add -global-opt pass.
Currently, this pass simply hoists calls to addressor functions up to
the function entry point. This solves most of the perfomance problem.

Fixes <rdar://problem/16500879> Need to hoist @swift_once outside of loops.

Swift SVN r16684
2014-04-23 01:09:48 +00:00
Arnold Schwaighofer
989d554a45 Add support for an assert_configuration builtin function
This patch adds support for a builtin function assert_configuration that is
replaced by constant progpagation by an appropriate value dependent on a compile
time setting. This replacement can also be disabled when serializing sil for a
library.

Using this mechanism we implement assertions that can  be disabled (or whose
behavior changes) depending on compile time build settings (Debug, Release,
DisableReplacement).

In the standard library we can now write one assert function that uses this
builtin function to provide different compile time selectable runtime behavior.

Example

Assert.swift:

@transparent
func assert<T : LogicValue>(
  condition: @auto_closure () -> T, message: StaticString = StaticString(),

  // Do not supply these parameters explicitly; they will be filled in
  // by the compiler and aren't even present when asserts are disabled
  file: StaticString = __FILE__, line: UWord = __LINE__
) {
  // Only in debug mode.
  if _isDebug() {
    assert(condition().getLogicValue(), message, file, line)
  }
}

AssertCommon.swift:

@transparent
func _isDebug() -> Bool {
  return Int32(Builtin.assert_configuration()) == 0;
}

rdar://16458612

Swift SVN r16472
2014-04-17 22:05:42 +00:00
Michael Gottesman
cffc3d372d [constant-propagation] Refactor constant propagation slightly to disable diagnostics so we can use it in the performance passes to help with branch simplification.
This commit also enables constant propagation in the performance
pipeline.

Since we are close to WWDC, this commit purposefully minimally touches
the pass (despite my hands wanted to refactor it so bad) just enough so
that we get the desired result with minimal in tree turmoil.

rdar://16604715

Swift SVN r16388
2014-04-16 01:49:16 +00:00
Michael Gottesman
1c7405343d [sil-opt] Add in support for passing in an SDK path so we can parse modules with clangimporter dependencies.
Swift SVN r16266
2014-04-12 22:35:02 +00:00
Michael Gottesman
4e73547a3e Change SerializedSILLoader::create to return a unique_ptr and use that everywhere so we don't leak SILLoaders.
Swift SVN r15700
2014-03-31 22:57:03 +00:00
Michael Gottesman
0727628c8c [deserialization] Add in the linker pass.
Swift SVN r15671
2014-03-31 08:40:36 +00:00
Nadav Rotem
5500bdae22 Add a command line flag for removing cond_fails in SIL.
Swift SVN r15432
2014-03-25 00:51:01 +00:00
Michael Gottesman
5b88963e78 [SIL] Implement external SIL Witness Table declarations.
This will help with ensuring that we do not create multiple witness
table "definitions" one of which is null. That situtation yields an
IRGen assertion to be hit since the external declaration (in the guise
of a definition) has a different type from the actual deserialized
definition.

Swift SVN r14999
2014-03-13 19:52:59 +00:00
Jordan Rose
49ec7c1ea1 Use SWIFT_MODULE_CACHE_PATH for all tools.
Now that the standard library depends on Clang headers, every single tool
needs to specifically avoid using the default module cache when
SWIFT_MODULE_CACHE_PATH is set.

<rdar://problem/16294222>

Swift SVN r14937
2014-03-12 00:27:24 +00:00
Dmitri Hrybenko
255b8e88c8 Fix a leak that I introduced in r14729: FrontendOptions does not own input
buffers, so undo 'unique_ptr'fication here


Swift SVN r14733
2014-03-06 13:53:04 +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
Chris Lattner
8869767260 Implement the rest of rdar://16242700
Fix a phase ordering problem: SILGen of a noreturn function doesn't drop an unreachable after the function,
and doing so is problematic for various reasons (all expressions would have to handle their insertion point
vaporizing, and would have to emit unreachable code diagnostics).  Instead, run a simple pass that folds
noreturn calls and diagnoses unreachable code, and do it before DI.  This prevents DI from seeing false
paths, and rejecting what seems like invalid code.



Swift SVN r14711
2014-03-06 01:29:32 +00:00
Michael Gottesman
c25d6f8390 [mandatory-inlining] Use getOptions() instead of passing around options.
Swift SVN r14493
2014-02-28 01:51:53 +00:00
Michael Gottesman
29e1a53bbb [deserialization] Deserialize transparent functions lazily iff they will be used in mandatory inlining.
Swift SVN r14490
2014-02-28 01:05:01 +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
Dmitri Hrybenko
fef36edc6b Try to fix the build following the LLVM raw_fd_ostream API change
Swift SVN r14304
2014-02-24 17:21:49 +00:00
Michael Gottesman
3a784587f7 [sil-opt] Teach SILOpt how to process module files.
I will be removing sil-dis in a forthcoming commit.

Swift SVN r14236
2014-02-21 23:01:13 +00:00
Michael Gottesman
8ddba95459 [sil-opt] Dump decls as well as SIL.
Swift SVN r14235
2014-02-21 23:01:13 +00:00
Michael Gottesman
2bc8e3e3ed Remove trailing whitespace. NFC.
Swift SVN r14215
2014-02-21 18:33:48 +00:00
Michael Gottesman
1300677b3f [sil-opt] Remove cruft code that was supposed to call the verifier after every
pass and instead was calling the verifier after adding every pass to the pass
manager (i.e. just wasting cpu time). Instead enable sil-verify-all by default
to get the same effect.

Swift SVN r14213
2014-02-21 18:29:32 +00:00
Michael Gottesman
e35f93a551 [sil-opt] Declare PassKind in an anonymous namespace instead of the global scope.
Swift SVN r14212
2014-02-21 18:29:32 +00:00
Michael Gottesman
903d4e85a3 [sil-opt] Change banner description to something actually descriptive.
Swift SVN r14211
2014-02-21 18:21:37 +00:00
Nadav Rotem
d52cbc89dd Rename AllocRefElim -> DeadObjectElim. NFC.
Swift SVN r14179
2014-02-20 23:14:59 +00:00
Michael Gottesman
8cff098f1e Split SILCodeMotion into two passes, LoadStoreOpts and SILCodeMotion.
LoadStoreOpts removes duplicate loads, forwards stores to loads, and eliminates
dead stores.

Swift SVN r13789
2014-02-11 23:36:51 +00:00
Andrew Trick
731000b4cd Added -sil-print-all and -sil-verify-all options.
Swift SVN r13662
2014-02-07 23:07:11 +00:00
Andrew Trick
04b2b5256b First implementation of <rdar://15922760> Deep devirtualization -
specialize on polymorphic arguments.

This can be enabled with: -sil-devirt-threshold 500.

It currently improves RC4 (when enabled) by 20%, but will be much more
important after Michael's load elimination with alias analysis lands.

This implementation is suitable for experimentation. Superficial code
reviews are also welcome. Although be warned that the design is overly
complex and I plan to rewrite it. I initially abandoned the idea of
incrementally specializing one function at a time, thinking that we
need to analyze full chains. However, I since realized after talking
to Nadav that the incremental approach can be made to work. A lot of
book-keeping will go away with that change.

TODO:

- Resolve protocol argument types. Currently we assume they can be
  reinitialized at applies, but I don't think they can unless they are
  @inouts.  This is an issue with the existing local devirtualizer
  that prevents it working across calls.

- Properly mangle the specialized methods. Find existing
  specializations by demangling rather than maintaining a map.

- Rewrite the logic for specializing chains for simplicity.

- Enable by default.

Swift SVN r13642
2014-02-07 19:10:27 +00:00
Andrew Trick
47b936fbae Let passes get their options (current configuration) from the
PassManager.

I think this is much cleaner and more flexible. The various pass
builders have no business marshalling these things around, and they
shouldn't be bound to the pass C'tor. In the future we will be able
override and dynamically modify pass configuration this way.

Swift SVN r13626
2014-02-07 05:01:00 +00:00
Michael Gottesman
312cab7cca Change invoking id for AADumper in sil-opt from aa-evaluator => aa-dump.
Swift SVN r13604
2014-02-06 23:24:01 +00:00
Michael Gottesman
cd0e0b8c27 Rename AAEvaluator => AADumper as per request.
Swift SVN r13603
2014-02-06 23:19:35 +00:00
Nadav Rotem
591a42aae3 Rename a few more pass factory methods.
Swift SVN r13588
2014-02-06 17:52:18 +00:00
Nadav Rotem
7cfb83449e Rename the pass to AllocBoxToStack
Swift SVN r13586
2014-02-06 17:43:54 +00:00
Michael Gottesman
4c92002736 [sil-aa] Create utility pass AAEvaluator which just evaluates AA on all values in a function. This is so that tests can be written to test out the AA implementation.
Swift SVN r13578
2014-02-06 10:06:21 +00:00
Nadav Rotem
0651b9bbd0 Add a new Dominance Analysis that wraps DomInfo and PDomInfo, and migrate the
passes that use them.



Swift SVN r13571
2014-02-06 07:52:16 +00:00
Michael Gottesman
098fda670f [sil-aa] Change SIL AliasAnalysis into an Analysis.
Swift SVN r13550
2014-02-06 02:29:41 +00:00
Michael Gottesman
d57c18c789 [sil-opt] Move PM.run() outside of the loop that sets up the pass manager so we don't run it every time we add a new pass.
Swift SVN r13512
2014-02-05 22:21:47 +00:00
Michael Gottesman
d369b6dbed Add simple inst count pass for counting the various instructions in a module.
Swift SVN r13510
2014-02-05 22:11:40 +00:00
Nadav Rotem
18fac942e2 Migrate sil-opt and some passes to the new Pass Mananger.
Swift SVN r13509
2014-02-05 22:00:50 +00:00
Jordan Rose
c7f1064527 Extract '-sil-inline-threshold' from the performance inliner.
Plumbing this through to the inliner necessitated the creation of a
SILOptions class (like FrontendOptions and IRGenOptions). I'll move
more things into this soon.

One change: for compatibility with the new driver, the option must be
specified as "-sil-inline-threshold 50" instead of "-sil-inline-threshold=50".
(We're really trying to be consistent about joined-equals vs. separate
in the new frontend.)

Swift SVN r13193
2014-01-31 01:52:12 +00:00
Nadav Rotem
230842221e Move the code motion optimizations into a new pass. NFC.
Swift SVN r13150
2014-01-30 17:32:57 +00:00
Michael Gottesman
49b0668831 Remove alloc_ref with simple destructors and only store users.
This pass attempts to remove alloc_ref and everything that uses the alloc_ref
if:

1. The alloc_ref has a destructor which we can very does not have escaping side
effects.
2. The alloc_ref does not have any non-trivial uses that are not stores.

It reduces ObjInst on my cpu from 10206922128 ns to 46 ns (i.e. nothing).

Swift SVN r12990
2014-01-27 08:59:20 +00:00
Joe Groff
28c1d340b5 Remove SIL 'StripRuntimeChecks' pass.
Without build configurations we can't strip runtime checks from the SIL without also disable diagnostics for library users. We're going to try a different stopgap approach of not emitting the runtime checks in IRGen for the short term.

Swift SVN r12586
2014-01-20 17:06:00 +00:00
Michael Gottesman
3988374855 [sil-strip-debug-info] Added new pass that strips out debug info. Only runs via sil-opt.
The muse hit me.

Swift SVN r12392
2014-01-16 05:14:12 +00:00
Joe Groff
197a1653fd SIL: Start on a StripRuntimeChecks pass.
In the long term we want more detailed configurability of runtime checks, but for our short-term performance work we just want a blanket on/off switch. Add a StripRuntimeChecks SIL pass that, as a start, converts invocations of checked overflow builtins to the equivalent unchecked builtins and kills cond_fails. Expose it through the compiler with a -disable-all-runtime-checks switch.

NB: I haven't tested building the stdlib or running the tests with the switch thrown yet.

Swift SVN r12379
2014-01-16 02:35:16 +00:00
Michael Gottesman
ae3b999925 Recommit "Very initial ARC optimizer implementation."
This recommits r12264 with the necessary changes to fix a bad thinko.

Swift SVN r12272
2014-01-14 03:08:52 +00:00
Dave Abrahams
9f99f02b24 Revert "Very initial ARC optimizer implementation."
This reverts commit r12264, which was breaking tests for me

Swift SVN r12270
2014-01-14 02:35:32 +00:00
Michael Gottesman
3650a75c99 Very initial ARC optimizer implementation.
For simplicity it currently only moves copy_values, strong_retains since we are
not doing the data flow analysis yet.

Even with its limitations (which are extreme), we are removing ~400
retain/release/copyvalue/destroyvalue pairs from the standard library.

Additionally we reduce the time RC4 takes from 7.5-5.5 (2 second delta).

Swift SVN r12264
2014-01-14 01:09:00 +00:00
Nadav Rotem
970c387c34 Refactor devirt related optimizations from sil-combine into a new pass.
The reason is that I would like to add more sophisticated analysis and a
chache, which does not fit into sil-combine very well.



Swift SVN r12221
2014-01-13 07:34:25 +00:00
Michael Gottesman
0100b2a75c [sil-sroa] SIL Scalar Replacement of Aggregates.
Swift SVN r11918
2014-01-06 03:44:54 +00:00
Michael Gottesman
612d622290 Rename current SILSROA => SILLowerAggregateInstrs.
Swift SVN r11739
2013-12-30 08:21:19 +00:00
Michael Gottesman
d6bf276e88 [sil-sroa] Very initial simple initial commit of SILSROA. Currently only lowers
copy_addr, destroy_addr into their constituant parts without performing any
chopping to unblock Nadav.

The plan is to use type lowering to chop these up and then rewrite afterwards.
But for now I want to unblock Nadav.

Swift SVN r11728
2013-12-30 00:17:37 +00:00