[swift-dev] [Starter Project] Teach SILParser how to parse switch_enum of undef.

Joe Groff jgroff at apple.com
Thu Dec 17 14:32:40 CST 2015


> On Dec 17, 2015, at 3:37 AM, Emanuel Zephir via swift-dev <swift-dev at swift.org> wrote:
> 
> Okay, that works.
> 
> I have a few questions about SR-210:
> 
> 1) The attached patch adds support for undefined integer value-cases in the switch_value instruction. What is the runtime meaning of this construct?

SIL 'undef' has the same meaning as LLVM's 'undef'. It means that the exact value isn't important and can be substituted with an arbitrary bit pattern. It's UB if the behavior of the program depends on the value of an undef, but safe if the undef can be eliminated, such as if it's dead, or eliminated by an operation like 'x & 0' or 'x - x' that's invariant of 'x'.

> 2) Are there any other SIL instructions in the select/switch family that need modifications? If yes, which? At least some of them (e.g. select_value) don't support this either.

'undef' ought to be parsed as part of the SIL value grammar. It'd be worth doing a pass to make sure we consistently use the same parsing rule everywhere we accept a value.

-Joe

> 3) Are there any areas that need special attention when writing tests and otherwise validating this change?
> 
> 
> --Emanuel
> 
> On Wed, Dec 16, 2015 at 10:15 AM, Michael Gottesman <mgottesman at apple.com <mailto:mgottesman at apple.com>> wrote:
> SGTM. If you want as you finish these, I have a list of them = ).
> 
> I just filed another one:
> 
> https://bugs.swift.org/browse/SR-247 <https://bugs.swift.org/browse/SR-247>
> 
> Michael
> 
>> On Dec 16, 2015, at 5:30 AM, Emanuel Zephir <emanuelzephir at gmail.com <mailto:emanuelzephir at gmail.com>> wrote:
>> 
>> Unless anyone objects, I'd like to claim this. I've assigned issue SR-210 to myself.
>> 
>> --Emanuel
>> 
>> On Sun, Dec 13, 2015 at 1:29 PM, Michael Gottesman via swift-dev <swift-dev at swift.org <mailto:swift-dev at swift.org>>wrote:
>> This is a small starter project for those who are interested in working with SIL.
>> 
>> The SIL Parser currently is unable to parse switch_enum of undef. I wrote a patch that does the work some time ago, but I never have had time to finish it (i.e. make sure everything works ok/write tests). I posted the patch in this issue:
>> 
>> https://bugs.swift.org/browse/SR-210 <https://bugs.swift.org/browse/SR-210>
>> 
>> My hope is that even though a lot of the work is already done this may serve as good starting point for someone who wants to poke at the SIL Parser (a part of the code base that has not gotten as much attention as others).
>> 
>> Michael
>> 
>> 
>> _______________________________________________
>> swift-dev mailing list
>> swift-dev at swift.org <mailto:swift-dev at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-dev <https://lists.swift.org/mailman/listinfo/swift-dev>
>> 
>> 
> 
> 
>  _______________________________________________
> swift-dev mailing list
> swift-dev at swift.org <mailto:swift-dev at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-dev <https://lists.swift.org/mailman/listinfo/swift-dev>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-dev/attachments/20151217/7ef562a6/attachment.html>


More information about the swift-dev mailing list