Commit Graph

558 Commits

Author SHA1 Message Date
Bob Wilson
3fd92f82e8 Use StringRef in more places to match recent llvm changes.
llvm r283043 and possibly other recent changes switch to use StringRef
instead of char* pointers. Update Swift to match. In some cases, this is
a clear improvement. It would be good to assess the impact on memory use,
particularly for the Filename component of source locations.

Note that the change to SILLocation::isNull fixes an apparent bug where
the location was treated as null when the filename was *not* null.
2016-10-15 11:02:07 -07:00
Adrian Prantl
f904bfa7e6 Debug Info: Use the main module as scope for top-level closures.
This works around a compiler crash when a top-level closure is inlined
into a different compile unit. The top-level-code function is only
generated once so the parent cannot be resolved in any other CU.
This change is NFC as far as the generated DWARF is concerned.

Fixes SR-2725.
2016-10-03 13:57:17 -07: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
489e80546e Merge pull request #4963 from adrian-prantl/25130236
Assert that the main source file name is non-empty.
2016-09-23 15:36:45 -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
Adrian Prantl
fa28b5e16b Debug Info: Insert dbg.value intrinsics immediately after the instruction
they describe.

This improves the live ranges of local variables during debugging.

<rdar://problem/26627376>
2016-09-23 10:14:56 -07:00
Adrian Prantl
c198611091 Simplify code. NFC 2016-09-22 11:30:09 -07:00
Mishal Shah
870b785219 Merge pull request #4893 from adrian-prantl/D20147
Update for LLVM API change D20147.
2016-09-20 19:16:32 -07:00
Adrian Prantl
0e9c8e9db4 Update for LLVM API change D20147. 2016-09-20 18:14:03 -07:00
Graydon Hoare
8970d44675 Add "-swift-version <n>" that sets LangOpts.EffectiveLanguageVersion.
This flag switches the "effective language version" of the compiler,
at least to any version supported (as of this change: "3" or "3.0").

At the moment nothing uses it except the language version build
configuration statements (#if swift(...)) and various other places
that report, encode, or otherwise check version numbers.

In the future, it's intended as scaffolding for backwards compatibility.

Fixes SR-2582
2016-09-20 15:11:37 -07:00
Michael Gottesman
fa1bb95923 Merge remote-tracking branch 'origin/master' into master-next 2016-08-30 19:50:12 -07:00
Adrian Prantl
73ac8296c4 Cleanup: Don't store VarDecls in DebugTypeInfo. 2016-07-22 09:42:15 -07:00
Adrian Prantl
3b3e308ed3 IRGenDebugInfo: Pass in the VarDecl separatly when emitting variables. (NFC) 2016-07-21 16:03:49 -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
Adrian Prantl
3ffaa762bc Don't emit line table entries for SIL functions marked as thunks.
rdar://problem/26221951
2016-07-07 19:03:28 -07:00
Adrian Prantl
361beff9c0 Emit pointer-sized structs only when -gdwarf-types is specified.
rdar://problem/25498103
2016-07-05 17:03:10 -07:00
Adrian Prantl
0847225962 Only emit DWARF types for enums when -gdwarf-types is specified. 2016-07-05 16:00:09 -07:00
Adrian Prantl
33ac7eb351 Only emit DWARF types for tuple types under -gdwarf-types. 2016-07-05 15:18:05 -07:00
Adrian Prantl
5504a188a3 Only emit DWARF types for structs when -gdwarf-types is specified. 2016-07-05 15:17:37 -07:00
Adrian Prantl
e2f05f046b Only emit DWARF types for function pointers when -gdwarf-types is specified. 2016-07-05 15:16:42 -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
Adrian Prantl
b4d3059051 Debug Info: Unique forward declarations generated for scopes and types.
This is mostly a cleanup and results slightly more efficient debug info.

rdar://problem/25965038
2016-07-01 12:03:39 -07:00
Adrian Prantl
6cb7d56500 Cache the previous result of IRGenDebugInfo::createInlinedAt().
This saves ~4 seconds of a -r --no-assertions stdlib build and lowers
the contribution of llvm::SourceMgr::getLineAndColumn() to the total
runtime from 6% to 2%.

<rdar://problem/27016577>
2016-06-29 15:57:47 -07:00
Adrian Prantl
022a8b1345 Fix a bug that prevented setting a DebugLoc if the first SILInstruction
in the function is setup code for a closure and re-enable the assertions
that caught this on the bots.

rdar://problem/26955467
2016-06-29 10:47:11 -07:00
Adrian Prantl
75e10a66cc This fixes a bot failure in the LLDB testsuite.
This removes an assertion that no longer serves its purpose and
relaxes the IRBuilder checks for debug info when generating code
inside the debugger.

When LLDB is JIT-compiling expressions, it will not generate a
SWIFT_ENTRY_POINT_FUNCTION (there will be one per expression)
but it will still generate the equivalent of top level code.

rdar://problem/26955467
2016-06-28 10:33:40 -07:00
Adrian Prantl
935b702a07 Add an assertion to IRBuilder to prevent function calls with no debug location
It is not valid LLVM IR to have a function call without a location to an
inlinable function inside a function with debug info — this makes it impossible
to construct inline information.

This patch adds an assertion and fixes up several places across IRGen where
such a situation could happen.

rdar://problem/26955467
2016-06-27 19:04:51 -07:00
Adrian Prantl
cf3fdff042 Simplify the definition of isExplicitClosure().
NFC.
2016-06-25 13:44:39 -07:00
Michael Gottesman
cf5dd16bd3 Merge pull request #2546 from compnerd/DL-update
[master-next] update DL method name
2016-06-25 01:50:07 -07:00
Adrian Prantl
bffda8a78d Debugging: Extend the live ranges of local values at -Onone.
For many local values we can avoid a shadow alloca by directly
describing them with a dbg.value. This also enables precise liveness
so variables don't show up in the debugger before they are
initialized. Unfortunately this also means that values will disappear
when they are no longer needed.

This patch inserts an empty inline assembler expression depending on
the llvm::Value that is being described in the blocks dominated by it.
This uses less stack space than full shadow copies *and* allows us to
track the liveness of the variable completely. It may cause values to
be spilled onto the stack, though.

<rdar://problem/26627376>
2016-06-24 10:35:45 -07:00
Adrian Prantl
1d02b3de59 Cleanup: Factor out common functionality in IRGenDebugInfo. 2016-06-07 11:30:20 -07:00
Adrian Prantl
4cee546841 Emit debug info for global variables without storage.
As with local variables this is done by emitting a constant 0 location
and a type of size zero.


<rdar://problem/26660971>
2016-06-06 17:06:20 -07:00
Adrian Prantl
dba926be30 Debug info: Fix the storage size of zero-size types.
This removes an obsolete workaround that prevented zero-sized types from
being emitted with the correct byte size.
2016-06-06 17:06:10 -07:00
Adrian Prantl
ff839429e4 Emit debug info for storage-less variables as constant 0 instead of undef.
LLVM drops debug intrinsics for undef values in SelectionDAG and FastISel.
Until this is fixed, emit a constant 0 to force the variable to be emitted.

<rdar://problem/26429250>
2016-06-06 15:20:18 -07:00
Saleem Abdulrasool
e93b391b87 [upstream-update] update DL method name
Update the name as per SVN r269456.
2016-05-16 11:54:38 -07:00
Adrian Prantl
0fac43e11f Adapt to upstream LLVM changes.
<rdar://problem/25949511+25962000>

(cherry picked from commit df9dfac609d17cd26d6107f17024c937b1b5b1a2)
2016-05-13 22:04:00 -07:00
Jacob Mizraji
7b7122fc11 Update ClangImporter and IRGenDebugInfo to build with upstream clang
(cherry picked from commit dab04d0517)
(cherry picked from commit d6b6594d77e01f5bb006897a42ec0a65665fcb9d)
2016-05-13 22:03:27 -07:00
Mark Lacey
5e41d3ffd9 Fixes for TypedDINodeRef API change. 2016-05-03 17:08:44 -07:00
Mark Lacey
182b6dfb18 Merge remote-tracking branch 'origin/master' into master-next
Conflicts:
	tools/driver/CMakeLists.txt
	tools/swift-reflection-dump/swift-reflection-dump.cpp
2016-05-03 14:23:20 -07:00
John McCall
560f71fa5d Remove IRGenDebugInfo's dependency on querying the IRGenerator during construction.
Also remove unused IsLibrary flag.
2016-04-27 10:06:21 -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
Doug Gregor
d1c81aa68f Adjust to LLVM r265077 and Clang r265711, courtesy of Chris Willmore 2016-04-12 17:14:02 -07:00
Slava Pestov
a656fcdc8e Fix some compiler warnings with asserts disabled 2016-04-07 11:14:22 -07:00
practicalswift
abfecfde17 [gardening] if ([space]…[space]) → if (…), for(…) → for (…), while(…) → while (…), [[space]x, y[space]] → [x, y] 2016-04-04 16:22:11 +02:00
Slava Pestov
5f8426b206 IRGen: More precise logic in debug info emission for globals
Previously we were using "has public visibility" as a proxy for
"comes from user code", which was OK because all global variables
had public linkage, even if they were internal or private in
the AST.

Now that this is about to change, let's check that we have a
SILLocation instead.
2016-03-28 14:14:49 -07:00
Erik Eckstein
b895a6498a IRGen: deal with DebugLoc locations in function scopes.
Plus a little bit refactoring.
2016-03-18 13:44:08 -07:00
Adrian Prantl
35fd887b69 Remove dead code. 2016-03-10 12:18:57 -08:00
Adrian Prantl
c0c8fbe1d2 Remove unused function. 2016-03-10 12:17:45 -08:00
Adrian Prantl
55607b2dbe Move IRGenDebugInfo Doxygen comments into the header file, LLVM-style.
NFC
2016-03-10 12:15:48 -08:00
Adrian Prantl
1f48b05f1f Debug Info: Retrieve the layout information of exploded values from the
explosion schema rather than from the debug type information and retire
a bunch of heuristics that are no longer necessary.

To enable this, this commit also includes a bugfix to debug info for
opaque data structures with the correct size and alignment information.

<rdar://problem/21470869+22707597>

This reapplies ad4f065ad6 and 7e489db9 after fixing the problem
uncovered by this commit in 5726370c1.
2016-03-10 10:16:02 -08:00