Commit Graph

752 Commits

Author SHA1 Message Date
Han Sangjin
b8dd577693 [swiftc] Fixed for Cygwin
Fixed for the difference of Cygwin with other Windows variants (MSVC,
Itanium, MinGW).

- The platform name is renamed to "cygwin" from "windows" which is used
  for searching the standard libraries.

- The consideration for DLL storage class (DllExport/DllImport) is not
  required for Cygwin and MinGW. There is no problem when linking in
  these environment.

- Cygwin should use large memory model as default.(This may be changed
  if someone ports to 32bit)

- Cygwin and MinGW should use the autolink feature in the sameway of
  Linux due to the linker's limit.
2017-01-19 05:48:24 +09:00
Brian Gesiak
b769d9941d [IRGen] Add word missing from comment (NFC)
The sentence in the comment trailed off even when it was added in
64a6a739, but the author may have meant putting arbitrary keys in the
Objective-C image info.
2017-01-10 23:28:21 -05:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
38be6125e5 [gardening] C++ gardening: Terminate namespaces, fix argument names, ...
Changes:
* Terminate all namespaces with the correct closing comment.
* Make sure argument names in comments match the corresponding parameter name.
* Remove redundant get() calls on smart pointers.
* Prefer using "override" or "final" instead of "virtual". Remove "virtual" where appropriate.
2016-12-17 00:32:42 +01:00
Michael Gottesman
59c6a64f5a [gardening] 0 => nullptr. Fixed with clang-tidy. 2016-12-06 23:14:13 -08:00
Erik Eckstein
9f8b68ae11 Mangling: use macros instead of hard-coded swift symbol names.
This makes it easier to switch between the old and new mangling scheme.
2016-12-02 15:55:30 -08:00
Hugh Bellamy
1aa951dfb2 Fix errors and warnings building swift/IRGen on Windows using MSVC (#5958) 2016-11-30 13:27:02 -08:00
practicalswift
797b80765f [gardening] Use the correct base URL (https://swift.org) in references to the Swift website
Remove all references to the old non-TLS enabled base URL (http://swift.org)
2016-11-20 17:36:03 +01:00
Adrian Prantl
f42dcb9551 Revert "Debug Info: Assert that the main source file name is non-empty."
This reverts commit 3fd5afc6d0.
while investigating buildbot breakage.
rdar://problem/28457719
2016-09-23 16:54:10 -07:00
Adrian Prantl
3fd5afc6d0 Debug Info: Assert that the main source file name is non-empty.
The Darwin linker won't process the debug info if the source file name
is invalid so there is no point in having a fallback implemented there.

<rdar://problem/25130236>
2016-09-23 10:30:59 -07:00
Michael Gottesman
fa1bb95923 Merge remote-tracking branch 'origin/master' into master-next 2016-08-30 19:50:12 -07:00
John McCall
1a2daa7586 Force LLVM to preserve value names in the same situations where we emit them in the first place.
Fixes IRGen test failures that only arise in non-asserts builds that
we've apparently been working around in less principled ways for
the last few months.
2016-08-04 18:46:51 -07:00
Mark Lacey
1c00ac4c6d Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	lib/IRGen/IRGen.cpp
	test/DebugInfo/parent-scope.swift
2016-07-15 19:23:53 -07:00
Saleem Abdulrasool
eeebf0cbe3 IRGen: give the force load symbol export DLL storage
The force load symbol was not marked as DLL export.  This would result in the
symbol not being emitted into the import library and consequently not being
available to the consumer.  This ensures that the symbol is visible outside of
the module.
2016-07-14 09:35:30 -07:00
swift-ci
3691b48c67 Merge pull request #2080 from compnerd/dllstorage 2016-07-07 18:02:08 -07:00
adrian-prantl
b1e0afc039 Merge pull request #3350 from adrian-prantl/25498103
Debug info diet!
2016-07-07 11:34:21 -07:00
Saleem Abdulrasool
7352392830 IRGen: add support for DLL Storage semantics
Add initial support for modelling DLL Storage semantics for global values.  This
is needed to support the indirect addressing mechanism used on Windows.
2016-07-06 18:03:57 -07:00
Adrian Prantl
6b1263bf5a [Driver] Add a -gdwarf-types option and set it up as an alias for -g (NFC-ish)
Background
----------

Now that Swift AST type support in LLDB has matured, we can stop emitting DWARF
type information by default to reduce compile time and ibject file size.
A future commit will change -g to emit only AST type references.

The full set of debug options will be
-gnone
-gline-tables-only
-g                 // AST types (= everything that LLDB needs)
-gdwarf-types      // AST types + DWARF types (for legacy debuggers)
2016-07-05 12:06:23 -07:00
Michael Gottesman
3c603ab18b Merge remote-tracking branch 'origin/master' into master-next 2016-07-01 18:44:21 -07:00
Saleem Abdulrasool
83901998c9 Port for PS4
Add support for the PS4 OS.  Update the standard library and add a target unit
test.
2016-06-30 20:14:50 -07:00
Saleem Abdulrasool
97d97cbf1f IRGen: address a TODO in the autolinking
Use the target specific directive generation.  This addresses a TODO to use the
same logic as clang.  Unfortunately, the logic in clang is not accessible
outside of it, so replicate the behaviour.
2016-06-28 18:42:51 -07:00
Vedant Kumar
1409a445d9 [stable-merge] Adopt new setUnnamedAddr API 2016-06-27 11:12:28 -07:00
Joe Groff
22c4e08b96 IRGen: Fix TypeInfo for witness_method SIL values.
@convention(witness_method) values were changed to carry a pointer to their source witness table, but the type info wasn't changed to match. Fixing this fixes rdar://problem/26268544.
2016-06-14 10:22:37 -07:00
Dmitri Gribenko
1d666d1950 Merge pull request #2897 from compnerd/autolink-coff
Native autolinking on COFF
2016-06-04 22:18:48 -07:00
Saleem Abdulrasool
7837db48d2 IRGen: dont use autolink-extract for COFF targets
COFF supports the `.drectve` section for embedding linker directives.  LLVM has
long supported emitting this section.  With this move, ELF shall become the only
target needing the autolink-extract functionality.
2016-06-04 17:37:27 -07:00
Saleem Abdulrasool
89bebf897f IRGen: change switch to be covered
Rather than adding a default case, add the missing case and rely on covered
switches providing indications of future additions.  NFC.
2016-06-04 15:04:13 -07:00
Saleem Abdulrasool
6023745e42 IRGen: clean up some debug code
Seems that there was some accidental debug code checked in.  Remove it.  NFC.
2016-06-04 14:53:44 -07:00
John McCall
838b12e41d Adjust for API changes in Clang. 2016-05-17 22:44:14 -07:00
John McCall
06c65464cf Don't crash if an error is emitted by Clang IR-generation.
Clang IR-generation can fail.  When it does this, it destroys the
module. Previously, we were blithely assuming this couldn't happen,
and so we would crash on the deallocated module.  Delay the
finalization of the Clang code generator until our own module
finalization, which is a more appropriate place for it anyway,
and then just bail out of the last few steps if Clang fails.
2016-05-17 12:38:53 -07:00
Michael Gottesman
bdac088e0a [upstream-update] Rename of namespace clang::CodeGenOptions => clang::codegenoptions. NFC.
(cherry picked from commit 57b0c35375fae8d7186862ddc41d6a8a5fdfe135)
(cherry picked from commit 45c518df0b4e0939b98f2f16fc3b45bf05780030)
2016-05-13 22:03:21 -07:00
John McCall
8e3151f451 Switch the TargetMachine back to being IGM-specific instead of global to the IRGenerator.
My understanding is that this *should* be read-only, but there
are test cases that are failing that suggest it might not be.
2016-04-27 10:38:10 -07:00
John McCall
6c92c324f6 Rename IRGenModuleDispatcher to just IRGenerator and transfer
ownership of some of the basic structures to it.
2016-04-27 09:42:03 -07:00
John McCall
822f6d0729 Remove redundant llvm::DataLayout argument from IRGenModule constructor. 2016-04-26 17:24:48 -07:00
John McCall
b340e439c8 Remove redundant llvm::Triple argument from IRGenModule constructor. 2016-04-26 17:19:09 -07:00
David Farler
09d0cfee8d Hang closure capture descriptors from their heap metadata
Now we can discern the types of values in heap boxes at runtime!
Closure reference captures are a common way of creating reference
cycles, so this provides some basic infrastructure for detecting those
someday.

A closure capture descriptor has the following:

- The number of captures.
- The number of sources of metadata reachable from the closure.
  This is important for substituting generics at runtime since we
  can't know precisely what will get captured until we observe a
  closure.
- The number of types in the NecessaryBindings structure.
  This is a holding tank in a closure for sources of metadata that
  can't be gotten from the captured values themselves.
- The metadata source map, a list of pairs, for each
  source of metadata for every generic argument needed to perform
  substitution at runtime.
  Key: The typeref for the generic parameter visible from the closure
  in the Swift source.
  Value: The metadata source, which describes how to crawl the heap from
  the closure to get to the metadata for that generic argument.
- A list of typerefs for the captured values themselves.

Follow-up: IRGen tests for various capture scenarios, which will include
MetadataSource encoding tests.

rdar://problem/24989531
2016-04-22 19:09:06 -07:00
David Farler
263af75590 Revert "Stamp Swift binaries with the reflection version"
This reverts commit 437d3f2043.
2016-04-15 12:26:27 -07:00
Slava Pestov
824bd7544d IRGen: Emit typerefs for all builtin types referenced from reflection metadata sections
In order to perform layout, the remote mirrors library needs to know
about the size, alignment and extra inhabitants of builtin types.

Ideally we would emit a reflection info section in libswiftRuntime.o,
but in the meantime just duplicate builtin type metadata for all
builtin types referenced from the current module instead.

In practice only the stdlib and a handful of overlays like the SIMD
overlay use builtin types, and only a few at a time.

Tested manually by running swift-reflection-tool on the standard
library -- I'll add automated tests by using -parse-stdlib to
reference Builtin types in a subsequent patch that adds more layout
logic.

NFC if -enable-reflection-metadata is off.
2016-04-15 00:12:11 -07:00
David Farler
437d3f2043 Stamp Swift binaries with the reflection version
This will be cross-checked with SwiftRemoteMirror's version
compatibility.

rdar://problem/25559468
2016-04-07 20:16:13 -07:00
Roman Levenstein
b985794992 Prepare IRGen and LLVM passes to use the new preserve_most calling convention, but do not enable it yet.
The convention should be enabled once we can properly build the runtime library using Siwft's own clang/llvm binaries.
2016-04-01 14:19:47 -07:00
Roman Levenstein
5eca6e4df4 Get rid of a workaround for the JIT symbol lookup.
The underlying LLVM JIT problem is solved now and there is no need for any workarounds.
2016-03-03 16:03:50 -08:00
Slava Pestov
b3103ac7b7 Runtime: Fix alignment issue in default witness tables
The size of a protocol's metadata was not a multiple of 8 bytes, so
on 64-bit platforms, the runtime would copy default witnesses from
the wrong address, because IRGen metadata does not add alignment padding,
whereas the in-memory structure does.

Fix this by adding a 32-bit padding field at the end of the protocol
descriptor. Technically this is not necessary on 32-bit, but this keeps
things simpler for now.

The test case for this is a library evolution test exercising resilient
default protocol requirements, but it is not quite ready to go in yet.
2016-03-03 07:36:59 -08:00
practicalswift
795b86004b [gardening] When using C style comments, stick to the one line form.
In the rare cases where C style comments are needed sticking with the
one line form is preferred to allow for quick comment analysis by
simple methods such as:

$ git grep -E '(//|/\*.*\*/)'

When using the single line form the command above is guaranteed to
include all comment content (+ some non-comment content), which
greatly simplifies quick comment analysis.
2016-03-02 10:06:55 +01:00
swiftix
2573782c8b Merge pull request #1357 from swiftix/wip-runtime-calling-convention
Prepare the ground for using a new calling convention for functions from the runtime library
2016-03-01 16:22:37 -08:00
John McCall
3ce1ba3e65 Only store the minimal requirements in generic metadata, where
"minimal" is defined as the set of requirements that would be
passed to a function with the type's generic signature that
takes the thick metadata of the parent type as its only argument.
2016-02-25 10:33:33 -08:00
Roman Levenstein
f9d0609d16 Fix a dynamic symbol lookup issue in interpreter mode.
This was a very subtle bug, which occurred only in interpreter mode under Linux.
The actual name of the symbol should be artificially prefixed by an underscore,
because this underscore is stripped during a symbol lookup in interpreter mode.
If this is not done, then a reference to variable "_x" is being resolved as a reference
to the function "x"!
2016-02-25 09:11:15 -08:00
Roman Levenstein
2ff5755dc3 Use the "rt_" prefix for all generated wrappers to distinguish them from the actual runtime functions. 2016-02-25 06:00:30 -08:00
Roman Levenstein
99fd8b6080 Rename some macros based on the PR review comments.
- use  the SWIFT prefix for all macros
- make names of some macros shorter
2016-02-25 05:31:00 -08:00
Roman Levenstein
de3b850ce8 Use more descriptive names for calling conventions.
Rename RuntimeCC into DefaultCC
Rename RuntimeCC1 into RegisterPreservingCC
Remove RuntimeCC0 because it was identical to DefaultCC.
2016-02-25 05:31:00 -08:00
Roman Levenstein
2956e5675f Update x-macro metaprogramming support in IRGenModule.
Teach IRGen how to handle runtime functions definitions in RuntimeFunctions.def
depending on their calling convention and on their need for global symbols referring
to their internal implementations.

IRGen would now generate wrappers for runtime functions invocations if at least one
of the following conditions is met:
- The runtime function is defined using FUNCTION_WITH_GLOBAL_SYMBOL_AND_IMPL,
  which explicitly states that it has a global symbol referring to its implementation. In this case,
  the generated wrapper will perform an indirect call using the specified global symbol.
  This results in some performance improvements, because doing so removes one level of
  indirection during a call of the runtime function.
  The invocation sequence before looked like:
    Swift code -> dynamic linker stub -> runtime_function -> indirect call of runtime_function's implementation through a global function pointer
  And using a wrapper it becomes:
    Swift code -> wrapper -> indirect call of runtime_function's implementation through a global function pointer

- The runtime function is defined using the usual FUNCTION x-macro but it uses a calling convention
   that requires that wrappers should be used instead of dynamic linker stubs to avoid the situations
   where the dynamic linker would clobber some of the callee-saved registers when it performs a lazy
   binding of the runtime function, which may lead to an undefined behaviour during the program execution.

   In this case, the behaviour is similar to the first case, except that the name of the global symbol for
   the  runtime function f is assumed to be _f, i.e. it has an underscore as a prefix. This symbol
   will be auto-generated and properly initialized by an x-macro based metaprogramming machinery
   in the runtime library.
2016-02-25 05:31:00 -08:00
Roman Levenstein
4941f51388 Add a new RuntimeCC1 calling convention in IRGen.
This calling convention can be now used in RuntimeFunctions.def.
2016-02-25 05:30:59 -08:00