Commit Graph

116 Commits

Author SHA1 Message Date
Michael Gottesman
a7bb61265c [deserialization] Tighten up deserialization of witness tables.
We now enforce via an assert that each witness table is unique and that
every protocol conformance that is referenceable from SIL must have a
witness table matched to it.

Also, I taught the linker that it should deserialize witness tables for
InitExistentialRefInst instructions, something that was missed before.

Swift SVN r17283
2014-05-02 22:28:13 +00:00
Joe Groff
51bde1485d Remove stray assertion.
The verifier will eventually check this (again).

Swift SVN r17128
2014-05-01 00:08:41 +00:00
Joe Groff
aeb607ad5b Fix latent SIL verification errors.
r15824 overrode SILVerifier::visitSILBasicBlock without calling up to the super definition, causing us to never actually verify any instructions for the past three weeks. Awesome. Patch up the latent bugs that have crept in, except for three devirtualizer tests that fail. This doesn't reenable the verifier because I don't want to cause crashes until all the regressions have been cleared up.

Swift SVN r17121
2014-04-30 22:33:46 +00:00
John McCall
8681963bcb A couple of long-overdue renames.
Builtin.ObjectPointer -> Builtin.NativeObject
Builtin.ObjCPointer -> Builtin.UnknownObject

Swift SVN r16634
2014-04-22 00:17:08 +00:00
Michael Gottesman
45b45b8b7a [cse] Teach CSE how to handle enum insts.
rdar://16560688

Swift SVN r16310
2014-04-14 11:05:41 +00:00
Michael Gottesman
0bc4f9c936 Call SILFunction destructor when we cleanup functions so that if the function contains a function_ref, the function referenced by the function_ref has its refcount properly decrement.
Otherwise a function_ref which was supposed to be deallocated would keep
functions alive.

rdar://16287331

Swift SVN r16192
2014-04-11 01:44:38 +00:00
John McCall
a7a4f67f1b Bump the reference count of a function as long as it's sitting
around in the deserializer's .
1,2d
1i
Bump the reference count of a SILFunction as long as it's sitting
around in the deserializer's cache.

If we deserialize a function, then delete it, then deserialize
another reference to it, we'll end up pointing to a deleted
function.  This was causing the bug where IRGen would assert
with "no order number for SIL function definition?"; I can't
seem to find a radar for that, though.

Also, deserialization test cases are hard to write and probably
inherently unstable.

Swift SVN r15908
2014-04-04 00:53:55 +00:00
Chris Lattner
afea47b621 rename "destroy_value" to "release_value", part of rdar://15889208.
Swift SVN r15777
2014-04-02 05:33:52 +00:00
Joe Groff
f6f3d6c324 SIL: StringLiteralInsts aren't identical if their encodings differ.
Fixes a problem where CSE would coalesce string_literals with the same text but different encodings when they happened to land in the same hash bucket.

Swift SVN r15603
2014-03-29 02:50:36 +00:00
Nadav Rotem
51087ea8b0 CSE cond_fail.
Swift SVN r15111
2014-03-16 04:27:07 +00:00
Nadav Rotem
6b6761fa08 CSE ApplyInst of BuiltIns with no side effects.
Swift SVN r15110
2014-03-16 03:52:18 +00:00
Nadav Rotem
9583261228 CSE two more instructions.
Swift SVN r15102
2014-03-15 07:25:26 +00:00
Doug Gregor
5d8bd84dfa Introduce the SIL instruction alloc_ref_dynamic.
alloc_ref_dynamic allocates an instance of a class type based on the
value in its metatype operand. Start emitting these instructions for
the allocating constructor of a complete object initializer (not yet
tested) and for the allocating constructor synthesized for an imported
Objective-C init method.

Still missing:
  - IRGen still does the same thing as alloc_ref right now. That
  change will follow.
  - There are devirtualization opportunities when we know the value of
  the metatype that would turn an alloc_ref_dynamic into an alloc_ref;
  I'm not planning to do this optimization.



Swift SVN r14560
2014-03-01 21:55:50 +00:00
Doug Gregor
2134072285 Split open_existential[_ref] out as their own instructions.
Riding off of project_existential[_ref] was convenient, but the
resuls are used quite differently. Note that open_existential[_ref]
still don't print/parse reasonably yet.



Swift SVN r13878
2014-02-13 23:42:23 +00:00
Michael Gottesman
2bf56c0dee Add in abstract SILInstruction AllocationInst so we can query if we have an Alloc{Stack,Box,Ref,Array} by just doing isa<AllocationInst>.
Swift SVN r13515
2014-02-05 23:02:58 +00:00
Chris Lattner
7532213f4a simplify the SIL string_literal instruction to only produce a single value,
which is the address of the string data.  Have SILGen compute and produce the
isASCII bit as an integer literal, and remove the logic from IRGen.

This overall approach is simpler and enables better SIL-level optimizations.


Swift SVN r13363
2014-02-03 19:10:37 +00:00
Nadav Rotem
56fea71716 Add more cases to the InstructionComperator. Also, return ‘false’ on unknown instructions instead of asserting.
Swift SVN r13091
2014-01-29 06:11:36 +00:00
Michael Gottesman
38871aed5e Add in abstract base class LiteralInst for literal instructions and modify all the literal SIL classes to inherit from it appropriately.
Swift SVN r12764
2014-01-22 19:23:11 +00:00
Nadav Rotem
1c9fbf5dac Teach CSE about ref_element_addr.
Swift SVN r12324
2014-01-15 07:45:44 +00:00
Chris Lattner
d82df1e073 make the SIL Printer print the var decl associated with a debug_value[_addr],
like this:
  debug_value %0 : $Int64  // let a               // id: %2



Swift SVN r12191
2014-01-11 01:40:15 +00:00
Chris Lattner
1c7803a1f9 Introduce new debug_value and debug_value_addr instructions to
give 'let' declarations debug info.  This is part of rdar://15785053.

IRGen is just stubbed out and nothing generates these yet (other than
the sil parser).


Swift SVN r12179
2014-01-11 01:07:36 +00:00
Doug Gregor
3f09a9891d Add an [objc] bit to the alloc_ref instruction to indicate when to use Objective-C's +allocWithZone:.
Swift SVN r12099
2014-01-09 21:35:55 +00:00
Joe Groff
8f6a58b998 SIL: Split address-only enum dispatch from destructive projection.
Split 'destructive_switch_enum_addr' into separate 'switch_enum_addr' and 'take_enum_data_addr' instructions. This should unblock some optimization work we would like to do with enums.

Swift SVN r12015
2014-01-07 22:58:21 +00:00
John McCall
12b1c9daf7 Add support for multiple encodings to the string_literal
SIL instruction.  Implement IR-gen support for same.  Fix
the parsing of SIL string literals to properly unescape them.

SIL-gen still emits UTF8 literals unconditionally.

Swift SVN r11904
2014-01-04 11:42:57 +00:00
Doug Gregor
1ee513e7e8 Use Builtin.Word for array lengths, string literal lengths, etc.
This eliminates a number of 64-bit integer/64-bit pointer assumptions
in the type checker and SILGen.


Swift SVN r11863
2014-01-03 18:53:01 +00:00
Nadav Rotem
20410a3b92 CondBranchInst: Save the number of true and false arguments.
The current implementation depends on the target basic block to record the number of argumens, but this is a bad idea because it makes it difficult to modify the argument list.



Swift SVN r11597
2013-12-23 06:23:02 +00:00
Michael Gottesman
045b9eb6f9 [cse] Add support for metatype.
With this commit CSE reduces the size of the standard library in SIL by 3840
lines.

Swift SVN r10913
2013-12-06 05:04:44 +00:00
Michael Gottesman
b3b50b0997 Refactor out the isIdenticalTo code into a visitor pattern.
This is inspired by Chris's SILVisitor suggestion for CSE.

Swift SVN r10911
2013-12-06 04:48:41 +00:00
Michael Gottesman
878cf0bb98 Rename SILInstructionMemoryBehavior => MemoryBehavior and move MemoryBehavior into SILInstruction.
Swift SVN r10770
2013-12-04 01:38:13 +00:00
Michael Gottesman
d8d1393611 Implement SILInstruction::isIdenticalTo for all literal types in preparation for CSE.
The code here is a simple checklist. It performs the following checks in order:

1. Quick check to see if the kind/number of operands/number of types match up.
2. Comparison all of the types/operands.
3. Finally use a switch to perform specialized per instruction comparisons on
state not represented in the instructions types/operands (i.e. vardecls,
structdecls, etc.).

Additionally the switch is setup so that instructions which have not been fully
implemented in the switch will cause an unreachable to be hit. Once all
instructions have isIdenticalTo implementations (implying the switch is
covered), I will remove the unreachable.

*NOTE* The primary use case for this now is CSE. In CSE we can control which
instructions we process so during the review process I am only going to process
literals for the sake of simplicity (and thus this patch contains only code for
checking literals).

Swift SVN r10743
2013-12-03 00:26:10 +00:00
Michael Gottesman
c2342df22e Removed trailing whitespace.
Swift SVN r10738
2013-12-02 22:52:01 +00:00
Chris Lattner
ad05efc481 Redesign the BuiltinFunctionRefInst to contain an Identifier instead of
a FuncDecl.  This makes it much more straight-forward for SIL passes to
introduce a new one - without doing name lookup in the builtin module!



Swift SVN r10694
2013-11-30 01:49:36 +00:00
Chris Lattner
3b954ed44d strength reduce SILGenModule::getBuiltinInfo/getIntrinsicInfo to
take an identifier instead of a FuncDecl.


Swift SVN r10692
2013-11-30 00:57:46 +00:00
Chris Lattner
ec283ac8b9 add a SILInstruction::clone method that does a trivial copy of an instruction.
Swift SVN r10686
2013-11-29 23:36:51 +00:00
Joe Groff
f6b1745650 SIL: Remove 'ModuleInst'.
Module values could never be used for anything, and we have SILUndef now, so when SILGen sees a ModuleExpr, we can just emit 'undef'.

Swift SVN r10548
2013-11-18 21:36:08 +00:00
Joe Groff
4c0ebedc6a SIL: Add SILGlobalAddrInst.
Like GlobalAddrInst, but for SILGlobalVariables. These would become the same instruction when SILGlobalVariable can replace AST-level global references.

Swift SVN r10510
2013-11-16 00:50:18 +00:00
Joe Groff
19457c12ea Give Builtin.Word an abstract size.
Instead of hardcoding Builtin.Word to be an alias for Builtin.Int64, make it its own type of abstract pointer width.

- Change BuiltinIntegerType's width representation to accommodate abstract widths.

- In the AST and in SIL, store values of the types as the greatest supported size for the abstract width (64 bits for a pointer).

- Add some type safety to the ([sz]ext|trunc)(OrBitCast)? builtins that they're used appropriately given the upper and lower bounds of the abstract sizes they're working with.

- Now that Builtin.Word is a distinct type, give it its own mangling.

- In IRGen, lower pointer-sized BuiltinIntegerType appropriately for the target, and truncate lowered SIL values if necessary.

Fixes <rdar://problem/15367913>.

Swift SVN r10467
2013-11-14 19:56:26 +00:00
Stephen Lin
615870004a Correct an error message
Swift SVN r10461
2013-11-14 18:24:23 +00:00
Chris Lattner
425819ac07 Change the SIL string_literal instruction to produce three results
(the same way alloc_box returns two) instead of returning a tuple.

This eliminates a ton of tuple_extract instructions, which just
bloat the generated SIL.  This resolves rdar://15378135.



Swift SVN r10416
2013-11-13 06:43:09 +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
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
Dmitri Hrybenko
b62e8903de Portability: libstdc++ does not implement is_trivially_copyable yet, implement
our own wrapper


Swift SVN r9695
2013-10-27 05:52:22 +00:00
Adrian Prantl
37bb48afb0 Debug info: Create debug type info for box-allocated types by using their
Decl. This should allow us to emit debug info for boxed generic types.

rdar://problem/15180622

Swift SVN r9071
2013-10-09 18:25:18 +00:00
Stephen Lin
3f5c0dbf0e Update SILArgument::getModule(), SILBasicBlock::getModule() and SILInstruction::getModule() signatures to match SILFunction::getModule(), for consistency; standardize usage of SILFunction::getParent() to SILFunction::getModule().
Swift SVN r8932
2013-10-04 21:12:20 +00:00
Stephen Lin
a6108dbd48 Rename FunctionRefInst::getFunction() and BuiltinFunctionRefInst::getFunction() to FunctionRefInst::getReferencedFunction() and BuiltinFunctionRefInst::getReferencedFunction() to avoid shadowing SILInstruction::getFunction().
Swift SVN r8929
2013-10-04 20:26:41 +00:00
Joe Groff
82a18333ed SIL: Purge SpecializeInst.
Make ApplyInst and PartialApplyInst directly take substitutions for generic functions instead of trying to stage out substitutions separately. The legacy reasons for doing this are gone.

Swift SVN r8747
2013-09-28 00:15:45 +00:00
Michael Gottesman
7bc9b9bfb8 Added SILInstruction::moveBefore to move an instruction before another instruction.
This is the same as llvm::Instruction::moveBefore.

Swift SVN r8689
2013-09-26 01:54:28 +00:00
Joe Groff
014f270516 SIL: Have project_existential_ref project to a protocol Self archetype.
This mirrors the behavior of project_existential and simplifies some special cases in SILGen. It unfortunately makes dynamic_lookup sequences a bit noisier because of the need to explicitly cast the projection from DynamicLookup.Self to Builtin.ObjCPointer, but I think this modeling is more solid and will fit better with my planned redesign of archetype_method/protocol_method.

Swift SVN r8572
2013-09-23 21:57:12 +00:00
Joe Groff
e109124186 Replace 'union' keyword with 'enum'.
This only touches the compiler and tests. Doc updates to follow.

Swift SVN r8478
2013-09-20 01:33:14 +00:00
Anna Zaks
1065caa2f4 [SIL] Store the BitWidth in the SwitchInstInst instead of computing it
getBitWidthForCase() is called from the destructor of the object and it
used to rely on Operand being around. However, dropAllReferences(), which
is run before instruction destruction makes the operand invalid at the
time of instruction death. (This results in a crash if we were to delete a
SwitchInstInt instruction.)

Swift SVN r8472
2013-09-19 23:41:03 +00:00