Commit Graph

629 Commits

Author SHA1 Message Date
Arnold Schwaighofer
aaa60d3bd8 Renable SLP vectorization
The necessary fixes are in llvm.

rdar://22673382
2015-11-16 09:51:54 -08:00
Erik Eckstein
ce848c648d And again: re-apply the StackPromotion commit 0dd045ca04.
The problem of the failure was a bug in instruction cloning, which is fixed in the previous commit.
2015-11-08 15:51:00 -08:00
Mark Lacey
e9718f619e Revert "Another try to re-apply the StackPromotion commit 0dd045ca04dcc10a33abf57f7e1b08260c4e3de1."
This reverts commit 7d70aa39dc because
it may be responsible for a bot breakage.
2015-11-07 16:51:24 -08:00
Erik Eckstein
7d70aa39dc Another try to re-apply the StackPromotion commit 0dd045ca04.
One bug fixed in escape analysis (previous commit) and one bug fixed in StackPromotion itself.
2015-11-06 16:16:36 -08:00
Arnold Schwaighofer
fd662987c8 Revert the StackPromotion pass - bots hit an assert.
Assertion failed: (NumUsePointsToFind > 0 && "There must be at least one
releasing instruction for an alloc"), function canPromoteAlloc

Revert "Fix comment for StackPromotion pass in SIL Passes"
Revert "Reapply the StackPromotion commit
0dd045ca04dcc10a33abf57f7e1b08260c4e3de1."

This reverts commit 3f4b1496bd and commit
199cfca13b.
2015-11-06 06:40:05 -08:00
Erik Eckstein
199cfca13b Reapply the StackPromotion commit 0dd045ca04.
This time with fixing a crash.
2015-11-05 22:01:27 -08:00
Erik Eckstein
d7b7fc76ea Revert "Add a stack promotion optimization."
This reverts commit 0dd045ca04.

StackPromotion crashes when compiling MatMult in stdlib-asserts configuration
2015-11-05 21:34:05 -08:00
Erik Eckstein
0dd045ca04 Add a stack promotion optimization.
It promotes allocations of native swift objects and array buffers to the stack if it is possible.
The SIL StackPromotion pass is the main part of the optimization. For details see comments there.
Unfortunately we need an additional LLVM pass to handle array buffers, which is not very nice.
I hope that we can get rid of it in future (again: for details see the comments in StackPromotion.cpp)

The optimization gives performance improvements in some benchmarks, mostly related to array literals:
ArrayLiteral: +12%
Combos: +16%
DictionaryLiteral: + 37%
RIPEMD: +10%
StringBuilder: +27%
StringInterpolation: +11%
And last but not least the new benchmark which is dedicated to test stack promotion:
ObjectAllocation: +52%
2015-11-05 16:52:59 -08:00
Michael Gottesman
4fae42e7bf [irgen] Refactor out the pass pipeline build code in IRGen so that llvm-swift-opt can use it.
llvm-swift-opt is a swift only version of opt that will be used to remove
swift's dependency on dynamically injecting passes into opt and to allow for
IRGen's LLVM pipeline to be simulated exactly by reusing the IRGen pass pipeline
building code.

The reason to remove the dynamic code is that it seems that this is code that
will be in flux vis-a-vis the transition to the new pass manager in LLVM, so it
makes sense to make this change now due to the benefit provided by exactly
simulating IRGen.

Swift SVN r32804
2015-10-21 21:45:18 +00:00
Michael Gottesman
72f5063f3c Update SwiftAA for upstream AA changes.
Swift SVN r32800
2015-10-21 21:45:13 +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
Arnold Schwaighofer
d78c964fd7 Revert "Renable LLVM's MergeFunctions pass"
This reverts commit r32421.

It broke the incremental bot.

Swift SVN r32422
2015-10-03 15:34:55 +00:00
Arnold Schwaighofer
1c9aa5914a Renable LLVM's MergeFunctions pass
rdar://20920907

Swift SVN r32421
2015-10-03 14:44:10 +00:00
Arnold Schwaighofer
d430903eb1 Temporarily disable the SLPVectorizer
The SLPVectorizer vectorizes loads from a packed struct of i2s.

 {<i2, i2, i2, i2>}

The problem with that is that LLVM codegens scalar accesses to such a type as
if it where a packed i8 struct.
So when we emit a vector load of <4 x i2> (i.e one byte) and extract any non
zero index element we get garbage. Disable the SLPVectorizer until it is fixed.

rdar://22673382

Swift SVN r32299
2015-09-29 14:39:01 +00:00
Joe Groff
dd9f28e1df IRGen: Emit protocol conformances on the parallel IRGen path too.
The new implementation needs to happen after all source files have been built and before lazy definitions are emitted, but I neglected to insert it in the parallel IRGen path. Fixes rdar://problem/22825770.

Swift SVN r32189
2015-09-23 22:37:37 +00:00
Michael Gottesman
1e3a73eb55 Update commit for change in DataLayout API.
Swift SVN r31818
2015-09-09 04:37:49 +00:00
Michael Gottesman
b564b414cb Update for DataLayout changes
Swift SVN r31801
2015-09-09 04:37:18 +00:00
Adrian Prantl
1d3af192bb Reformat createSwiftModuleObjectFile() for readability.
Swift SVN r31677
2015-09-03 23:27:41 +00:00
Adrian Prantl
0de0d43773 Introduce a -modulewrap driver action that wraps a (merged) .swiftmodule
inside a swift ast section in an object file so it can be passed to the
linker. The driver automatically wraps merged swiftmodules iff the target
is ELF.

rdar://problem/22407666

Swift SVN r31641
2015-09-02 21:56:25 +00:00
Joe Groff
773eadb9f2 IRGen/Runtime: Populate the runtime protocol conformance table with relative references.
By using relative references, either directly to symbols internal to the current TU, or to the GOT entry for external symbols, we avoid unnecessary runtime relocations, and we save space on 64-bit platforms, since a single image is still <2GB in size. For the 64-bit standard library, this trades 26KB of fake-const data in __DATA,__swift1_proto for 13KB of true-const data in __TEXT,__swift2_proto. Implements rdar://problem/22334380.

Swift SVN r31555
2015-08-28 18:07:22 +00:00
Michael Gottesman
2315c8fd06 [llvm-arc-opts] Rename SwiftARCExpand => SwiftARCContract.
This pass does things similar to LLVMARCContract so it makes sense to use the
same naming schema.

Also I am going to be implementing some contracting optimziations here later
today.

Swift SVN r30203
2015-07-15 00:03:01 +00:00
Dmitri Hrybenko
2fc1cbe8c1 Adjust to the new IRBuilder APIs
Swift SVN r29692
2015-06-25 22:01:24 +00:00
Dmitri Hrybenko
92897ea2c9 IRGen: stop using the DisableFPElim target option
Use function attributes instead.  This is required for a newer LLVM
since it does not have the target option at all.

rdar://21480622

Swift SVN r29676
2015-06-25 18:24:37 +00:00
Greg Parker
779480abc5 [IRGen] Disable LLVM's MergeFunctions pass.
This reverts r29409.

MergeFunctions breaks struct-return ABI on i386 and arm64: rdar://21481081


Swift SVN r29590
2015-06-24 01:20:29 +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
Arnold Schwaighofer
2eb8688420 Revert "Disable LLVM's MergeFunctions again"
Renable the merge function pass. More bugs in LLVM's MergeFunction pass were
fixed.

This reverts commit r29248.

rdar://20920907

Swift SVN r29409
2015-06-16 23:27:30 +00:00
Arnold Schwaighofer
f94a02ab0a Disable LLVM's MergeFunctions again
It looks like there are more bugs lurking in that pass

rdar://21204610

Swift SVN r29248
2015-06-02 20:54:31 +00:00
Arnold Schwaighofer
15ff698409 IRGen: Give ClangCodeGen a chance to emit its translation unit's global state
We need this because that global state includes tables like llvm[.compiler].used
which would otherwise be sorely missed.

This fixes an issue of the clang importer that would cause us to fail whenever
we imported a function (say it is marked as static inline) that performs an
objective-c method call and we optimize the code. The optimizer would not see
the objective-c selector global variable (which is marked private) as being
"used by unkown i.e the objc runtime" and would rightly assume it could
propagate the value of the global variable's initializer value as a constant to
loads of the global variable.

Now we call the ClangCodeGenerators translation unit finalization code which
will emit these tables and other module flags. We need to take care that we
merge those datastrutures with datastructures that we emit from swift's IRGen.

rdar://21115194

Swift SVN r29176
2015-05-31 00:01:29 +00:00
Arnold Schwaighofer
4b5217ec78 Revert "Disable LLVM's MergeFunctions pass"
Renable the merge function pass. The bug in LLVM was fixed.

This reverts commit r28483.

Swift SVN r29045
2015-05-26 23:55:39 +00:00
Devin Coughlin
6374588f3d [IRGen] Mark Objective-C Watch simulator images as simulated in IRGen setModuleFlags().
We already do for the iOS simulator and the tvOS simulator. This fixes
the 'unrecognized selector sent to instance’ bridging crashes in the stdlib
watch simulator tests.

Greg Parker did the hard work of tracking this down and suggested the fix.

<rdar://problem/20932146>

Swift SVN r28846
2015-05-20 20:39:42 +00:00
Arnold Schwaighofer
cdeb5823f5 Disable LLVM's MergeFunctions pass
It is broken. clang does not enable it by default.

We might consider renabling it. But while we are triaging bugs it makes sense to
disable it.

rdar://20848016

Swift SVN r28483
2015-05-12 18:38:35 +00:00
Doug Gregor
b8995b0aa3 Transform the Module class into ModuleDecl.
Modules occupy a weird space in the AST now: they can be treated like
types (Swift.Int), which is captured by ModuleType. They can be
treated like values for disambiguation (Swift.print), which is
captured by ModuleExpr. And we jump through hoops in various places to
store "either a module or a decl".

Start cleaning this up by transforming Module into ModuleDecl, a
TypeDecl that's implicitly created to describe a module. Subsequent
changes will start folding away the special cases (ModuleExpr ->
DeclRefExpr, name lookup results stop having a separate Module case,
etc.).

Note that the Module -> ModuleDecl typedef is there to limit the
changes needed. Much of this patch is actually dealing with the fact
that Module used to have Ctx and Name public members that now need to
be accessed via getASTContext() and getName(), respectively.

Swift SVN r28284
2015-05-07 21:10:50 +00:00
Erik Eckstein
94b3f8c545 IRGen: improve debug logging for multi-threaded compilation
Swift SVN r28115
2015-05-04 15:10:49 +00:00
Erik Eckstein
f362570fb9 Change IRGenModuleDispatcher to a reference in IRGenModule.
According to Sean's feedback.



Swift SVN r27692
2015-04-24 09:17:29 +00:00
Erik Eckstein
8bd9712ed3 Fix crash when compiling a module with a main-file with -g and -wmo -num-threads.
rdar://problem/20655307



Swift SVN r27631
2015-04-23 08:32:47 +00:00
John McCall
136965d9f8 Enter the brave new world of Swift 2.0.
Bump the ABI version while we're at it; there's no reason not to be bumping this for every release.

Swift SVN r27194
2015-04-10 01:12:21 +00:00
Erik Eckstein
277dd82473 IRGen: add TODOs for error handling
Swift SVN r26360
2015-03-20 18:56:56 +00:00
Erik Eckstein
87389cb0ae IRGen: Exit with an error in case of no source files for multi-threaded compilation.
Swift SVN r26352
2015-03-20 10:47:11 +00:00
Erik Eckstein
22991b1088 Multi-threaded llvm code generation (experimental).
It can be enabled with the -num-threads <n> option.
Without this option there should be NFC.

When enabled, the LLVM IR is split into multiple modules: one module for each input file.
And for each module an output file is generated. All output files must be specified with -o options:
for each input file in the command line there must be an -o <outputfile> option.

LLVM compilation is performed on each module separately.
This means that the generated code is different than with regular -wmo.
But performance and code size should be approximately the same because important inter-file
optimizations are already done at SIL level (e.g. inlining, specialization).

There is still no support in the driver for this feature.



Swift SVN r25930
2015-03-10 16:52:14 +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
Luqman Aden
34b74cfa1c [driver] Add -emit-sib primary action.
Swift SVN r25783
2015-03-05 19:15:07 +00:00
Andrew Trick
af711933b7 Update DataLayout API for upstream LLVM changes.
Swift SVN r25771
2015-03-04 23:21:47 +00:00
Manman Ren
0f7fb29331 [bitcode] use __swift_cmdline instead of __cmdline to differentiate from clang.
Swift SVN r25716
2015-03-03 20:00:19 +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
daa111dcca Rename function EmbedBitcode to embedBitcode.
Swift SVN r25579
2015-02-27 00:44:25 +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
d39f8e49a8 [Driver] make Swift accept bitcode input.
Thanks Jordan for reviewing the patches.
rdar://19048891


Swift SVN r25558
2015-02-26 19:31:09 +00:00
Manman Ren
26431e0eac Update interface of getIRTargetOptions. Review feedback from Jordan.
Swift SVN r25441
2015-02-20 23:33:05 +00:00
Manman Ren
db16b534e0 Refactor part of performIRGeneration to createTargetMachine and performLLVM.
This helps us to support bitcode input. No functionality change.


Swift SVN r25435
2015-02-20 21:02:18 +00:00
Ben Langmuir
98c64214a3 Update for LLVM PassManager change r229094
PassMangager.h is gone.

Swift SVN r25272
2015-02-13 16:36:45 +00:00