Commit Graph

263 Commits

Author SHA1 Message Date
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
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