Commit Graph

6634 Commits

Author SHA1 Message Date
Chris Lattner
f6d339526d fix typo
Swift SVN r9934
2013-11-04 22:43:52 +00:00
Jordan Rose
553983f584 Fix misuse of alignof, which returns alignment as 2^N instead of N.
If we constexpr'd some of the functions in MathExtras we could use
log2(alignof(T)), but for now just hardcode a literal "3".

Swift SVN r9928
2013-11-04 18:22:25 +00:00
Chris Lattner
db86f4dad1 Bump SILValue up to allow 2 bits of result number, enabling instructions to produce up to 4 results.
Swift SVN r9924
2013-11-04 18:02:08 +00:00
Chris Lattner
82567f9ffb SILValue is just a wrapper around its ValueAndResultNumber. Derive
the number of low bits available in it from the #bits in ValueAndResultNumber,
instead of computing it independently.


Swift SVN r9922
2013-11-04 17:54:42 +00:00
Chris Lattner
2909a0e129 teach simplifycfg to constant fold switch_enum instructions, now that
all the tuple stuff is out of the way.  This kicks in 600 times in the
stdlib and ends up shrinking the stdlib by 2500 lines (down to 53209).


Swift SVN r9903
2013-11-03 16:52:50 +00:00
Chris Lattner
68af974227 Remove 'axle' related code and build machinery. It turns out that we
will not be pursuing this project in the immediate future.



Swift SVN r9901
2013-11-03 16:04:27 +00:00
Chris Lattner
8083f2d9c8 add setOperand() to unary instructions.
Swift SVN r9899
2013-11-03 05:53:23 +00:00
Chris Lattner
a2a1b2af55 Clean up tuple and extract SILBuilder stuff:
- Introduce emitTupleExtract / emitStructExtract, which fold when their operand is a tuple/struct.
- Rename SILBuilder::createTupleExtractInst -> createTupleExtract, "Inst" isn't used as a suffix.
- Switch capture promotion and DI to use the new functions.

This trims 300 lines out of the stdlib.


Swift SVN r9897
2013-11-03 04:47:40 +00:00
Dmitri Hrybenko
91ce21666d Change 'func' keyword to 'def'
I tried hard find all references to 'func' in documentation, comments and
diagnostics, but I am sure that I missed a few.  If you find something, please
let me know.

rdar://15346654


Swift SVN r9886
2013-11-02 01:00:42 +00:00
Joe Groff
003709d51f SIL: Add a backreference from SILModule to its originating Swift Module.
Ideally this wouldn't be necessary, but the type substitution APIs required by generic specialization and SIL verification currently require a Module* pointer, and it's obnoxious to have to pass it down separately everywhere it's needed. Longer-term the reliance on Modules for type substitution might be able to go away.

Swift SVN r9866
2013-11-01 00:46:21 +00:00
Joe Groff
c57ea38b95 SILGen: Don't produce context arguments for captured typealiases.
If a local function tried to reference a local typealias, we were trying to emit a SIL variable reference and freaking out, causing <rdar://problem/15360605>. For now, don't emit any capture arguments for local typealiases. Any context a local typealias requires should be handled by capturing the external context's generic parameters.

Swift SVN r9865
2013-11-01 00:12:29 +00:00
Chris Lattner
419b3c5ac8 tidy up * placement.
Swift SVN r9852
2013-10-31 20:55:11 +00:00
Chris Lattner
db9cda3d96 introduce a SILBasicBlock::getPreds() range to match getSuccs()
Swift SVN r9851
2013-10-31 20:54:59 +00:00
Chris Lattner
03e7b756d0 teach simplify-cfg to merge blocks connected by an uncond branch, when
the dest has no other predecessors.  This fires 6926 times on the stdlib.


Swift SVN r9794
2013-10-30 16:48:59 +00:00
Chris Lattner
681ad64db3 teach simplifycfg's dead block deletion to correctly handle blocks with
instructions that are used cross-block.


Swift SVN r9788
2013-10-30 14:23:51 +00:00
Chris Lattner
ef93c81ffb Introduce a new SIL-level "undef" value, useful for SIL transformations.
IRGen support is missing, Joe volenteers to implement it.


Swift SVN r9776
2013-10-30 00:58:09 +00:00
Chris Lattner
6c23f3e8f8 Add an important assert to ValueBase, to make it a hard error to delete
a value that still has uses.  Doing so leaves dangling pointers and is
unwise.  Nothing in the testsuite triggers this, but simplify-cfg can
on real code.


Swift SVN r9770
2013-10-29 23:44:51 +00:00
Anna Zaks
7e47f5984a Fix a comment.
Swift SVN r9767
2013-10-29 22:27:27 +00:00
Chris Lattner
c118613de3 Fix SILValue use_iterators to type the user as a SILInstruction, not just a ValueBase.
There are no values other than instructions that can use other values.  BBArguments are
defs, not uses.  This eliminates a bunch of casts in clients that use getUser().


Swift SVN r9701
2013-10-27 23:32:14 +00:00
Chris Lattner
5ce1700021 - Mark the copyaddr's generated for inout shadow variables as autogenerated,
so they can be easily identified by the inout deshadowing pass.  This does
  not mark the alloc_box as autogenerated though, since it is a user variable
  when the variable escapes.

- Fix some wonky indentation in SILLocation.



Swift SVN r9700
2013-10-27 22:48:05 +00:00
Chris Lattner
2127da6a91 Enhance the function_ref instruction to maintain a refcount on the
SILFunction that it references.  Use this in the mandatory inlining
pass to remove deserialized transparent functions, to clean up the
-emit-sil output of the compiler (and presumably speed up compile 
time).  This implements rdar://15272652



Swift SVN r9699
2013-10-27 22:00:54 +00:00
Adrian Prantl
5bbe0afb9f Debug info: Properly handle the function prologue in the line table.
Introduces a new flag in SILLocation: InPrologue to mark instructions
that setup the stack and allocate storage for local variables/arguments.

Fixes rdar://problem/15290023: Breakpoint set on prologue - crash ensues.

Swift SVN r9686
2013-10-26 00:12:20 +00:00
Anna Zaks
27328ac459 Warn on unreachable code due to a constant condition in a switch over enum.
Swift SVN r9679
2013-10-25 21:55:12 +00:00
Michael Gottesman
fdebc3db11 [sil-combine] Port of LLVM's pattern matching infrastructure to SIL.
The attached patch is a port of LLVM's PatternMatch infrastructure for SIL.
LLVM's pattern matching infrastructure is how much of InstCombine is implemented
and the brevity of its pattern matching should be a boon to SILCombine's
implementation as well.

Many basic matchers have been implemented, but of course many more *could* be
implemented (i.e. this is a work in progress).

Swift SVN r9650
2013-10-24 19:25:58 +00:00
Joe Groff
00dcdf394f SIL: Introduce CondFailInst.
This instruction will conditionally trigger a runtime failure if its operand is true.

Swift SVN r9588
2013-10-22 15:53:04 +00:00
Chris Lattner
91c7cea310 Remove the SILModule& argument from a few methods in SILInstruction.h.
Instructions know which module they came from, so there is no need to
pass it in.



Swift SVN r9584
2013-10-22 11:06:50 +00:00
Joe Groff
61360ba7a4 SIL: Remove ConvertCCInst.
Swift SVN r9577
2013-10-22 03:16:27 +00:00
Joe Groff
3a5267c020 SILGen: Build a thunk in SILGen instead of using convert_cc instruction.
We already know how to call external functions in SILGen, why reimplement all that in IRGen? Instead of representing the thunk operation as a SIL instruction, let's just emit the thunk using existing SILGen machinery. Fixes <rdar://problem/14097136>.

Swift SVN r9576
2013-10-22 03:16:15 +00:00
Adrian Prantl
5cf8999985 Debug info: some more refactoring for rdar://problem/14845534.
Swift SVN r9571
2013-10-21 23:38:18 +00:00
Chris Lattner
3b84c0fc05 use the standard idiom for defining a const and non-const version of a method.
Swift SVN r9526
2013-10-20 15:19:59 +00:00
Michael Gottesman
a2ee7a3d60 Make sure that the non-const version of getOperandForField calls the const version of said function instead of infinite looping.
Swift SVN r9524
2013-10-20 12:12:52 +00:00
Adrian Prantl
3fafb6c7e7 Debug info: Make the ret instruction in the function epilogue a cleanup
location rather than a regular location to avoid the linetable jumping
back to the beginning of the function.
Add a large number of testcases that check the sanity of the return
locations in various scenarios involving implicit/explicit returns,
cleanups, and multiple return locations per function.

rdar://problem/14845534

Swift SVN r9511
2013-10-19 00:20:44 +00:00
Dmitri Hrybenko
e51e9bfcfa Fix comment style
Swift SVN r9454
2013-10-17 18:38:58 +00:00
Sean Callanan
ac43e98dd2 Added SILExternalSource, a class that can be used
to interpose on the SIL linking process.  Under the
following conditions:

- a function is called by the current SILModule;
- that function is transparent and empty in the
  generated SIL;
- the SIL linker doesn't find a serialized
  version of it; and
- the external client (right now, LLDB) has a
  SILExternalSource installed in the SILModule;

the SIL linker will query the SILExternalSource
via lookupSILFunction.

This interface will be used by LLDB to provide
SIL accessors for a program's variables when they
are referred to by Swift expressions.


Swift SVN r9452
2013-10-17 18:04:24 +00:00
Anna Zaks
4d50044dd8 Add MandatoryInlinedLocation SIL location type.
This will allow us to differentiate from regular inlined code (as in optimization inlining). Some passes(AllocBocToStack) and debug info would be allowed to be more aggressive/preserve less debug info with mandatory inlined code.

Swift SVN r9339
2013-10-15 00:17:51 +00:00
Chris Lattner
a6cde9cd8d Add a convenience function to map a CanType+StructDecl to the mapped
CanType.  This doesn't really fit on SILBuilder, but until StructType 
and BoundGenericStructType are merged, this will do.


Swift SVN r9336
2013-10-14 23:42:41 +00:00
Chris Lattner
589bd7362a simplify this, per Joe's advice.
Swift SVN r9316
2013-10-14 17:07:24 +00:00
Chris Lattner
8a6b5a29a2 add some helpers that return the struct/tuple associated with a
{struct|tuple}_element[_addr] instruction.



Swift SVN r9315
2013-10-14 17:01:22 +00:00
Dmitri Hrybenko
ae0826e34a Fix compilation issues with ToT Clang
Swift SVN r9313
2013-10-14 16:11:29 +00:00
Michael Gottesman
e90c93b344 [sil] Removed stale comment and replaced one instance of auto with the actual type for additional clarity.
Swift SVN r9228
2013-10-11 22:19:45 +00:00
John McCall
2e41a8dcc6 Fix CRTP on SILVisitor.
Swift SVN r9206
2013-10-11 18:09:19 +00:00
Michael Gottesman
9de1dbf1ea [sil] Teach StructInsts how to return the operand for a given VarDecl.
This allows you to lookup the operand extracted from a struct by a
struct_extract in a SIL pass.

Swift SVN r9189
2013-10-11 02:53:10 +00:00
John McCall
8fbc790d39 Subsume OwnershipConventions into SILFunctionType.
Swift SVN r9186
2013-10-11 00:50:57 +00:00
Jordan Rose
25deab5f31 Misc. cleanup related to use of TranslationUnit.
Swift SVN r9164
2013-10-10 19:49:32 +00:00
Joe Groff
8f68e1b68b SIL: Add create(Struct,Tuple)ElementAddr helpers that derive the element type.
To be consistent with create(Struct,Tuple)Extract.

Swift SVN r9138
2013-10-10 15:34:17 +00:00
Joe Groff
5650130518 SIL: Substitute struct field types when creating struct ops in passes.
The AST type of the VarDecl is incorrect for bound generic structs and needs to be substituted.

Swift SVN r9130
2013-10-10 04:35:57 +00:00
John McCall
af706c889a swift::SILFunctionType::ParameterType -> swift::SILParameterInfo
swift::SILFunctionType::ReturnType -> swift::SILReturnInfo

Swift SVN r9116
2013-10-10 00:31:38 +00:00
Jordan Rose
5ed38c0b72 Clarify SourceFile vs. TranslationUnit interfaces for SILGen and IRGen.
Once we have multiple SourceFiles in a TranslationUnit, it no longer makes
sense to say "only SILGen decls starting from element N" without specifying
which source file you mean.

Also, clarify ownership by having performSILGeneration return a unique_ptr
instead of just a bare pointer.

Swift SVN r9112
2013-10-09 23:44:43 +00:00
John McCall
b880e60100 Remove SILFunctionTypeInfo in favor of SILFunctionType.
We still don't actually use this as a type, however.

Swift SVN r9091
2013-10-09 20:55:55 +00:00
John McCall
dcf9d15cc7 Rewrite SILFunctionTypeInfo in terms of SILFunctionType.
Swift SVN r9090
2013-10-09 20:55:46 +00:00