[swift-dev] Problem in parsing SIL

Slava Pestov spestov at apple.com
Tue Jun 21 16:03:01 CDT 2016


Hi Mikio,

Try this:

swiftc -frontend -emit-silgen classdecl.swift > classdecl.sil
swiftc -parse-sil classdecl.sil

I'm not sure why -emit-silgen sometimes emits type declarations and other times not. The only difference I can see is what without the -frontend flag, the driver passes in -primary-file, whereas with -frontend, it does not.

Perhaps Joe or Jordan can chime in.

> On Jun 14, 2016, at 2:39 AM, Mikio Takeuchi via swift-dev <swift-dev at swift.org> wrote:
> 
> Hi,
> 
> I am learning SIL and trying to compile SIL generated by the Swift compiler.
> I succeeded in doing so with a simple Swift program for just printing "hi",
> but I got errors with another simple program which includes a declaration of a trivial class.
> 
> I am running swift-3.0-preview-1 bundled with Xcode8-beta on OS X El Capitan.
> 
> $ uname -a
> Darwin localhost 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64
> $ swiftc --version
> Apple Swift version 3.0 (swiftlang-800.0.30 clang-800.0.24)
> Target: x86_64-apple-macosx10.9
> $ cat print.swift
> print("hi")
> $ swiftc -emit-silgen print.swift > print.sil
> $ swiftc -parse-sil print.sil
> $ ./print
> hi
> $ cat classdecl.swift
> class MyObject { }
> $ swiftc -emit-silgen classdecl.swift > classdecl.sil
> $ swiftc -parse-sil classdecl.sil
> classdecl.sil:26:105: error: use of undeclared type 'MyObject'
> sil_scope 2 { loc "classdecl.swift":1:7 parent @_TFC9classdecl8MyObjectD : $@convention(method) (@owned MyObject) -> () }
>                                                                                                         ^~~~~~~~
> classdecl.sil:26:121: error: extraneous '}' at top level
> sil_scope 2 { loc "classdecl.swift":1:7 parent @_TFC9classdecl8MyObjectD : $@convention(method) (@owned MyObject) -> () }
>                                                                                                                         ^
> 
> (omitted)
> 
> If anybody know any clue, please let me know.
> 
> Thanks,
> Mikio Takeuchi
> _______________________________________________
> swift-dev mailing list
> swift-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev



More information about the swift-dev mailing list